]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] Fix assertion crash in CStringChecker
George Karpenkov [Sat, 31 Mar 2018 01:20:08 +0000 (01:20 +0000)]
[analyzer] Fix assertion crash in CStringChecker

An offset might be unknown.

rdar://39054939

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

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

6 years ago[analyzer] Cache offset computation for MemRegion
George Karpenkov [Sat, 31 Mar 2018 01:20:07 +0000 (01:20 +0000)]
[analyzer] Cache offset computation for MemRegion

Achieves almost a 200% speedup on the example where the performance of
visitors was problematic.

Performance on sqlite3 is unaffected.

rdar://38818362

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

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

6 years ago[analyzer] Fix liveness calculation for C++17 structured bindings
George Karpenkov [Sat, 31 Mar 2018 01:20:06 +0000 (01:20 +0000)]
[analyzer] Fix liveness calculation for C++17 structured bindings

C++ structured bindings for non-tuple-types are defined in a peculiar
way, where the resulting declaration is not a VarDecl, but a
BindingDecl.
That means a lot of existing machinery stops working.

rdar://36912381

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

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

6 years ago[ASTImporter] Add test helper Fixture
Peter Szecsi [Fri, 30 Mar 2018 22:03:29 +0000 (22:03 +0000)]
[ASTImporter] Add test helper Fixture

Add a helper test Fixture, so we can add tests which can check internal
attributes of AST nodes like getPreviousDecl(), isVirtual(), etc.
This enables us to check if a redeclaration chain is correctly built during
import, if the virtual flag is preserved during import, etc. We cannot check
such attributes with the existing testImport.
Also, this fixture makes it possible to import from several "From" contexts.

We also added several test cases here, some of them are disabled.
We plan to pass the disabled tests in other patches.

Patch by Gabor Marton!

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

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

6 years ago[analyzer] Fix test triple in missing-bind-temporary.cpp.
Artem Dergachev [Fri, 30 Mar 2018 21:22:35 +0000 (21:22 +0000)]
[analyzer] Fix test triple in missing-bind-temporary.cpp.

Otherwise the default triple for x86-windows-msvc2015 auto-inserts
__attribute__((thiscall)) to some calls.

Fixes the respective buildbot.

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

6 years ago[analyzer] Track null or undef values through pointer arithmetic.
Artem Dergachev [Fri, 30 Mar 2018 19:27:42 +0000 (19:27 +0000)]
[analyzer] Track null or undef values through pointer arithmetic.

Pointer arithmetic on null or undefined pointers results in null or undefined
pointers. This is obvious for undefined pointers; for null pointers it follows
from our incorrect-but-somehow-working approach that declares that 0 (Loc)
doesn't necessarily represent a pointer of numeric address value 0, but instead
it represents any pointer that will cause a valid "null pointer dereference"
issue when dereferenced.

For now we've been seeing through pointer arithmetic at the original dereference
expression, i.e. in bugreporter::getDerefExpr(), but not during further
investigation of the value's origins in bugreporter::trackNullOrUndefValue().
The patch fixes it.

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

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

6 years ago[CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.
Artem Dergachev [Fri, 30 Mar 2018 19:25:39 +0000 (19:25 +0000)]
[CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.

Sometimes template instantiation causes CXXBindTemporaryExpr to be missing in
its usual spot. In CFG, temporary destructors work by relying on
CXXBindTemporaryExprs, so they won't work in this case.

Avoid the crash and notify the clients that we've encountered an unsupported AST
by failing to provide the ill-formed construction context for the temporary.

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

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

6 years ago[CFG] [analyzer] Avoid modeling C++17 constructors that aren't fully supported.
Artem Dergachev [Fri, 30 Mar 2018 19:21:18 +0000 (19:21 +0000)]
[CFG] [analyzer] Avoid modeling C++17 constructors that aren't fully supported.

Not enough work has been done so far to ensure correctness of construction
contexts in the CFG when C++17 copy elision is in effect, so for now we
should drop construction contexts in the CFG and in the analyzer when
they seem different from what we support anyway.

This includes initializations with conditional operators and return values
across multiple stack frames.

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

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

6 years agoRemove unused CHECK lines leftover from r306928.
Eli Friedman [Fri, 30 Mar 2018 18:39:28 +0000 (18:39 +0000)]
Remove unused CHECK lines leftover from r306928.

The RUN lines were removed, but the corresponding CHECK lines never
went away.

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

6 years ago[OPENMP] Added emission of offloading data sections for declare target
Alexey Bataev [Fri, 30 Mar 2018 18:31:07 +0000 (18:31 +0000)]
[OPENMP] Added emission of offloading data sections for declare target
variables.

Added emission of the offloading data sections for the variables within
declare target regions + fixes emission of the declare target variables
marked as declare target not within the declare target region.

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

6 years ago[clang-format] Ensure wrapped ObjC selectors with 1 arg obey IndentWrappedFunctionNames
Ben Hamilton [Fri, 30 Mar 2018 15:38:45 +0000 (15:38 +0000)]
[clang-format] Ensure wrapped ObjC selectors with 1 arg obey IndentWrappedFunctionNames

Summary:
In D43121, @Typz introduced logic to avoid indenting 2-or-more
argument ObjC selectors too far to the right if the first component
of the selector was longer than the others.

This had a small side effect of causing wrapped ObjC selectors with
exactly 1 argument to not obey IndentWrappedFunctionNames:

```
- (aaaaaaaaaa)
aaaaaaaaaa;
```

This diff fixes the issue by ensuring we align wrapped 1-argument
ObjC selectors correctly:

```
- (aaaaaaaaaa)
    aaaaaaaaaa;
```

Test Plan: New tests added. Test failed before change, passed
  after change. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, klimek, Typz, jolesiak

Reviewed By: djasper, jolesiak

Subscribers: cfe-commits, Typz

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

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

6 years ago[analyzer] Remove the unused method declaration in `ValistChecker.cpp`.
Henry Wong [Fri, 30 Mar 2018 13:37:50 +0000 (13:37 +0000)]
[analyzer] Remove the unused method declaration in `ValistChecker.cpp`.

Summary: `getVariableNameFromRegion()` seems useless.

Reviewers: xazax.hun, george.karpenkov

Reviewed By: xazax.hun

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits, MTC

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

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

6 years ago[Modules] Improve fixit for framework private module maps
Bruno Cardoso Lopes [Fri, 30 Mar 2018 05:17:58 +0000 (05:17 +0000)]
[Modules] Improve fixit for framework private module maps

The wrong source range was being provided in some case, fix that to get
a better fixit.

rdar://problem/38520199

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

6 years agoAdding UNSUPPORTED: system-windows at George's request until the problem can be debugged.
Douglas Yung [Fri, 30 Mar 2018 01:29:07 +0000 (01:29 +0000)]
Adding UNSUPPORTED: system-windows at George's request until the problem can be debugged.

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

6 years agoHoist MethodVFTableLocation out of MicrosoftVTableContext, NFC
Reid Kleckner [Thu, 29 Mar 2018 22:42:24 +0000 (22:42 +0000)]
Hoist MethodVFTableLocation out of MicrosoftVTableContext, NFC

This allows forward declaring it so that we can add it to
MicrosoftMangleContext::mangleVirtualMemPtrThunk without including
VTableBuilder.h. That saves a hashtable lookup when emitting virtual
member pointer functions.

It also shortens a really long type name. This struct has "VFtable" in
the name, so it seems pretty unlikely that someone will assume it is
generally useful for non-MS C++ ABI stuff.

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

6 years ago[analyzer] Fix target triple for autorelease-write-checker test
George Karpenkov [Thu, 29 Mar 2018 22:28:04 +0000 (22:28 +0000)]
[analyzer] Fix target triple for autorelease-write-checker test

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

6 years agoSet dso_local on cfi_slowpath.
Rafael Espindola [Thu, 29 Mar 2018 22:08:01 +0000 (22:08 +0000)]
Set dso_local on cfi_slowpath.

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

6 years ago[analyzer] Better pretty-printing of regions in exploded graph
George Karpenkov [Thu, 29 Mar 2018 22:07:58 +0000 (22:07 +0000)]
[analyzer] Better pretty-printing of regions in exploded graph

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

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

6 years ago[AArch64]: Add support for parsing rN registers.
Manoj Gupta [Thu, 29 Mar 2018 21:11:15 +0000 (21:11 +0000)]
[AArch64]: Add support for parsing rN registers.

Summary:
Allow rN registers to be simply parsed as correspoing xN registers.
The "register ... asm("rN")" is an command to the
compiler's register allocator, not an operand to any individual assembly
instruction. GCC documents this syntax as "...the name of the register
that should be used."

This is needed to support the changes in Linux kernel (see
https://lkml.org/lkml/2018/3/1/268 )

Note: This will add support only for the limited use case of
register ... asm("rN"). Any other uses that make rN leak into assembly
are not supported.

Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover

Reviewed By: peter.smith

Subscribers: javed.absar, eraman, cfe-commits, srhines

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

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

6 years ago[analyzer] Path-insensitive checker for writes into an auto-releasing pointer
George Karpenkov [Thu, 29 Mar 2018 20:55:34 +0000 (20:55 +0000)]
[analyzer] Path-insensitive checker for writes into an auto-releasing pointer

from the wrong auto-releasing pool, as such writes may crash.

rdar://25301111

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

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

6 years ago[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
Eugene Zelenko [Thu, 29 Mar 2018 20:51:59 +0000 (20:51 +0000)]
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

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

6 years agoMark __cfi_check as dso_local.
Rafael Espindola [Thu, 29 Mar 2018 20:51:30 +0000 (20:51 +0000)]
Mark __cfi_check as dso_local.

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

6 years agoGeneralize NRVO to cover C structs.
Akira Hatanaka [Thu, 29 Mar 2018 17:56:24 +0000 (17:56 +0000)]
Generalize NRVO to cover C structs.

This commit generalizes NRVO to cover C structs (both trivial and
non-trivial structs).

rdar://problem/33599681

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

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

6 years ago[Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.
Volodymyr Sapsai [Thu, 29 Mar 2018 17:34:09 +0000 (17:34 +0000)]
[Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.

Deprecation replacement can be any text but if it looks like a name of
ObjC method and has the same number of arguments as original method,
replace all slot names so after applying a fix-it you have valid code.

rdar://problem/36660853

Reviewers: aaron.ballman, erik.pilkington, rsmith

Reviewed By: erik.pilkington

Subscribers: cfe-commits, jkorous-apple

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

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

6 years agoSet dso_local when clearing dllimport.
Rafael Espindola [Thu, 29 Mar 2018 16:45:18 +0000 (16:45 +0000)]
Set dso_local when clearing dllimport.

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

6 years agoAdd a dllimport test.
Rafael Espindola [Thu, 29 Mar 2018 16:35:52 +0000 (16:35 +0000)]
Add a dllimport test.

Thanks to rnk for the suggestion.

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

6 years ago[test] Fix an XRay test on FreeBSD
Zhihao Yuan [Thu, 29 Mar 2018 15:50:44 +0000 (15:50 +0000)]
[test] Fix an XRay test on FreeBSD

Summary: Fixing clang-test on FreeBSD as a follow-up of https://reviews.llvm.org/D43378 to handle the revert happened in r325749.

Reviewers: devnexen, krytarowski, dberris

Subscribers: emaste, dberris, cfe-commits

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

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

6 years agoSet calling convention for CUDA kernel
Yaxun Liu [Thu, 29 Mar 2018 15:02:08 +0000 (15:02 +0000)]
Set calling convention for CUDA kernel

This patch sets target specific calling convention for CUDA kernels in IR.

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

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

6 years agoDisable emitting static extern C aliases for amdgcn target for CUDA
Yaxun Liu [Thu, 29 Mar 2018 14:50:00 +0000 (14:50 +0000)]
Disable emitting static extern C aliases for amdgcn target for CUDA

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

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

6 years agoFix typo
Matt Arsenault [Thu, 29 Mar 2018 14:31:59 +0000 (14:31 +0000)]
Fix typo

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

6 years ago[Hexagon] Aid bit-reverse load intrinsics lowering with bitcode
Krzysztof Parzyszek [Thu, 29 Mar 2018 13:54:31 +0000 (13:54 +0000)]
[Hexagon] Aid bit-reverse load intrinsics lowering with bitcode

The conversion of operatios to bitcode helps to eliminate an additional
store in certain cases. We used to lower these load intrinsics in DAG to
DAG conversion by which time, the "Dead Store Elimination" pass is
already run. There is an associated LLVM patch.

Patch by Sumanth Gundapaneni.

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

6 years agoRename clang link from clang-X.Y to clang-X
Sylvestre Ledru [Thu, 29 Mar 2018 10:05:46 +0000 (10:05 +0000)]
Rename clang link from clang-X.Y to clang-X

Summary:
As we are only doing X.0.Z releases (not using the minor version), there is no need to keep -X.Y in the version.
So, instead, I propose the following:
Instead of having clang-7.0 in bin/, we will have clang-7

Since also matches was gcc is doing.

Reviewers: tstellar, dlj, dim, hans

Reviewed By: dim, hans

Subscribers: dim, mgorny, cfe-commits

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

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

6 years agoRefactor some code for a warning. NFC.
Richard Trieu [Thu, 29 Mar 2018 05:14:17 +0000 (05:14 +0000)]
Refactor some code for a warning.  NFC.

Use range-based for-loops instead of iterators to walk over vectors.
Switch the key of the DenseMap so a custom key handler is no longer needed.
Remove unncessary adds to the DenseMap.
Use unique_ptr instead of manual memory management.

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

6 years ago[astmatchers] Fix linking issue
George Karpenkov [Thu, 29 Mar 2018 02:47:28 +0000 (02:47 +0000)]
[astmatchers] Fix linking issue

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

6 years ago[analyzer] [testing] Be less verbose by default in integration testing.
George Karpenkov [Thu, 29 Mar 2018 01:23:54 +0000 (01:23 +0000)]
[analyzer] [testing] Be less verbose by default in integration testing.

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

6 years ago[astmatchers] Move a matcher out of internal namespace: blind debugging of MSVC issues
George Karpenkov [Thu, 29 Mar 2018 01:15:05 +0000 (01:15 +0000)]
[astmatchers] Move a matcher out of internal namespace: blind debugging of MSVC issues

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

6 years ago[ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ in templ...
George Karpenkov [Thu, 29 Mar 2018 00:56:24 +0000 (00:56 +0000)]
[ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ in templatized code under ARC

The AST for the fragment

```
@interface I
@end

template <typename>
void decode(I *p) {
  for (I *k in p) {}
}

void decode(I *p) {
  decode<int>(p);
}
```

differs heavily when templatized and non-templatized:

```
|-FunctionTemplateDecl 0x7fbfe0863940 <line:4:1, line:7:1> line:5:6 decode
| |-TemplateTypeParmDecl 0x7fbfe0863690 <line:4:11> col:11 typename depth 0 index 0
| |-FunctionDecl 0x7fbfe08638a0 <line:5:1, line:7:1> line:5:6 decode 'void (I *__strong)'
| | |-ParmVarDecl 0x7fbfe08637a0 <col:13, col:16> col:16 referenced p 'I *__strong'
| | `-CompoundStmt 0x7fbfe0863b88 <col:19, line:7:1>
| |   `-ObjCForCollectionStmt 0x7fbfe0863b50 <line:6:3, col:20>
| |     |-DeclStmt 0x7fbfe0863a50 <col:8, col:13>
| |     | `-VarDecl 0x7fbfe08639f0 <col:8, col:11> col:11 k 'I *const __strong'
| |     |-ImplicitCastExpr 0x7fbfe0863a90 <col:16> 'I *' <LValueToRValue>
| |     | `-DeclRefExpr 0x7fbfe0863a68 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe08637a0 'p' 'I *__strong'
| |     `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20>
| `-FunctionDecl 0x7fbfe0863f80 <line:5:1, line:7:1> line:5:6 used decode 'void (I *__strong)'
|   |-TemplateArgument type 'int'
|   |-ParmVarDecl 0x7fbfe0863ef8 <col:13, col:16> col:16 used p 'I *__strong'
|   `-CompoundStmt 0x7fbfe0890cf0 <col:19, line:7:1>
|     `-ObjCForCollectionStmt 0x7fbfe0890cc8 <line:6:3, col:20>
|       |-DeclStmt 0x7fbfe0890c70 <col:8, col:13>
|       | `-VarDecl 0x7fbfe0890c00 <col:8, col:11> col:11 k 'I *__strong' callinit
|       |   `-ImplicitValueInitExpr 0x7fbfe0890c60 <<invalid sloc>> 'I *__strong'
|       |-ImplicitCastExpr 0x7fbfe0890cb0 <col:16> 'I *' <LValueToRValue>
|       | `-DeclRefExpr 0x7fbfe0890c88 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe0863ef8 'p' 'I *__strong'
|       `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20>
```

Note how in the instantiated version ImplicitValueInitExpr unexpectedly appears.

While objects are auto-initialized under ARC, it does not make sense to
have an initializer for a for-loop variable, and it makes even less
sense to have such a different AST for instantiated and non-instantiated
version.

Digging deeper, I have found that there are two separate Sema* files for
dealing with templates and for dealing with non-templatized code.
In a non-templatized version, an initialization was performed only for
variables which are not loop variables for an Objective-C loop and not
variables for a C++ for-in loop:

```
  if (FRI && (Tok.is(tok::colon) || isTokIdentifier_in())) {
    bool IsForRangeLoop = false;
    if (TryConsumeToken(tok::colon, FRI->ColonLoc)) {
      IsForRangeLoop = true;
      if (Tok.is(tok::l_brace))
        FRI->RangeExpr = ParseBraceInitializer();
      else
        FRI->RangeExpr = ParseExpression();
    }

    Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
    if (IsForRangeLoop)
      Actions.ActOnCXXForRangeDecl(ThisDecl);
    Actions.FinalizeDeclaration(ThisDecl);
    D.complete(ThisDecl);
    return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, ThisDecl);
  }

  SmallVector<Decl *, 8> DeclsInGroup;
  Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(
      D, ParsedTemplateInfo(), FRI);
```

However the code in SemaTemplateInstantiateDecl was inconsistent,
guarding only against C++ for-in loops.

rdar://38391075

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

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

6 years ago[ASTMatchers] Introduce a matcher for matching any given Objective-C selector
George Karpenkov [Thu, 29 Mar 2018 00:51:12 +0000 (00:51 +0000)]
[ASTMatchers] Introduce a matcher for matching any given Objective-C selector

Incudes a tiny related refactoring.

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

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

6 years ago[ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective...
George Karpenkov [Thu, 29 Mar 2018 00:51:11 +0000 (00:51 +0000)]
[ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective-C methods

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

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

6 years ago[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Wed, 28 Mar 2018 22:09:09 +0000 (22:09 +0000)]
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

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

6 years ago[ObjC++] Make parameter passing and function return compatible with ObjC
Akira Hatanaka [Wed, 28 Mar 2018 21:13:14 +0000 (21:13 +0000)]
[ObjC++] Make parameter passing and function return compatible with ObjC

ObjC and ObjC++ pass non-trivial structs in a way that is incompatible
with each other. For example:

typedef struct {
  id f0;
  __weak id f1;
} S;

// this code is compiled in c++.
extern "C" {
  void foo(S s);
}

void caller() {
  // the caller passes the parameter indirectly and destructs it.
  foo(S());
}

// this function is compiled in c.
// 'a' is passed directly and is destructed in the callee.
void foo(S a) {
}

This patch fixes the incompatibility by passing and returning structs
with __strong or weak fields using the C ABI in C++ mode. __strong and
__weak fields in a struct do not cause the struct to be destructed in
the caller and __strong fields do not cause the struct to be passed
indirectly.

Also, this patch fixes the microsoft ABI bug mentioned here:

https://reviews.llvm.org/D41039?id=128767#inline-364710

rdar://problem/38887866

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

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

6 years ago[Hexagon] Add support for "new" circular buffer intrinsics
Krzysztof Parzyszek [Wed, 28 Mar 2018 19:40:57 +0000 (19:40 +0000)]
[Hexagon] Add support for "new" circular buffer intrinsics

These instructions have been around for a long time, but we
haven't supported intrinsics for them. The "new" vesrions use
the CSx register for the start of the buffer instead of the K
field in the Mx register.

There is a related llvm patch.

Patch by Brendon Cahoon.

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

6 years ago[MS] Fix bug in method vfptr location code
Reid Kleckner [Wed, 28 Mar 2018 18:23:35 +0000 (18:23 +0000)]
[MS] Fix bug in method vfptr location code

We were assuming that vbtable indices were assigned in layout order in
our comparison, which is not the case. When a virtual method, such as
the destructor, appears in multiple vftables, the vftable that appears
first in object layout order is the one that points to the main
implementation of that method. The later vftables use thunks.

In this layout, we adjusted "this" in the main implementation by the
amount that is appropriate for 'B' instead of 'A', even though the main
implementation is found in D's vftable for A:

  struct A {
    virtual ~A() {}
  };
  struct B {
    virtual ~B() {}
  };
  struct C : virtual B {};
  struct D : virtual A, C {};

D's layout looks like:
   0 D subobject (empty)
   0 C base suboject
   8 A base subobject
  16 B base subobject

With this fix, we correctly adjust by -8 in D's deleting destructor
instead of -16.

Fixes PR36921.

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

6 years agoFix for LLVM header changes
David Blaikie [Wed, 28 Mar 2018 17:45:10 +0000 (17:45 +0000)]
Fix for LLVM header changes

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

6 years ago[Diag] Avoid emitting a redefinition note if no location is available.
Matt Davis [Wed, 28 Mar 2018 16:05:05 +0000 (16:05 +0000)]
[Diag] Avoid emitting a redefinition note if no location is available.

Summary:
The "previous definition is here" note is not helpful if there is no location information. The note will reference nothing in such a case. This patch first checks to see if there is location data, and if so the note diagnostic is emitted.

This fixes PR15409.  The issue in the first comment seems to already be resolved. This patch addresses the second example.

Reviewers: bruno, rsmith

Reviewed By: bruno

Subscribers: cfe-commits

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

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

6 years agoclang-cl: s/Enable/Disable/ in help text for /GX-
Hans Wennborg [Wed, 28 Mar 2018 14:57:49 +0000 (14:57 +0000)]
clang-cl: s/Enable/Disable/ in help text for /GX-

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

6 years ago[OPENMP] Codegen for ctor|dtor of declare target variables.
Alexey Bataev [Wed, 28 Mar 2018 14:28:54 +0000 (14:28 +0000)]
[OPENMP] Codegen for ctor|dtor of declare target variables.

When the declare target variables are emitted for the device,
constructors|destructors for these variables must emitted and registered
by the runtime in the offloading sections.

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

6 years ago[PATCH] [RISCV] Verify the input value of -march=
Shiva Chen [Wed, 28 Mar 2018 08:29:50 +0000 (08:29 +0000)]
[PATCH] [RISCV] Verify the input value of -march=

Summary:
This patch doing more check and verify the -march= string and will issue
an error if it's a invalid combination.

Reviewers: asb, apazos

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

Patch by Kito Cheng.

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

6 years agoFix some handling of AST nodes with diagnostics.
Richard Trieu [Wed, 28 Mar 2018 04:16:13 +0000 (04:16 +0000)]
Fix some handling of AST nodes with diagnostics.

The diagnostic system for Clang can already handle many AST nodes.  Instead
of converting them to strings first, just hand the AST node directly to
the diagnostic system and let it handle the output.  Minor changes in some
diagnostic output.

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

6 years ago[ObjC] Make C++ triviality type traits available to non-trivial C
Akira Hatanaka [Wed, 28 Mar 2018 00:12:08 +0000 (00:12 +0000)]
[ObjC] Make C++ triviality type traits available to non-trivial C
structs.

r326307 and r327870 made changes that allowed using non-trivial C
structs with fields qualified with __strong or __weak. This commit makes
the following C++ triviality type traits available to non-trivial C
structs:

__has_trivial_assign
__has_trivial_move_assign
__has_trivial_copy
__has_trivial_move_constructor
__has_trivial_constructor
__has_trivial_destructor

rdar://problem/33599681

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

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

6 years ago[Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers
Petr Hosek [Tue, 27 Mar 2018 21:33:12 +0000 (21:33 +0000)]
[Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers

This is needed in addition to fuzzer in order to use libFuzzer.

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

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

6 years ago[Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.
Volodymyr Sapsai [Tue, 27 Mar 2018 21:29:05 +0000 (21:29 +0000)]
[Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.

rdar://problem/35539384

Reviewers: ahatanak, nicholas, rsmith, jkorous-apple

Reviewed By: jkorous-apple

Subscribers: cfe-commits, jkorous-apple

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

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

6 years ago[coroutines] Do not attempt to typo-correct when coroutine is looking for required...
Gor Nishanov [Tue, 27 Mar 2018 20:38:19 +0000 (20:38 +0000)]
[coroutines] Do not attempt to typo-correct when coroutine is looking for required members

When SemaCoroutine looks for await_resume, it means it. No need for helpful: "Did you mean await_ready?" messages.

Fixes PR33477 and a couple of FIXMEs in test/SemaCXX/coroutines.cpp

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

6 years agoAMDGPU: Update datalayout for stack alignment
Matt Arsenault [Tue, 27 Mar 2018 19:26:51 +0000 (19:26 +0000)]
AMDGPU: Update datalayout for stack alignment

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

6 years ago[Sema] Avoid crash for category implementation without interface
Shoaib Meenai [Tue, 27 Mar 2018 18:58:28 +0000 (18:58 +0000)]
[Sema] Avoid crash for category implementation without interface

When we have a category implementation without a corresponding interface
(which is an error by itself), semantic checks for property accesses
will attempt to access a null interface declaration and then segfault.
Error out in such cases instead.

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

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

6 years agoUpdate test after r328635 in LLVM
Krzysztof Parzyszek [Tue, 27 Mar 2018 17:17:39 +0000 (17:17 +0000)]
Update test after r328635 in LLVM

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

6 years ago[clang] Change std::sort to llvm::sort in response to r327219
Mandeep Singh Grang [Tue, 27 Mar 2018 16:50:00 +0000 (16:50 +0000)]
[clang] Change std::sort to llvm::sort in response to r327219

r327219 added wrappers to std::sort which randomly shuffle the container before
sorting.  This will help in uncovering non-determinism caused due to undefined
sorting order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of
std::sort.

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

6 years ago[clang-format] Refine ObjC guesser to handle child lines of child lines
Ben Hamilton [Tue, 27 Mar 2018 15:01:21 +0000 (15:01 +0000)]
[clang-format] Refine ObjC guesser to handle child lines of child lines

Summary:
This fixes an issue brought up by djasper@ in his review of D44790. We
handled top-level child lines, but if those child lines themselves
had child lines, we didn't handle them.

Rather than use recursion (which could blow out the stack), I use a
DenseSet to hold the set of lines we haven't yet checked (since order
doesn't matter), and update the set to add the children of each
line as we check it.

Test Plan: New tests added. Confirmed tests failed before fix
  and passed after fix.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Do not insert space before closing brace in ObjC dict literal
Ben Hamilton [Tue, 27 Mar 2018 15:01:17 +0000 (15:01 +0000)]
[clang-format] Do not insert space before closing brace in ObjC dict literal

Summary:
Previously, `clang-format` would sometimes insert a space
before the closing brace in an Objective-C dictionary literal.

Unlike array literals (which obey `Style.SpacesInContainerLiterals`
to add a space after `[` and before `]`), Objective-C dictionary
literals currently are not meant to insert a space after `{` and before
`}`, regardless of `Style.SpacesInContainerLiterals`.

However, some constructs like `@{foo : @(bar)}` caused `clang-format`
to insert a space between `)` and `}`.

This fixes the issue and adds tests. (I understand the behavior is
not consistent between array literals and dictionary literals, but
that's existing behavior that's a much larger change.)

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

Reviewers: djasper, jolesiak, Wizard

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years agoDrop spurious break; NFC
Sven van Haastregt [Tue, 27 Mar 2018 14:57:56 +0000 (14:57 +0000)]
Drop spurious break; NFC

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

6 years agoMove a ref-counted pointer instead of copying it. NFC.
Alexander Kornienko [Tue, 27 Mar 2018 14:02:06 +0000 (14:02 +0000)]
Move a ref-counted pointer instead of copying it. NFC.

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

6 years agoRevert "[clang-format] Remove empty lines before }[;] // comment"
Krasimir Georgiev [Tue, 27 Mar 2018 13:14:29 +0000 (13:14 +0000)]
Revert "[clang-format] Remove empty lines before }[;] // comment"

This reverts commit r327861.

The empty line before namespaces is desired in some places. We need a
better approach to handle this.

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

6 years ago[analyzer] LoopUnrolling: update the matched assignment operators
Peter Szecsi [Tue, 27 Mar 2018 12:16:56 +0000 (12:16 +0000)]
[analyzer] LoopUnrolling: update the matched assignment operators

Extended the matched assignment operators when checking for bound changes in a body of the loop by using the freshly added isAssignmentOperator matcher.
This covers all the (current) possible assignments, tests added as well.

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

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

6 years ago[ASTMatchers] Add isAssignmentOperator matcher
Peter Szecsi [Tue, 27 Mar 2018 12:11:46 +0000 (12:11 +0000)]
[ASTMatchers] Add isAssignmentOperator matcher

Adding a matcher for BinaryOperator and cxxOperatorCallExpr to be able to
decide whether it is any kind of assignment operator or not. This would be
useful since allows us to easily detect assignments via matchers for static
analysis (Tidy, SA) purposes.

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

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

6 years ago[coroutines] Fix unused warning on result of co_yield.
Eric Fiselier [Tue, 27 Mar 2018 03:33:06 +0000 (03:33 +0000)]
[coroutines] Fix unused warning on result of co_yield.

This patch follows up on r328602, which fixed the spurious unused
result warning for `co_await`.

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

6 years ago[coroutines] Fix invalid source range in co_await call expressions.
Eric Fiselier [Tue, 27 Mar 2018 03:15:46 +0000 (03:15 +0000)]
[coroutines] Fix invalid source range in co_await call expressions.

Summary:
Currently an invalid source range is generated for the member call expressions of `co_await`. The end location of the call expression is the `co_await` token loc, while the start is the location of the operand. This causes crashes when the source range is used to produce diagnostics.

This patch fixes the issues by using the expression location instead of the token location when building the member calls.

Reviewers: GorNishanov, rsmith, vsk, aaron.ballman

Reviewed By: vsk

Subscribers: cfe-commits, modocache

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

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

6 years agoFix unused expression warning in co_await.
Eric Fiselier [Tue, 27 Mar 2018 00:58:16 +0000 (00:58 +0000)]
Fix unused expression warning in co_await.

Previously, anytime the result of the resume expression in
operator co_await was unused, a warning was generated. This
patch fixes the issue by only generating the unused result warning
if calling `await_resume()` would also generate a warning.

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

6 years agoRemove dead method
Reid Kleckner [Tue, 27 Mar 2018 00:26:13 +0000 (00:26 +0000)]
Remove dead method

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

6 years ago[Edit, Rewrite] Fix some Clang-tidy modernize and Include What You Use warnings;...
Eugene Zelenko [Tue, 27 Mar 2018 00:01:49 +0000 (00:01 +0000)]
[Edit, Rewrite] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

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

6 years ago[Frontend] Fix some Clang-tidy modernize and Include What You Use warnings; other...
Eugene Zelenko [Mon, 26 Mar 2018 21:45:04 +0000 (21:45 +0000)]
[Frontend] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

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

6 years ago[MS] Fix late-parsed template infinite loop in eager instantiation
Reid Kleckner [Mon, 26 Mar 2018 18:22:47 +0000 (18:22 +0000)]
[MS] Fix late-parsed template infinite loop in eager instantiation

Summary:
This fixes PR33561 and PR34185.

Don't store pending template instantiations for late-parsed templates in
the normal PendingInstantiations queue. Instead, use a separate list
that will only be parsed and instantiated at end of TU when late
template parsing actually works and doesn't infinite loop.

Reviewers: rsmith, thakis, hans

Subscribers: cfe-commits

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

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

6 years ago[CodeGen] Mark fma as const for Android
Pirama Arumuga Nainar [Mon, 26 Mar 2018 17:03:34 +0000 (17:03 +0000)]
[CodeGen] Mark fma as const for Android

Summary:
r318093 sets fma, fmaf, fmal as const for Gnu and MSVC.  Android also
does not set errno for these functions.  So mark these const for
Android.

Reviewers: spatel, efriedma, srhines, chh, enh

Subscribers: cfe-commits, llvm-commits

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

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

6 years ago[OPENMP] Codegen for declare target with link clause.
Alexey Bataev [Mon, 26 Mar 2018 16:40:55 +0000 (16:40 +0000)]
[OPENMP] Codegen for declare target with link clause.

If the link clause is used on the declare target directive, the object
should be linked on target or target data directives, not during the
codegen. Patch adds support for this clause.

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

6 years ago[clang-format] Wildcard expansion on Windows.
Alexander Kornienko [Mon, 26 Mar 2018 13:54:17 +0000 (13:54 +0000)]
[clang-format] Wildcard expansion on Windows.

Summary:
Add support for wildcard expansion in command line arguments on Windows.
See https://docs.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments

Fixes https://bugs.llvm.org/show_bug.cgi?id=17217

Reviewers: klimek, djasper, rnk

Reviewed By: rnk

Subscribers: rnk, smeenai, zturner, alexfh, mgorny, cfe-commits

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

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

6 years ago[SemaCXX] _Pragma("clang optimize off") not affecting lambda.
Carlos Alberto Enciso [Mon, 26 Mar 2018 13:48:03 +0000 (13:48 +0000)]
[SemaCXX] _Pragma("clang optimize off") not affecting lambda.

Declaring "_Pragma("clang optimize off")" before the body of a
function with a lambda leads to the lambda functions in the body
not being affected.

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

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

6 years agoRemove reference to stale (2009) python version.
Yaron Keren [Sun, 25 Mar 2018 13:12:05 +0000 (13:12 +0000)]
Remove reference to stale (2009) python version.

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

6 years ago[C++17] Fix class template argument deduction for default constructors without an...
Zhihao Yuan [Sat, 24 Mar 2018 04:32:11 +0000 (04:32 +0000)]
[C++17] Fix class template argument deduction for default constructors without an initializer

Summary:
As the title says, this makes following code compile:

```
template<typename> struct Foo {};
Foo() -> Foo<void>;

Foo f; // ok
```

Thanks Nicolas Lesser for coining the fix.

Reviewers: rsmith, lichray

Reviewed By: rsmith, lichray

Subscribers: lichray, cfe-commits

Tags: #clang

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

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

6 years ago[analyzer] Do not crash in CallEvent.getReturnType()
George Karpenkov [Sat, 24 Mar 2018 01:53:12 +0000 (01:53 +0000)]
[analyzer] Do not crash in CallEvent.getReturnType()

When the call expression is not available.

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

6 years ago[ODRHash] Support pointer and reference types.
Richard Trieu [Sat, 24 Mar 2018 00:52:44 +0000 (00:52 +0000)]
[ODRHash] Support pointer and reference types.

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

6 years ago[libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.
Matt Morehouse [Fri, 23 Mar 2018 23:35:28 +0000 (23:35 +0000)]
[libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.

Summary:
Disables certain CMP optimizations to improve fuzzing signal under -O1
and -O2.

Switches all fuzzer tests to -O2 except for a few leak tests where the
leak is optimized out under -O2.

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, llvm-commits

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

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

6 years agoChange for an LLVM header file move
David Blaikie [Fri, 23 Mar 2018 22:16:59 +0000 (22:16 +0000)]
Change for an LLVM header file move

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

6 years ago[CUDA] Fixed false error reporting in case of calling H->G->HD->D.
Artem Belevich [Fri, 23 Mar 2018 19:49:03 +0000 (19:49 +0000)]
[CUDA] Fixed false error reporting in case of calling H->G->HD->D.

Launching a kernel from the host code does not generate code for the
kernel itself. This fixes an issue with clang erroneously reporting
an error for a HD->D call from within the kernel.

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

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

6 years ago[HWASan] Port HWASan to Linux x86-64 (clang)
Alex Shlyapnikov [Fri, 23 Mar 2018 19:47:45 +0000 (19:47 +0000)]
[HWASan] Port HWASan to Linux x86-64 (clang)

Summary: Porting HWASan to Linux x86-64, the third of the three patches, clang part.

Reviewers: eugenis

Subscribers: cryptoad, cfe-commits

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

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

6 years ago[AMDGPU] Fix codegen for inline assembly
Yaxun Liu [Fri, 23 Mar 2018 19:43:42 +0000 (19:43 +0000)]
[AMDGPU] Fix codegen for inline assembly

Need to override convertConstraint to recognise amdgpu specific register names.

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

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

6 years ago[AMDGPU] Update OpenCL to use 48 bytes of implicit arguments for AMDGPU (CLANG)
Tony Tye [Fri, 23 Mar 2018 18:51:45 +0000 (18:51 +0000)]
[AMDGPU] Update OpenCL to use 48 bytes of implicit arguments for AMDGPU (CLANG)

Add two additional implicit arguments for OpenCL for the AMDGPU target using the AMDHSA runtime to support device enqueue.

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

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

6 years ago[AMDGPU] Remove use of OpenCL triple environment and replace with function attribute...
Tony Tye [Fri, 23 Mar 2018 18:43:15 +0000 (18:43 +0000)]
[AMDGPU] Remove use of OpenCL triple environment and replace with function attribute for AMDGPU (CLANG)

- Remove use of the opencl and amdopencl environment member of the target triple for the AMDGPU target.
- Use a function attribute to communicate to the AMDGPU backend.

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

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

6 years ago[vfs] Don't bail out after a missing -ivfsoverlay file
Ben Langmuir [Fri, 23 Mar 2018 17:37:27 +0000 (17:37 +0000)]
[vfs] Don't bail out after a missing -ivfsoverlay file

This make -ivfsoverlay behave more like other fatal errors (e.g. missing
-include file) by skipping the missing file instead of bailing out of
the whole compilation. This makes it possible for libclang to still
provide some functionallity as well as to correctly produce the fatal
error diagnostic (previously we lost the diagnostic in libclang since
there was no TU to tie it to).

rdar://33385423

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

6 years agoBring r328238 back with a fix.
Rafael Espindola [Fri, 23 Mar 2018 01:36:23 +0000 (01:36 +0000)]
Bring r328238 back with a fix.

The issues was that we were setting hidden visibility if, when
processing a hidden class, we found out that we needed to emit a
reference to a vtable provided by the standard library.

Original message:

Set dso_local on vtables.

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

6 years agoRemove problematic PrettyStackTrace entry added in r328276
Jordan Rose [Fri, 23 Mar 2018 01:12:09 +0000 (01:12 +0000)]
Remove problematic PrettyStackTrace entry added in r328276

I'm not sure /why/ this is causing issues for libclang, but it is.
Unbreak the buildbots since it's already consumed an hour of my time.

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

6 years ago[Modules] Update test to mention it requires C++14.
Volodymyr Sapsai [Fri, 23 Mar 2018 00:16:06 +0000 (00:16 +0000)]
[Modules] Update test to mention it requires C++14.

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

6 years ago[analyzer] Trust _Nonnull annotations for system framework
George Karpenkov [Fri, 23 Mar 2018 00:16:03 +0000 (00:16 +0000)]
[analyzer] Trust _Nonnull annotations for system framework

Changes the analyzer to believe that methods annotated with _Nonnull
from system frameworks indeed return non null objects.
Local methods with such annotation are still distrusted.
rdar://24291919

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

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

6 years ago[analyzer] Extend GCDAntipatternChecker to match group_enter/group_leave pattern
George Karpenkov [Fri, 23 Mar 2018 00:16:02 +0000 (00:16 +0000)]
[analyzer] Extend GCDAntipatternChecker to match group_enter/group_leave pattern

rdar://38480416

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

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

6 years ago[analyzer] [NFC] Move worklist implementation to WorkList.cpp
George Karpenkov [Fri, 23 Mar 2018 00:16:01 +0000 (00:16 +0000)]
[analyzer] [NFC] Move worklist implementation to WorkList.cpp

Current location is very confusing, especially because there is already
WorkList.h, and other code in CoreEngine.cpp is not related to work list
implementation.

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

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

6 years ago[ARM] Add ARMv8.2-A FP16 vector intrinsic
Abderrazek Zaafrani [Fri, 23 Mar 2018 00:08:40 +0000 (00:08 +0000)]
[ARM] Add ARMv8.2-A FP16 vector intrinsic

Putting back the code in commit r327189 that was reverted in r322737. The code is being committed in three stages and this one is the last stage: 1) r327455 fp16 feature flags, 2) r327836 pass half type or i16 based on FullFP16, and 3) the code here which the front-end fp16 vector intrinsic for ARM.

Differential revision https://reviews.llvm.org/D43650

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

6 years agoSink PrettyDeclStackTrace down to the AST library
Jordan Rose [Fri, 23 Mar 2018 00:07:18 +0000 (00:07 +0000)]
Sink PrettyDeclStackTrace down to the AST library

...and add some very basic stack trace entries for module building.
This would have helped track down rdar://problem/38434694 sooner.

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

6 years agoSet dso_local on __ImageBase.
Rafael Espindola [Thu, 22 Mar 2018 23:02:19 +0000 (23:02 +0000)]
Set dso_local on __ImageBase.

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

6 years agoAdd a test.
Rafael Espindola [Thu, 22 Mar 2018 22:57:48 +0000 (22:57 +0000)]
Add a test.

This would have found the regression in r328238.

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

6 years ago[analyzer] Enable temporary object destructor inlining by default.
Artem Dergachev [Thu, 22 Mar 2018 22:05:53 +0000 (22:05 +0000)]
[analyzer] Enable temporary object destructor inlining by default.

When a temporary is constructed with a proper construction context, it should
be safe to inline the destructor. We have added suppressions for some of the
common false positives caused by such inlining, so there should be - and from my
observations there indeed is - more benefit than harm from enabling destructor
inlining.

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

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

6 years ago[CFG] [analyzer] Add C++17-specific ctor-initializer construction contexts.
Artem Dergachev [Thu, 22 Mar 2018 22:02:38 +0000 (22:02 +0000)]
[CFG] [analyzer] Add C++17-specific ctor-initializer construction contexts.

CXXCtorInitializer-based constructors are also affected by the C++17 mandatory
copy elision, like variable constructors and return value constructors.
Extend r328248 to support those.

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

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

6 years ago[analyzer] Remove an assertion that doesn't hold in C++17.
Artem Dergachev [Thu, 22 Mar 2018 21:54:48 +0000 (21:54 +0000)]
[analyzer] Remove an assertion that doesn't hold in C++17.

Function return values can be constructed directly in variables or passed
directly into return statements, without even an elidable copy in between.
This is how the C++17 mandatory copy elision AST behaves. The behavior we'll
have in such cases is the "old" behavior that we've had before we've
implemented destructor inlining and proper lifetime extension support.

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

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