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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Artem Dergachev [Thu, 22 Mar 2018 21:40:24 +0000 (21:40 +0000)]
[CFG] [analyzer] NFC: Move construction context allocation into a helper method.
Improve readability of ConstructionContext::createFromLayers().
Differential Revision: https://reviews.llvm.org/D44725
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328249
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Dergachev [Thu, 22 Mar 2018 21:37:39 +0000 (21:37 +0000)]
[CFG] [analyzer] Add C++17-specific variable and return construction contexts.
In C++17 copy elision is mandatory for variable and return value constructors
(as long as it doesn't involve type conversion) which results in AST that does
not contain elidable constructors in their usual places. In order to provide
construction contexts in this scenario we need to cover more AST patterns.
This patch makes the CFG prepared for these scenarios by:
- Fork VariableConstructionContext and ReturnedValueConstructionContext into
two different sub-classes (each) one of which indicates the C++17 case and
contains a reference to an extra CXXBindTemporaryExpr.
- Allow CFGCXXRecordTypedCall element to accept VariableConstructionContext and
ReturnedValueConstructionContext as its context.
Differential Revision: https://reviews.llvm.org/D44597
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328248
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Dergachev [Thu, 22 Mar 2018 21:30:58 +0000 (21:30 +0000)]
[analyzer] Make symbol_iterator iterate over SVal's symbolic base.
If a memory region (or an SVal that represents a pointer to that memory region)
is a (direct or indirect, not necessarily proper) sub-region of a SymbolicRegion
then it is said to have a symbolic base.
For now SVal::symbol_iterator explores the symbol within a symbolic region
only when the SVal represents a pointer to the symbolic region itself,
not to any of its sub-regions.
This behavior is not indended by any user of symbol_iterator; all users who
cared about such behavior were expecting the iterator to descend into the
symbolic base of an arbitrary region, find the parent symbol of the symbolic
base region, and iterate over that symbol. Lack of such behavior resulted in
bugs demonstarted by the test cases.
Hence the decision to change the API to behave more intuitively.
Differential Revision: https://reviews.llvm.org/D44347
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328247
91177308-0d34-0410-b5e6-
96231b3b80d8
Eric Fiselier [Thu, 22 Mar 2018 21:17:07 +0000 (21:17 +0000)]
Fix test failure on Windows caused by different underlying enumeration type rules
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328243
91177308-0d34-0410-b5e6-
96231b3b80d8
Rafael Espindola [Thu, 22 Mar 2018 21:14:16 +0000 (21:14 +0000)]
Revert "Set dso_local on vtables."
This reverts commit r328238.
Looks like it broke some buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328242
91177308-0d34-0410-b5e6-
96231b3b80d8
Rafael Espindola [Thu, 22 Mar 2018 20:33:01 +0000 (20:33 +0000)]
Set dso_local on vtables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328238
91177308-0d34-0410-b5e6-
96231b3b80d8
Rafael Espindola [Thu, 22 Mar 2018 18:03:13 +0000 (18:03 +0000)]
Set dso_local on builtin functions.
The difference between CreateRuntimeFunction and CreateBuiltinFunction
is that CreateBuiltinFunction would not set dllimport or dso_local.
To keep the current semantics, just forward to CreateRuntimeFunction
with Local=true so it doesn't add dllimport.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328224
91177308-0d34-0410-b5e6-
96231b3b80d8
Ben Hamilton [Thu, 22 Mar 2018 17:37:19 +0000 (17:37 +0000)]
[clang-format] Fix ObjC style guesser to also iterate over child lines
Summary:
When I wrote `ObjCHeaderStyleGuesser`, I incorrectly assumed the
correct way to iterate over all tokens in `AnnotatedLine` was to
iterate over the linked list tokens starting with
`AnnotatedLine::First`.
However, `AnnotatedLine` also contains a vector
`AnnotedLine::Children` with child `AnnotedLine`s which have their own
tokens which we need to iterate over.
Because I didn't iterate over the tokens in the children lines, the
ObjC style guesser would fail on syntax like:
#define FOO ({ NSString *s = ... })
as the statement(s) inside { ... } are child lines.
This fixes the bug and adds a test. I confirmed the test
failed before the fix, and passed after the fix.
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/D44790
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328220
91177308-0d34-0410-b5e6-
96231b3b80d8
Gheorghe-Teodor Bercea [Thu, 22 Mar 2018 17:33:27 +0000 (17:33 +0000)]
[OpenMP][Clang] Add call to global data sharing stack initialization on the workers side
Summary: The workers also need to initialize the global stack. The call to the initialization function needs to happen after the kernel_init() function is called by the master. This ensures that the per-team data structures of the runtime have been initialized.
Reviewers: ABataev, grokos, carlo.bertolli, caomhin
Reviewed By: ABataev
Subscribers: jholewinski, guansong, cfe-commits
Differential Revision: https://reviews.llvm.org/D44749
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328219
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Belevich [Thu, 22 Mar 2018 16:47:41 +0000 (16:47 +0000)]
[CUDA] add REQUIRES fields for CUDA variants of LTO tests.
Also relax checking for nvptx triple. This should avoid test failure if
the test is executed on 32-bit platform.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328213
91177308-0d34-0410-b5e6-
96231b3b80d8
Daniel Jasper [Thu, 22 Mar 2018 14:43:54 +0000 (14:43 +0000)]
clang-format: Narrow down raw string literal line break exception.
For multiline raw string literals, we generally want to respect the
author's choice of linebreak before the 'R"(' as the rest of the raw
string might be aligned to it and we cannot (commonly) modify the
content.
For single-line raw string literals, this doesn't make any sense and so
we should just treat them as regular string literals in this regard.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328201
91177308-0d34-0410-b5e6-
96231b3b80d8
Daniel Jasper [Thu, 22 Mar 2018 14:30:28 +0000 (14:30 +0000)]
clang-format: Fix SpacesInParentheses with fully qualified names.
When SpacesInParentheses is set to true clang-format does not add a
space before fully qualified names. For example:
do_something(::globalVar );
Fix by Darby Payne. Thank you!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328200
91177308-0d34-0410-b5e6-
96231b3b80d8
Jonas Devlieghere [Thu, 22 Mar 2018 13:53:30 +0000 (13:53 +0000)]
[CodeGen] Emit DWARF "constructor" calling convention
Now that LLVM has support for emitting calling conventions in DWARF (see
r328191) have clang emit them.
Patch by: Adrien Guinet
Differential revision: https://reviews.llvm.org/D42351
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328196
91177308-0d34-0410-b5e6-
96231b3b80d8
Ben Hamilton [Thu, 22 Mar 2018 03:25:22 +0000 (03:25 +0000)]
[clang-format] Add a few more Core Graphics identifiers to ObjC heuristic
Summary:
We received reports of the Objective-C style guesser getting a false
negative on header files like:
CGSize SizeOfThing(MyThing thing);
This adds more Core Graphics identifiers to the Objective-C style
guesser.
Test Plan: New tests added. Ran tests with:
% make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests
Reviewers: jolesiak, djasper
Reviewed By: jolesiak, djasper
Subscribers: krasimir, klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D44632
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328175
91177308-0d34-0410-b5e6-
96231b3b80d8
Ben Hamilton [Thu, 22 Mar 2018 03:23:53 +0000 (03:23 +0000)]
[clang-format] Don't insert space between r_paren and 'new' in ObjC decl
Summary:
Previously, clang-format would insert a space between
the closing parenthesis and 'new' in the following valid Objective-C
declaration:
+ (instancetype)new;
This was because 'new' is treated as a keyword, not an identifier.
TokenAnnotator::spaceRequiredBefore() already handled the case where
r_paren came before an identifier, so this diff extends it to
handle r_paren before 'new'.
Test Plan: New tests added. Ran tests with:
% make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests
Reviewers: djasper, jolesiak, stephanemoore
Reviewed By: djasper, jolesiak, stephanemoore
Subscribers: stephanemoore, klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D44692
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328174
91177308-0d34-0410-b5e6-
96231b3b80d8
Robert Widmann [Thu, 22 Mar 2018 03:16:23 +0000 (03:16 +0000)]
Improve -Winfinite-recursion
Summary: Rewrites -Winfinite-recursion to remove the state dictionary and explore paths in loops - especially infinite loops. The new check now detects recursion in loop bodies dominated by a recursive call.
Reviewers: rsmith, rtrieu
Reviewed By: rtrieu
Subscribers: lebedev.ri, cfe-commits
Differential Revision: https://reviews.llvm.org/D43737
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328173
91177308-0d34-0410-b5e6-
96231b3b80d8
Eugene Zelenko [Thu, 22 Mar 2018 00:53:26 +0000 (00:53 +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@328171
91177308-0d34-0410-b5e6-
96231b3b80d8
David Blaikie [Wed, 21 Mar 2018 22:34:27 +0000 (22:34 +0000)]
Fix for LLVM change (Transforms/Utils/Local.h -> Analysis/Utils/Local.h)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328166
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Belevich [Wed, 21 Mar 2018 22:22:59 +0000 (22:22 +0000)]
[CUDA] Disable LTO for device-side compilations.
This fixes host-side LTO during CUDA compilation. Before, LTO
pipeline construction was clashing with CUDA pipeline construction.
At the moment there's no point doing LTO on device side as each
device-side TU is a complete program. We will need to figure out
compilation pipeline construction for the device-side LTO when we
have working support for multi-TU device-side CUDA compilation.
Differential Revision: https://reviews.llvm.org/D44691
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328161
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Belevich [Wed, 21 Mar 2018 21:55:02 +0000 (21:55 +0000)]
[NVPTX] Make tensor shape part of WMMA intrinsic's name.
This is needed for the upcoming implementation of the
new 8x32x16 and 32x8x16 variants of WMMA instructions
introduced in CUDA 9.1.
Differential Revision: https://reviews.llvm.org/D44719
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328158
91177308-0d34-0410-b5e6-
96231b3b80d8
Volodymyr Sapsai [Wed, 21 Mar 2018 21:28:54 +0000 (21:28 +0000)]
[Modules] Fix creating fake definition data for lambdas.
During reading C++ definition data for lambda we can access
CXXRecordDecl representing lambda before we finished reading the
definition data. This can happen by reading a captured variable which is
VarDecl, then reading its decl context which is CXXMethodDecl `operator()`,
then trying to merge redeclarable methods and accessing
enclosing CXXRecordDecl. The call stack looks roughly like
VisitCXXRecordDecl
ReadCXXRecordDefinition
VisitVarDecl
VisitCXXMethodDecl
mergeRedeclarable
getPrimaryContextForMerging
If we add fake definition data at this point, later we'll hit the assertion
Assertion failed: (!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?"), function MergeDefinitionData, file clang/lib/Serialization/ASTReaderDecl.cpp, line 1675.
The fix is to assign definition data before reading it. Fixes PR32556.
rdar://problem/
37461072
Reviewers: rsmith, bruno
Reviewed By: rsmith
Subscribers: cfe-commits, jkorous-apple, aprantl
Differential Revision: https://reviews.llvm.org/D43494
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328153
91177308-0d34-0410-b5e6-
96231b3b80d8
Eric Fiselier [Wed, 21 Mar 2018 19:19:48 +0000 (19:19 +0000)]
[Builtins] Overload __builtin_operator_new/delete to allow forwarding to usual allocation/deallocation functions.
Summary:
Libc++'s default allocator uses `__builtin_operator_new` and `__builtin_operator_delete` in order to allow the calls to new/delete to be ellided. However, libc++ now needs to support over-aligned types in the default allocator. In order to support this without disabling the existing optimization Clang needs to support calling the aligned new overloads from the builtins.
See llvm.org/PR22634 for more information about the libc++ bug.
This patch changes `__builtin_operator_new`/`__builtin_operator_delete` to call any usual `operator new`/`operator delete` function. It does this by performing overload resolution with the arguments passed to the builtin to determine which allocation function to call. If the selected function is not a usual allocation function a diagnostic is issued.
One open issue is if the `align_val_t` overloads should be considered "usual" when `LangOpts::AlignedAllocation` is disabled.
In order to allow libc++ to detect this new behavior the value for `__has_builtin(__builtin_operator_new)` has been updated to `201802`.
Reviewers: rsmith, majnemer, aaron.ballman, erik.pilkington, bogner, ahatanak
Reviewed By: rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D43047
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328134
91177308-0d34-0410-b5e6-
96231b3b80d8
Petr Hosek [Wed, 21 Mar 2018 16:48:26 +0000 (16:48 +0000)]
[Fuchsia] Don't install libc++, libc++abi or libunwind on Darwin
The Clang driver doesn't currently know how to use the libraries
that are shipped as part of the toolchain so there's no reason to
ship them at all.
Differential Revision: https://reviews.llvm.org/D44724
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328114
91177308-0d34-0410-b5e6-
96231b3b80d8
Luke Cheeseman [Wed, 21 Mar 2018 12:05:19 +0000 (12:05 +0000)]
clang-interpreter example cmake fix
Add in a space when appending the export to the linker options. Without
the space the export is appended onto whatever the last link option
was, which might be a file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328092
91177308-0d34-0410-b5e6-
96231b3b80d8
Clement Courbet [Wed, 21 Mar 2018 10:54:29 +0000 (10:54 +0000)]
[ASTMatchers] Remove extra qualifier for consistency (LibASTMatchersReference.html)
+ Regenerate doc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328087
91177308-0d34-0410-b5e6-
96231b3b80d8
Clement Courbet [Wed, 21 Mar 2018 10:48:00 +0000 (10:48 +0000)]
[ASTMatchers] Regenerate doc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328086
91177308-0d34-0410-b5e6-
96231b3b80d8
Rafael Espindola [Wed, 21 Mar 2018 01:30:16 +0000 (01:30 +0000)]
Set dso_local on runtime variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328068
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Dergachev [Wed, 21 Mar 2018 00:57:37 +0000 (00:57 +0000)]
Revert r326782 "[analyzer] CStringChecker.cpp: Remove the duplicated check...".
It seems that the refactoring was causing a functional change and some warnings
have disappeared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328067
91177308-0d34-0410-b5e6-
96231b3b80d8
Artem Dergachev [Wed, 21 Mar 2018 00:49:47 +0000 (00:49 +0000)]
[analyzer] Suppress more MallocChecker positives in smart pointer destructors.
r326249 wasn't quite enough because we often run out of inlining stack depth
limit and for that reason fail to see the atomics we're looking for.
Add a more straightforward false positive suppression that is based on the name
of the class. I.e. if we're releasing a pointer in a destructor of a "something
shared/intrusive/reference/counting something ptr/pointer something", then any
use-after-free or double-free that occurs later would likely be a false
positive.
rdar://problem/
38013606
Differential Revision: https://reviews.llvm.org/D44281
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328066
91177308-0d34-0410-b5e6-
96231b3b80d8
Eugene Zelenko [Wed, 21 Mar 2018 00:14:43 +0000 (00:14 +0000)]
[Analysis] 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@328063
91177308-0d34-0410-b5e6-
96231b3b80d8
Bruno Cardoso Lopes [Tue, 20 Mar 2018 22:36:39 +0000 (22:36 +0000)]
[Modules] Honor -fmodule-name when handling private framework modules
When skipping building the module for a private framework module,
LangOpts.CurrentModule isn't enough for implict modules builds; for
instance, in case a private module is built while building a public one,
LangOpts.CurrentModule doesn't reflect the -fmodule-name being passed
down, but instead the module name which triggered the build.
Store the actual -fmodule-name in LangOpts.ModuleName and actually
check a name was provided during compiler invocation in order to
skip building the private module.
rdar://problem/
38434694
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328053
91177308-0d34-0410-b5e6-
96231b3b80d8
Erich Keane [Tue, 20 Mar 2018 22:05:01 +0000 (22:05 +0000)]
Change ImplicitConverionKind comments to refer to C++ stable names[NFC]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328051
91177308-0d34-0410-b5e6-
96231b3b80d8
Rafael Espindola [Tue, 20 Mar 2018 22:02:57 +0000 (22:02 +0000)]
Delete BuiltinCC. NFC.
It is always identical to RuntimeCC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328050
91177308-0d34-0410-b5e6-
96231b3b80d8
Rafael Espindola [Tue, 20 Mar 2018 21:54:14 +0000 (21:54 +0000)]
Add CHECKs for a few declarations. NFC.
We were just missing test coverage for this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328048
91177308-0d34-0410-b5e6-
96231b3b80d8
Benjamin Kramer [Tue, 20 Mar 2018 21:52:19 +0000 (21:52 +0000)]
[format] Eliminate global destructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328047
91177308-0d34-0410-b5e6-
96231b3b80d8
Eugene Zelenko [Tue, 20 Mar 2018 21:08:59 +0000 (21:08 +0000)]
[Driver] 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@328044
91177308-0d34-0410-b5e6-
96231b3b80d8