]> granicus.if.org Git - clang/log
clang
6 years agoReland r332885, "CodeGen, Driver: Start using direct split dwarf emission in clang."
Peter Collingbourne [Tue, 22 May 2018 18:52:37 +0000 (18:52 +0000)]
Reland r332885, "CodeGen, Driver: Start using direct split dwarf emission in clang."

As well as two follow-on commits r332906, r332911 with a fix for
test clang/test/CodeGen/split-debug-filename.c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333013 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[clang-format] Fix putting ObjC message arguments in one line for multiline...
Jacek Olesiak [Tue, 22 May 2018 16:44:42 +0000 (16:44 +0000)]
Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

Summary: Reverts D46879

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: krasimir, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47205

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332998 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r332982 Call CreateTempMemWithoutCast for ActiveFlag
Yaxun Liu [Tue, 22 May 2018 16:13:07 +0000 (16:13 +0000)]
Revert r332982 Call CreateTempMemWithoutCast for ActiveFlag

Due to regression on arm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332991 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] produce the LLVM canonical form of abs
Sanjay Patel [Tue, 22 May 2018 15:36:50 +0000 (15:36 +0000)]
[CodeGen] produce the LLVM canonical form of abs

We chose the 'slt' form as canonical in IR with:
rL332819
...so we should generate that form directly for efficiency.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332989 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] add tests for abs builtins; NFC
Sanjay Patel [Tue, 22 May 2018 15:11:59 +0000 (15:11 +0000)]
[CodeGen] add tests for abs builtins; NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332988 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCall CreateTempMemWithoutCast for ActiveFlag
Yaxun Liu [Tue, 22 May 2018 14:36:26 +0000 (14:36 +0000)]
Call CreateTempMemWithoutCast for ActiveFlag

Introduced CreateMemTempWithoutCast and CreateTemporaryAllocaWithoutCast to emit alloca
without casting to default addr space.

ActiveFlag is a temporary variable emitted for clean up. It is defined as AllocaInst* type and there is
a cast to AlllocaInst in SetActiveFlag. An alloca casted to generic pointer causes assertion in
SetActiveFlag.

Since there is only load/store of ActiveFlag, it is safe to use the original alloca, therefore use
CreateMemTempWithoutCast is called.

Differential Revision: https://reviews.llvm.org/D47099

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332982 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeView] Enable debugging of captured variables within C++ lambdas
Brock Wyma [Tue, 22 May 2018 12:41:19 +0000 (12:41 +0000)]
[CodeView] Enable debugging of captured variables within C++ lambdas

This change will help Visual Studio resolve forward references to C++ lambda
routines used by captured variables.

Differential Revision: https://reviews.llvm.org/D45438

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332975 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Add a test case for crash
Krasimir Georgiev [Tue, 22 May 2018 11:44:03 +0000 (11:44 +0000)]
[clang-format] Add a test case for crash

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332974 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "CodeGen, Driver: Start using direct split dwarf emission in clang."
Amara Emerson [Tue, 22 May 2018 11:18:58 +0000 (11:18 +0000)]
Revert "CodeGen, Driver: Start using direct split dwarf emission in clang."

This reverts commit r332885 as it broke several greendragon buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332973 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Fix another make_unique ambiguity."
Amara Emerson [Tue, 22 May 2018 11:18:49 +0000 (11:18 +0000)]
Revert "Fix another make_unique ambiguity."

This reverts commit r332906 as a dependency to revert r332885.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332972 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Add missing x86-registered-target."
Amara Emerson [Tue, 22 May 2018 11:18:43 +0000 (11:18 +0000)]
Revert "Add missing x86-registered-target."

This reverts commit r332911, as a dependency to revert r332885.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332971 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format: [JS] do not wrap before any `is`.
Martin Probst [Tue, 22 May 2018 10:39:07 +0000 (10:39 +0000)]
clang-format: [JS] do not wrap before any `is`.

Summary:
`is` type annotations can occur at any nesting level. For example:

    function x() {
      return function y(): a is B { ... };
    }

Breaking before the `is` above breaks TypeScript parsing the code. This
change prevents the wrap.

Reviewers: krasimir

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47193

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332968 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[objc-gnustep2] Use unsigned char to avoid potential UB in isalnum.
David Chisnall [Tue, 22 May 2018 10:13:17 +0000 (10:13 +0000)]
[objc-gnustep2] Use unsigned char to avoid potential UB in isalnum.

Suggested by Gabor Buella.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332966 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[objc-gnu] Fix test.
David Chisnall [Tue, 22 May 2018 10:13:14 +0000 (10:13 +0000)]
[objc-gnu] Fix test.

The test was implicitly capturing the local filesystem layout.

Patch by Hans Wennborg!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332965 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[objc-gnustep2] Use isalnum instead of a less efficient and nonportable equivalent.
David Chisnall [Tue, 22 May 2018 10:13:11 +0000 (10:13 +0000)]
[objc-gnustep2] Use isalnum instead of a less efficient and nonportable equivalent.

Patch by Hans Wennborg!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332964 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Revert r332955 "GNUstep Objective-C ABI version 2""
David Chisnall [Tue, 22 May 2018 10:13:06 +0000 (10:13 +0000)]
Revert "Revert r332955 "GNUstep Objective-C ABI version 2""

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332963 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Fix crash in getLengthToMatchingParen
Krasimir Georgiev [Tue, 22 May 2018 09:46:55 +0000 (09:46 +0000)]
[clang-format] Fix crash in getLengthToMatchingParen

Summary:
Found by oss-fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8212

Reviewers: bkramer

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47191

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332961 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r332955 "GNUstep Objective-C ABI version 2"
Bjorn Pettersson [Tue, 22 May 2018 08:16:45 +0000 (08:16 +0000)]
Revert r332955 "GNUstep Objective-C ABI version 2"

Reverted due to buildbot failures.
Seems like isnumber() is some Apple addition to cctype.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332957 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd cctype include.
David Chisnall [Tue, 22 May 2018 07:22:50 +0000 (07:22 +0000)]
Add cctype include.

This appears to leak in already on libc++ platforms, but is breaking on
some other targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332955 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoGNUstep Objective-C ABI version 2
David Chisnall [Tue, 22 May 2018 06:09:23 +0000 (06:09 +0000)]
GNUstep Objective-C ABI version 2

Summary:
This includes initial support for the (hopefully final) updated Objective-C ABI, developed here:

https://github.com/davidchisnall/clang-gnustep-abi-2

It also includes some cleanups and refactoring from older GNU ABIs.

The current version is ELF only, other formats to follow.

Reviewers: rjmccall, DHowett-MSFT

Reviewed By: rjmccall

Subscribers: smeenai, cfe-commits

Differential Revision: https://reviews.llvm.org/D46052

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332950 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Prevent inclusion of __wmmintrin_aes.h and __wmmintrin_pclmul.h without includi...
Craig Topper [Tue, 22 May 2018 02:02:13 +0000 (02:02 +0000)]
[X86] Prevent inclusion of __wmmintrin_aes.h and __wmmintrin_pclmul.h without including wmmintrin.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332929 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd missing include for cstdint to Visibility.h
Raphael Isemann [Mon, 21 May 2018 22:27:22 +0000 (22:27 +0000)]
Add missing include for cstdint to Visibility.h

Summary: We use uint8_t in this header, so we need to include cstdint.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47164

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332913 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd missing x86-registered-target.
Peter Collingbourne [Mon, 21 May 2018 22:14:02 +0000 (22:14 +0000)]
Add missing x86-registered-target.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332911 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove a builtin that should have been removed in r332882.
Craig Topper [Mon, 21 May 2018 22:10:02 +0000 (22:10 +0000)]
[X86] Remove a builtin that should have been removed in r332882.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332909 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix another make_unique ambiguity.
Peter Collingbourne [Mon, 21 May 2018 21:48:17 +0000 (21:48 +0000)]
Fix another make_unique ambiguity.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332906 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.
Craig Topper [Mon, 21 May 2018 20:58:23 +0000 (20:58 +0000)]
[X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.

Because the intrinsics in the headers are implemented as macros, we can't just use a select builtin and pternlog builtin. This would require one of the macro arguments to be used twice. Depending on what was passed to the macro we could expand an expression twice leading to weird behavior. We could maybe declare our local variable in the macro, but that would need to worry about name collisions.

To avoid that just generate IR directly in CGBuiltin.cpp.

Differential Revision: https://reviews.llvm.org/D47125

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332891 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r332847; it caused us to miscompile certain forms of reference initialization.
Richard Smith [Mon, 21 May 2018 20:36:58 +0000 (20:36 +0000)]
Revert r332847; it caused us to miscompile certain forms of reference initialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332886 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCodeGen, Driver: Start using direct split dwarf emission in clang.
Peter Collingbourne [Mon, 21 May 2018 20:31:59 +0000 (20:31 +0000)]
CodeGen, Driver: Start using direct split dwarf emission in clang.

Fixes PR37466.

Differential Revision: https://reviews.llvm.org/D47093

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332885 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Use __builtin_convertvector to implement some of the packed integer to packed...
Craig Topper [Mon, 21 May 2018 20:19:17 +0000 (20:19 +0000)]
[X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

I believe this is safe assuming default default FP environment. The conversion might be inexact, but it can never overflow the FP type so this shouldn't be undefined behavior for the uitofp/sitofp instructions.

We already do something similar for scalar conversions.

Differential Revision: https://reviews.llvm.org/D46863

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332882 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to...
Peter Collingbourne [Mon, 21 May 2018 20:16:41 +0000 (20:16 +0000)]
CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to dwo output.

Part of PR37466.

Differential Revision: https://reviews.llvm.org/D47089

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332881 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r332028; see PR37545 for details.
Richard Smith [Mon, 21 May 2018 20:10:54 +0000 (20:10 +0000)]
Revert r332028; see PR37545 for details.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332879 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Clang Tablegen] Add llvm_unreachable() to getModifierName()
Mark Searles [Mon, 21 May 2018 17:29:08 +0000 (17:29 +0000)]
[Clang Tablegen] Add llvm_unreachable() to getModifierName()

Fix internal build failure:

../../../ClangDiagnosticsEmitter.cpp -o ClangDiagnosticsEmitter.o
../../../ClangDiagnosticsEmitter.cpp: In function 'llvm::StringRef
{anonymous}::getModifierName({anonymous}::ModifierType)':
../../../ClangDiagnosticsEmitter.cpp:495:1: error: control reaches end of non-void function [-Werror=return-type]
}
^

Build failure triggered by git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332799 91177308-0d34-0410-b5e6-96231b3b80d8

Differential Revision: https://reviews.llvm.org/D47150

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332854 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.
Alexey Bataev [Mon, 21 May 2018 16:40:32 +0000 (16:40 +0000)]
[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.

if `-fopenmp-simd` is specified alone, `_OPENMP` macro should not be
  defined. If `-fopenmp-simd` is specified along with the `-fopenmp`,
  `_OPENMP` macro should be defined with the value `201511`.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332852 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AMDGPU] fixes for lds f32 builtins
Daniil Fukalov [Mon, 21 May 2018 16:18:07 +0000 (16:18 +0000)]
[AMDGPU] fixes for lds f32 builtins

1. added restrictions to memory scope, order and volatile parameters
2. added custom processing for these builtins - currently is not used code,
   needed to switch off GCCBuiltin link to the builtins (ongoing change to llvm
   tree)
3. builtins renamed as requested

Differential Revision: https://reviews.llvm.org/D43281

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332848 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Recognize more cases of zero initialization
Serge Pavlov [Mon, 21 May 2018 16:09:54 +0000 (16:09 +0000)]
[CodeGen] Recognize more cases of zero initialization

If a variable has an initializer, codegen tries to build its value. If
the variable is large in size, building its value requires substantial
resources. It causes strange behavior from user viewpoint: compilation
of huge zero initialized arrays like:

    char data_1[2147483648u] = { 0 };

consumes enormous amount of time and memory.

With this change codegen tries to determine if variable initializer is
equivalent to zero initializer. In this case variable value is not
constructed.

This change fixes PR18978.

Differential Revision: https://reviews.llvm.org/D46241

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332847 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Fix incorrect packed aligned structure layout
Momchil Velikov [Mon, 21 May 2018 14:28:43 +0000 (14:28 +0000)]
[Sema] Fix incorrect packed aligned structure layout

Handle attributes before checking the record layout (e.g. underalignment check
during `alignas` processing), as layout may be cached without taking into
account attributes that may affect it.

Differential Revision: https://reviews.llvm.org/D46439

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332843 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Disable aggressive structor optimizations at -O0, take 2
Pavel Labath [Mon, 21 May 2018 11:47:45 +0000 (11:47 +0000)]
[CodeGen] Disable aggressive structor optimizations at -O0, take 2

The first version of the patch (r332228) was flawed because it was
putting structors into C5/D5 comdats very eagerly. This is correct only
if we can ensure the comdat contains all required versions of the
structor (which wasn't the case). This version uses a more nuanced
approach:
- for local structor symbols we use an alias because we don't have to
  worry about comdats or other compilation units.
- linkonce symbols are emitted separately, as we cannot guarantee we
  will have all symbols we need to form a comdat (they are emitted
  lazily, only when referenced).
- available_externally symbols are also emitted separately, as the code
  seemed to be worried about emitting an alias in this case.
- other linkage types are not affected by the optimization level. They
  either get put into a comdat (weak) or get aliased (external).

Reviewers: rjmccall, aprantl

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D46685

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332839 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove some preprocessor feature checks from intrinsic headers
Craig Topper [Mon, 21 May 2018 06:07:49 +0000 (06:07 +0000)]
[X86] Remove some preprocessor feature checks from intrinsic headers

Summary:
These look to be a couple things that weren't removed when we switched to target attribute.

The popcnt makes including just smmintrin.h also include popcntintrin.h. The popcnt file itself already contains target attrributes.

The prefetch ones are just wrappers around __builtin_prefetch which we have graceful fallbacks for in the backend if the exact instruction isn't available. So there's no reason to hide them. And it makes them available in functions that have the write target attribute but not a -march command line flag.

Reviewers: echristo, RKSimon, spatel, DavidKreitzer

Reviewed By: echristo

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47029

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332830 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove some unused builtins.
Craig Topper [Mon, 21 May 2018 03:36:57 +0000 (03:36 +0000)]
[X86] Remove some unused builtins.

These were upgraded to native shufflevectors months ago.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332829 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR...
Craig Topper [Sun, 20 May 2018 23:34:10 +0000 (23:34 +0000)]
[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR instead.

Someday maybe we'll use selects for all the builtins.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332825 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert 332750, clang part (see comment on D46910).
Nico Weber [Sun, 20 May 2018 23:02:20 +0000 (23:02 +0000)]
Revert 332750, clang part (see comment on D46910).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332822 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSema: diagnose invalid catch parameter in ObjC
Saleem Abdulrasool [Sun, 20 May 2018 19:26:44 +0000 (19:26 +0000)]
Sema: diagnose invalid catch parameter in ObjC

Ensure that the type being used has an associated interface when
declaring the parameter for `@catch`.

Resolves PR37384!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332821 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPrint the qualified name when dumping deserialized decls.
Vassil Vassilev [Sun, 20 May 2018 09:38:52 +0000 (09:38 +0000)]
Print the qualified name when dumping deserialized decls.

This is useful to understand and debug the lazy template specializations
used in the pch and modules.

Differential Revision: https://reviews.llvm.org/D41785

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332817 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Temporarily remove test for LLVM findNearest
Brian Gesiak [Sat, 19 May 2018 12:44:02 +0000 (12:44 +0000)]
[Driver] Temporarily remove test for LLVM findNearest

Summary:
This fixes a failure caused by the revert of https://reviews.llvm.org/rL332805.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332806 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Loosen test for LLVM findNearest
Brian Gesiak [Sat, 19 May 2018 11:46:58 +0000 (11:46 +0000)]
[Driver] Loosen test for LLVM findNearest

Summary:
When https://reviews.llvm.org/D46776 landed to improve the behavior of
`llvm::OptTable::findNearest`, a PS4 buildbot began failing due to an
assertion that a suggestion "-debug-info-macro" should be provided for
the unrecognized option `clang -cc1as -debug-info-macros`. All other
buildbots succeeded in this check, and the PS4 buildbot succeeded in the
other `findNearest` tests.

Temporarily loosen this check in order to reland the `findNearest`
change.

Test Plan: check-clang

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332804 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCodeGen: block capture shouldn't ICE
JF Bastien [Sat, 19 May 2018 04:21:26 +0000 (04:21 +0000)]
CodeGen: block capture shouldn't ICE

When a lambda capture captures a __block in the same statement, the compiler asserts out because isCapturedBy assumes that an Expr can only be a BlockExpr, StmtExpr, or if it's a Stmt then all the statement's children are expressions. That's wrong, we need to visit all sub-statements even if they're not expressions to see if they also capture.

Fix this issue by pulling out the isCapturedBy logic to use RecursiveASTVisitor.

<rdar://problem/39926584>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332801 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdjust and fix failing CXX tests after r332799
Eric Fiselier [Sat, 19 May 2018 03:33:56 +0000 (03:33 +0000)]
Adjust and fix failing CXX tests after r332799

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332800 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Clang Tablegen][RFC] Allow Early Textual Substitutions in `Diagnostic` messages.
Eric Fiselier [Sat, 19 May 2018 03:12:04 +0000 (03:12 +0000)]
[Clang Tablegen][RFC] Allow Early Textual Substitutions in `Diagnostic` messages.

Summary:
There are cases where the same string or select is repeated verbatim in a lot of diagnostics. This can be a pain to maintain and update. Tablegen provides no way stash the common text somewhere and reuse it in the diagnostics, until now!

This patch allows diagnostic texts to contain `%sub{<definition-name>}`, where `<definition-name>` names a Tablegen record of type `TextSubstitution`. These substitutions are done early, before the diagnostic string is otherwise processed. All `%sub` modifiers will be replaced before the diagnostic definitions are emitted.

The substitution must specify all arguments used by the substitution, and modifier indexes in the substitution are re-numbered accordingly. For example:

```
def select_ovl_candidate : TextSubstitution<"%select{function|constructor}0%select{| template| %2}1">;
```
when used as
```
"candidate `%sub{select_ovl_candidate}3,2,1 not viable"
```
will act as if we wrote:
```
"candidate %select{function|constructor}3%select{| template| %1}2 not viable"
```

Reviewers: rsmith, rjmccall, aaron.ballman, a.sidorin

Reviewed By: rjmccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D46740

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332799 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDo not enable RTTI with -fexceptions, for PS4
Sunil Srivastava [Fri, 18 May 2018 23:32:01 +0000 (23:32 +0000)]
Do not enable RTTI with -fexceptions, for PS4

NFC for targets other than PS4.

This patch is a change in behavior for PS4, in that PS4 will no longer enable
RTTI when -fexceptions is specified (RTTI and Exceptions are disabled by default
on PS4). RTTI will remain disabled except for types being thrown or caught.
Also, '-fexceptions -fno-rtti' (previously prohibited on PS4) is now accepted,
as it is for other targets.

This patch removes some PS4 specific code, making the code cleaner.

Also, in the test file rtti-options.cpp, PS4 tests where the behavior is the
same as the generic x86_64-linux are removed, making the test cleaner.

Differential Revision: https://reviews.llvm.org/D46982

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332784 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[test] Fix run line to use correct triple
Shoaib Meenai [Fri, 18 May 2018 21:59:29 +0000 (21:59 +0000)]
[test] Fix run line to use correct triple

objc_begin_catch/objc_end_catch are specific to the Itanium ABI, so we
should be using an Itanium triple for this test.

Additionally, while I'm here, convert the run line to invoke the
compiler directly rather than going through the driver.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332777 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMaintain PS4 ABI compatibility by making the fix made in r331136 not apply when the...
Douglas Yung [Fri, 18 May 2018 21:51:46 +0000 (21:51 +0000)]
Maintain PS4 ABI compatibility by making the fix made in r331136 not apply when the target is the PS4.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47084

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332773 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r332470 (and corresponding tests in r332492).
Richard Smith [Fri, 18 May 2018 20:18:17 +0000 (20:18 +0000)]
Revert r332470 (and corresponding tests in r332492).

This regressed our support for __attribute__((section)). See added test file
for example of code broken by this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332760 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSupport: Simplify endian stream interface. NFCI.
Peter Collingbourne [Fri, 18 May 2018 19:46:24 +0000 (19:46 +0000)]
Support: Simplify endian stream interface. NFCI.

Provide some free functions to reduce verbosity of endian-writing
a single value, and replace the endianness template parameter with
a field.

Part of PR37466.

Differential Revision: https://reviews.llvm.org/D47032

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332757 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Move #include manipulation code to new lib/Tooling/Inclusions."
Eric Liu [Fri, 18 May 2018 18:33:08 +0000 (18:33 +0000)]
Revert "Move #include manipulation code to new lib/Tooling/Inclusions."

This reverts commit r332720. This break build bot with modules. Need to
investigate. Revert the change to unbreak bots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332751 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Support] Avoid normalization in sys::getDefaultTargetTriple
Petr Hosek [Fri, 18 May 2018 18:33:07 +0000 (18:33 +0000)]
[Support] Avoid normalization in sys::getDefaultTargetTriple

The return value of sys::getDefaultTargetTriple, which is derived from
-DLLVM_DEFAULT_TRIPLE, is used to construct tool names, default target,
and in the future also to control the search path directly; as such it
should be used textually, without interpretation by LLVM.

Normalization of this value may lead to unexpected results, for example
if we configure LLVM with -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnu,
normalization will transform that value to x86_64--linux-gnu. Driver will
use that value to search for tools prefixed with x86_64--linux-gnu- which
may be confusing. This is also inconsistent with the behavior of the
--target flag which is taken as-is without any normalization and overrides
the value of LLVM_DEFAULT_TARGET_TRIPLE.

Users of sys::getDefaultTargetTriple already perform their own
normalization as needed, so this change shouldn't impact existing logic.

Differential Revision: https://reviews.llvm.org/D46910

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332750 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMC: Change the streamer ctors to take an object writer instead of a stream. NFCI.
Peter Collingbourne [Fri, 18 May 2018 18:26:45 +0000 (18:26 +0000)]
MC: Change the streamer ctors to take an object writer instead of a stream. NFCI.

The idea is that a client that wants split dwarf would create a
specific kind of object writer that creates two files, and use it to
create the streamer.

Part of PR37466.

Differential Revision: https://reviews.llvm.org/D47050

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332749 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Fix a bad cast from mask16 to mask8 in _mm256_mask_cvtepi16_epi8 introduced...
Craig Topper [Fri, 18 May 2018 17:18:46 +0000 (17:18 +0000)]
[X86] Fix a bad cast from mask16 to mask8 in _mm256_mask_cvtepi16_epi8 introduced in r332266.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332738 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix unused variable warning in r332724
Eric Liu [Fri, 18 May 2018 16:29:42 +0000 (16:29 +0000)]
Fix unused variable warning in r332724

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332734 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS
Eric Liu [Fri, 18 May 2018 16:06:19 +0000 (16:06 +0000)]
[Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS

Summary: ... to support purely VFS-based tools.

Reviewers: bkramer

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47074

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332731 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporter] Enable disabled but passing test
Gabor Marton [Fri, 18 May 2018 15:46:18 +0000 (15:46 +0000)]
[ASTImporter] Enable disabled but passing test

Summary:
There is a test which passes since D32947, but it was forgotten to be enabled.
This patch enables that disabled test.

Reviewers: a.sidorin, r.stahl, xazax.hun

Subscribers: rnkovacs, dkrupp, cfe-commits

Differential Revision: https://reviews.llvm.org/D47069

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332728 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format/ObjC] Correctly annotate single-component ObjC method invocations
Ben Hamilton [Fri, 18 May 2018 15:27:02 +0000 (15:27 +0000)]
[clang-format/ObjC] Correctly annotate single-component ObjC method invocations

Summary:
Previously, clang-format's parser would fail to annotate the
selector in a single-component Objective-C method invocation with
`TT_SelectorName`. For example, the following:

  [foo bar];

would parse `bar` as `TT_Unknown`:

  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=identifier L=34 PPK=2
  FakeLParens= FakeRParens=0 II=0x559d5db51770 Text='bar'

This caused us to fail to insert a space after a closing cast rparen,
so the following:

  [((Foo *)foo) bar];

would format as:

  [((Foo *)foo)bar];

This diff fixes the issue by ensuring we annotate the selector
in a single-component Objective-C method invocation as
`TT_SelectorName`.

Test Plan: New tests added. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: jolesiak

Subscribers: Wizard, klimek, hokein, cfe-commits

Differential Revision: https://reviews.llvm.org/D47028

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332727 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[HIP] Support offloading by linker script
Yaxun Liu [Fri, 18 May 2018 15:07:56 +0000 (15:07 +0000)]
[HIP] Support offloading by linker script

To support linking device code in different source files, it is necessary to
embed fat binary at host linking stage.

This patch emits an external symbol for fat binary in host codegen, then
embed the fat binary by lld through a linker script.

Differential Revision: https://reviews.llvm.org/D46472

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332724 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMove #include manipulation code to new lib/Tooling/Inclusions.
Eric Liu [Fri, 18 May 2018 14:16:37 +0000 (14:16 +0000)]
Move #include manipulation code to new lib/Tooling/Inclusions.

Summary:
clangToolingCore is linked into almost everything (incl. clang), but
not few tools need #include manipulation at this point. So pull this into a
separate library in Tooling.

Reviewers: ilya-biryukov

Subscribers: klimek, mgorny, cfe-commits, thakis

Differential Revision: https://reviews.llvm.org/D47068

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332720 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[VFS] Implement getRealPath for OverlayFileSystem.
Eric Liu [Fri, 18 May 2018 13:22:49 +0000 (13:22 +0000)]
[VFS] Implement getRealPath for OverlayFileSystem.

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47060

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332717 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoThis patch aims to match the changes introduced
Alexander Ivchenko [Fri, 18 May 2018 11:56:21 +0000 (11:56 +0000)]
This patch aims to match the changes introduced
in gcc by https://gcc.gnu.org/ml/gcc-cvs/2018-04/msg00534.html.
The -mibt feature flag is being removed, and the -fcf-protection
option now also defines a CET macro and causes errors when used
on non-X86 targets, while X86 targets no longer check for -mibt
and -mshstk to determine if -fcf-protection is supported. -mshstk
is now used only to determine availability of shadow stack intrinsics.

Comes with an LLVM patch (D46882).

Patch by mike.dvoretsky

Differential Revision: https://reviews.llvm.org/D46881

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332704 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDo not try to remove invisible Decls from DeclContext
Gabor Marton [Fri, 18 May 2018 09:08:47 +0000 (09:08 +0000)]
Do not try to remove invisible Decls from DeclContext

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332699 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSupport: Add a raw_ostream::write_zeros() function. NFCI.
Peter Collingbourne [Thu, 17 May 2018 22:11:43 +0000 (22:11 +0000)]
Support: Add a raw_ostream::write_zeros() function. NFCI.

This will eventually replace MCObjectWriter::WriteZeros.

Part of PR37466.

Differential Revision: https://reviews.llvm.org/D47033

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332675 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd missing test case for r332639
Reid Kleckner [Thu, 17 May 2018 18:34:05 +0000 (18:34 +0000)]
Add missing test case for r332639

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332646 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix a mangling failure on clang-cl C++17
Reid Kleckner [Thu, 17 May 2018 18:12:18 +0000 (18:12 +0000)]
Fix a mangling failure on clang-cl C++17

MethodVFTableLocations in MigrosoftVTableContext contains canonicalized
decl. But, it's sometimes asked to lookup for non-canonicalized decl,
and that causes assertion failure, and compilation failure.

Fixes PR37481.

Patch by Taiju Tsuiki!

Differential Revision: https://reviews.llvm.org/D46929

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332639 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[sanitizer] Don't add --export-dynamic for Myriad
Walter Lee [Thu, 17 May 2018 18:04:39 +0000 (18:04 +0000)]
[sanitizer] Don't add --export-dynamic for Myriad

This is to work around a bug in some versions of gnu ld, where
--export-dynamic implies -shared even if -static is explicitly given.
Myriad supports static linking only, so --export-dynamic is never
needed.

Differential Revision: https://reviews.llvm.org/D46452

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332635 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Allow "extern __shared__ Foo foo[]" within anon. namespaces.
Justin Lebar [Thu, 17 May 2018 16:15:07 +0000 (16:15 +0000)]
[CUDA] Allow "extern __shared__ Foo foo[]" within anon. namespaces.

Summary:
Previously this triggered a -Wundefined-internal warning.  But it's not
an undefined variable -- any variable of this form is a pointer to the
base of GPU core's shared memory.

Reviewers: tra

Subscribers: sanjoy, rsmith

Differential Revision: https://reviews.llvm.org/D46782

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332621 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.
Justin Lebar [Thu, 17 May 2018 16:12:42 +0000 (16:12 +0000)]
[CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

Reviewers: rsmith

Subscribers: sanjoy, cfe-commits, tra

Differential Revision: https://reviews.llvm.org/D46993

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332619 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix __uuidof handling on non-type template parameter in C++17
Nico Weber [Thu, 17 May 2018 15:26:37 +0000 (15:26 +0000)]
Fix __uuidof handling on non-type template parameter in C++17

Clang used to pass the base lvalue of a non-type template parameter
to the template instantiation phase when the base part is __uuidof
and it's running in C++17 mode.
However, that drops its LValuePath, and unintentionally transforms
&__uuidof(...) to __uuidof(...).

This CL fixes that by passing whole expr. Fixes PR24986.

https://reviews.llvm.org/D46820?id=146557
Patch from Taiju Tsuiki <tzik@chromium.org>!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332614 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AArch64] Correct inline assembly test case for S modifier [NFC]
Peter Smith [Thu, 17 May 2018 13:17:33 +0000 (13:17 +0000)]
[AArch64] Correct inline assembly test case for S modifier [NFC]

The existing test for the AArch64 inline assembly constraint S uses the
A and L modifiers. These modifiers were implemented in the original
AArch64 backend but were not carried forward to the merged backend. The
A is associated with ADRP and does nothing, the L is associated with
:lo12: . Given that A and L are not supported by GCC and not supported
by the new implementation of constraint S in LLVM (see D46745) I've
altered the test to put :lo12: directly in the string so that A and L
are not needed.

Differential Revision: https://reviews.llvm.org/D46932

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332606 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse dotted format of version tuple for availability diagnostics
Jan Korous [Thu, 17 May 2018 11:51:49 +0000 (11:51 +0000)]
Use dotted format of version tuple for availability diagnostics

E. g. use "10.11" instead of "10_11".

We are maintaining backward compatibility by parsing underscore-delimited version tuples but no longer keep track of the separator and using dot format for output.

Differential Revision: https://reviews.llvm.org/D46747

rdar://problem/39845032

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332598 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCodeGen: Fix invalid bitcast for lifetime.start/end
Yaxun Liu [Thu, 17 May 2018 11:16:35 +0000 (11:16 +0000)]
CodeGen: Fix invalid bitcast for lifetime.start/end

lifetime.start/end expects pointer argument in alloca address space.
However in C++ a temporary variable is in default address space.

This patch changes API CreateMemTemp and CreateTempAlloca to
get the original alloca instruction and pass it lifetime.start/end.

It only affects targets with non-zero alloca address space.

Differential Revision: https://reviews.llvm.org/D45900

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332593 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd vfs::FileSystem::getRealPath
Eric Liu [Thu, 17 May 2018 10:26:23 +0000 (10:26 +0000)]
Add vfs::FileSystem::getRealPath

Summary: And change `FileManager::getCanonicalName` to use getRealPath.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D46942

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332590 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporter] Fix missing implict CXXRecordDecl
Gabor Marton [Thu, 17 May 2018 09:46:07 +0000 (09:46 +0000)]
[ASTImporter] Fix missing implict CXXRecordDecl

Summary:
Implicit CXXRecordDecl is not added to its DeclContext during import, but in
the original AST it is. This patch fixes this.

Reviewers: xazax.hun, a.sidorin, szepet

Subscribers: rnkovacs, dkrupp, cfe-commits

Differential Revision: https://reviews.llvm.org/D46958

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332588 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Allow skipping function bodies in preamble only
Ivan Donchevskii [Thu, 17 May 2018 09:24:37 +0000 (09:24 +0000)]
[libclang] Allow skipping function bodies in preamble only

Second attempt. Fix line endings and warning.

As an addition to CXTranslationUnit_SkipFunctionBodies, provide the
new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble,
which constraints the skipping of functions bodies to the preamble
only. Function bodies in the main file are not affected if this
option is set.

Skipping function bodies only in the preamble is what clangd already
does and the introduced flag implements it for libclang clients.

Patch by Nikolai Kosjar.

Differential Revision: https://reviews.llvm.org/D45815

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332587 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Frontend] Avoid running plugins during code completion parse
Ivan Donchevskii [Thu, 17 May 2018 09:21:07 +0000 (09:21 +0000)]
[Frontend] Avoid running plugins during code completion parse

Second attempt. Proper line endings.

The parsing that is done for code completion is a special case that will
discard any generated diagnostics, so avoid running plugins for this
case in the first place to avoid performance penalties due to the
plugins.

A scenario for this is for example libclang with extra plugins like tidy.

Patch by Nikolai Kosjar

Differential Revision: https://reviews.llvm.org/D46050

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332586 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815
Ivan Donchevskii [Thu, 17 May 2018 09:15:22 +0000 (09:15 +0000)]
Revert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815

Windows line endings.
Requires proper resubmission.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332585 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Fix putting ObjC message arguments in one line for multiline receiver
Jacek Olesiak [Thu, 17 May 2018 08:35:15 +0000 (08:35 +0000)]
[clang-format] Fix putting ObjC message arguments in one line for multiline receiver

Summary:
Currently BreakBeforeParameter is set to true everytime message receiver spans multiple lines, e.g.:
```
[[object block:^{
  return 42;
}] aa:42 bb:42];
```
will be formatted:
```
[[object block:^{
  return 42;
}] aa:42
   bb:42];
```
even though arguments could fit into one line. This change fixes this behavior.

Test Plan:
make -j12 FormatTests && tools/clang/unittests/Format/FormatTests

Reviewers: benhamilton, djasper

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D46879

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332582 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Allow skipping function bodies in preamble only
Ivan Donchevskii [Thu, 17 May 2018 07:31:29 +0000 (07:31 +0000)]
[libclang] Allow skipping function bodies in preamble only

As an addition to CXTranslationUnit_SkipFunctionBodies, provide the
new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble,
which constraints the skipping of functions bodies to the preamble
only. Function bodies in the main file are not affected if this
option is set.

Skipping function bodies only in the preamble is what clangd already
does and the introduced flag implements it for libclang clients.

Patch by Nikolai Kosjar.

Differential Revision: https://reviews.llvm.org/D45815

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332578 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix rL332458: [AST] Added a helper to extract a user-friendly text of a comment.
Clement Courbet [Thu, 17 May 2018 06:46:15 +0000 (06:46 +0000)]
Fix rL332458: [AST] Added a helper to extract a user-friendly text of a comment.

Older gcc versions do not support raw string literals within macros.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332576 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Extend ObjCAutoreleaseWriteChecker to catch block declarations with autore...
George Karpenkov [Wed, 16 May 2018 22:47:05 +0000 (22:47 +0000)]
[analyzer] Extend ObjCAutoreleaseWriteChecker to catch block declarations with autoreleasing variables

Differential Revision: https://reviews.llvm.org/D46984

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332546 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTMatchers] Introduce a blockDecl matcher for matching block declarations
George Karpenkov [Wed, 16 May 2018 22:47:03 +0000 (22:47 +0000)]
[ASTMatchers] Introduce a blockDecl matcher for matching block declarations

Blocks can be matched just as well as functions or Objective-C methods.

Differential Revision: https://reviews.llvm.org/D46980

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332545 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Change the warning message for GCD antipattern checker
George Karpenkov [Wed, 16 May 2018 22:46:47 +0000 (22:46 +0000)]
[analyzer] Change the warning message for GCD antipattern checker

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332544 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Fix assertion when constructor is disabled with partially specialized template.
Volodymyr Sapsai [Wed, 16 May 2018 18:28:58 +0000 (18:28 +0000)]
[Sema] Fix assertion when constructor is disabled with partially specialized template.

The added test case was triggering assertion

> Assertion failed: (!SpecializedTemplate.is<SpecializedPartialSpecialization*>() && "Already set to a class template partial specialization!"), function setInstantiationOf, file clang/include/clang/AST/DeclTemplate.h, line 1825.

It was happening with ClassTemplateSpecializationDecl
`enable_if_not_same<int, int>`. Because this template is specialized for
equal types not to have a definition, it wasn't instantiated and its
specialization kind remained TSK_Undeclared. And because it was implicit
instantiation, we didn't mark the decl as invalid. So when we try to
find the best matching partial specialization the second time, we hit
the assertion as partial specialization is already set.

Fix by reusing stored partial specialization when available, instead of
looking for the best match every time.

rdar://problem/39524996

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D46909

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332509 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd lit tests forgotten for R332470
Erich Keane [Wed, 16 May 2018 17:04:47 +0000 (17:04 +0000)]
Add lit tests forgotten for R332470

I forgot to svn-add the lit tests for R332470.
Added here!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332492 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Modules] Do not diagnose missing import in recovery mode if there isn't a decl to...
Bruno Cardoso Lopes [Wed, 16 May 2018 17:00:24 +0000 (17:00 +0000)]
[Modules] Do not diagnose missing import in recovery mode if there isn't a decl to lookup

Clang often tries to create implicit module import for error recovery,
which does a great job helping out with diagnostics. However, sometimes
clang does not have enough information given that it's using an invalid
context to move on. Be more strict in those cases to avoid crashes.

We hit crash on invalids because of this but unfortunately there are no
testcases and I couldn't manage to create one. The crashtrace however
indicates pretty clear why it's happening.

rdar://problem/39313933

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332491 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Attr] Don't print fake MSInheritance argument
Joel E. Denny [Wed, 16 May 2018 15:18:30 +0000 (15:18 +0000)]
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

Differential Revision: https://reviews.llvm.org/D46905

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332481 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r332474: [Attr] Don't print fake MSInheritance argument
Joel E. Denny [Wed, 16 May 2018 15:18:27 +0000 (15:18 +0000)]
Revert r332474: [Attr] Don't print fake MSInheritance argument

I botched the commit log attributes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332480 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] DO not crash on combined constructs in declare target
Alexey Bataev [Wed, 16 May 2018 15:08:32 +0000 (15:08 +0000)]
[OPENMP] DO not crash on combined constructs in declare target
functions.

If the combined construct is specified in the declare target function
and the device code is emitted, the compiler crashes because of the
incorrectly chosen captured stmt. We should choose the innermost
captured statement, not the outermost.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332477 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Attr] Don't print fake MSInheritance argument
Joel E. Denny [Wed, 16 May 2018 14:51:18 +0000 (14:51 +0000)]
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

https://reviews.llvm.org/D46905

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332474 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OpenCL] make test independent of optimizer
Sanjay Patel [Wed, 16 May 2018 14:38:07 +0000 (14:38 +0000)]
[OpenCL] make test independent of optimizer

There shouldn't be any tests that run the entire optimizer here,
but the last test in this file is definitely going to break with
a change in LLVM IR canonicalization. Change that part to check
the unoptimized IR because that's the real intent of this file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332473 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd support for __declspec(code_seg("segname"))
Erich Keane [Wed, 16 May 2018 13:57:17 +0000 (13:57 +0000)]
Add support for __declspec(code_seg("segname"))

Add support for __declspec(code_seg("segname"))

This patch is built on the existing support for #pragma code_seg. The code_seg
declspec is allowed on functions and classes. The attribute enables the
placement of code into separate named segments, including compiler-generated
members and template instantiations.

For more information, please see the following:
https://msdn.microsoft.com/en-us/library/dn636922.aspx

A new CodeSeg attribute is used instead of adding a new spelling to the existing
Section attribute since they don’t apply to the same Subjects. Section
attributes are also added for the code_seg declspec since they are used for
#pragma code_seg. No CodeSeg attributes are added to the AST.

The patch is written to match with the Microsoft compiler’s behavior even where
that behavior is a little complicated (see https://reviews.llvm.org/D22931, the
Microsoft feedback page is no longer available since MS has removed the page).
That code is in getImplicitSectionAttrFromClass routine.

Diagnostics messages are added to match with the Microsoft compiler for code-seg
attribute mismatches on base and derived classes and virtual overrides.

Differential Revision: https://reviews.llvm.org/D43352

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332470 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Frontend] Avoid running plugins during code completion parse
Ivan Donchevskii [Wed, 16 May 2018 13:50:05 +0000 (13:50 +0000)]
[Frontend] Avoid running plugins during code completion parse

The parsing that is done for code completion is a special case that will
discard any generated diagnostics, so avoid running plugins for this
case in the first place to avoid performance penalties due to the
plugins.

A scenario for this is for example libclang with extra plugins like tidy.

Patch by Nikolai Kosjar

Differential Revision: https://reviews.llvm.org/D46050

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332469 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP, NVPTX] Add check for SPMD mode in orphaned parallel directives.
Alexey Bataev [Wed, 16 May 2018 13:36:30 +0000 (13:36 +0000)]
[OPENMP, NVPTX] Add check for SPMD mode in orphaned parallel directives.

If the orphaned directive is executed in SPMD mode, we need to emit the
check for the SPMD mode and run the orphaned parallel directive in
sequential mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332467 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix an Index test caused by a clang-format change (r332436).
Eric Liu [Wed, 16 May 2018 12:58:13 +0000 (12:58 +0000)]
Fix an Index test caused by a clang-format change (r332436).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332465 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Improve the modeling of memset().
Henry Wong [Wed, 16 May 2018 12:37:53 +0000 (12:37 +0000)]
[analyzer] Improve the modeling of memset().

Since there is no perfect way bind the non-zero value with the default binding, this patch only considers the case where buffer's offset is zero and the char value is 0. And according to the value for overwriting, decide how to update the string length.

Reviewers: dcoughlin, NoQ, xazax.hun, a.sidorin, george.karpenkov

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D44934

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332463 91177308-0d34-0410-b5e6-96231b3b80d8