Commit Graph

42008 Commits

Author SHA1 Message Date
Devin Coughlin e69b043088 [analyzer] Refer to capture field to determine if capture is reference.
The analyzer incorrectly treats captures as references if either the original
captured variable is a reference or the variable is captured by reference.
This causes the analyzer to crash when capturing a reference type by copy
(PR24914). Fix this by refering solely to the capture field to determine when a
DeclRefExpr for a lambda capture should be treated as a reference type.

https://llvm.org/bugs/show_bug.cgi?id=24914
rdar://problem/23524412

llvm-svn: 253157
2015-11-15 03:07:17 +00:00
David Majnemer 7f77eb90a5 [Sema] Don't crash trying to diagnose abs called on a pointer type
Clang tries to figure out if a call to abs is suspicious by looking
through implicit casts to look at the underlying, implicitly converted
type.
Interestingly, C has implicit conversions from pointer-ish types like
function to less exciting types like int.  This trips up our 'abs'
checker because it doesn't know which variant of 'abs' is appropriate.

Instead, diagnose 'abs' called on function types upfront.  This sort of
thing is highly suspicious and is likely indicative of a missing
pointer dereference/function call/array index operation.

This fixes PR25532.

llvm-svn: 253156
2015-11-15 03:04:34 +00:00
Craig Topper 07fa176669 Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFC
llvm-svn: 253155
2015-11-15 02:31:46 +00:00
Craig Topper abb83aed5c Move diagnostics from Parse to Sema to remove Sema's dependency on ParserDiagnostic.h diagnostics.
llvm-svn: 253143
2015-11-14 19:31:56 +00:00
Craig Topper 7d2f94319f Fix indentation. NFC
llvm-svn: 253142
2015-11-14 19:31:52 +00:00
Craig Topper 54a6a68c70 Merge some similar diagnostics using %select.
llvm-svn: 253136
2015-11-14 18:16:08 +00:00
Craig Topper 3110a5cb93 Minor formatting fixes. NFC
llvm-svn: 253135
2015-11-14 18:16:02 +00:00
Craig Topper ff35428593 Fix 80 column violation. NFC.
llvm-svn: 253134
2015-11-14 18:16:00 +00:00
Craig Topper 3f13d4d20d Fix spelling error in comment.
llvm-svn: 253133
2015-11-14 18:15:55 +00:00
Ben Langmuir 90717ad731 [modules] Allow "redefinition" of typedef of anon tag from unimported submodule
r233345 started being stricter about typedef names for linkage purposes
in non-visible modules, but broke languages without the ODR.

rdar://23527954

llvm-svn: 253123
2015-11-14 03:26:14 +00:00
Eric Christopher ce83677666 Add support for the always_inline + target feature diagnostic to print
out the first missing target feature that's required and reword
the diagnostic accordingly.

llvm-svn: 253121
2015-11-14 02:38:37 +00:00
Craig Topper 7f5ff2175f Use %select to merge similar diagnostics. NFC
llvm-svn: 253119
2015-11-14 02:09:55 +00:00
Eric Christopher 39db726093 Clarify and elaborate the conditions on which we're checking target
features for calls.

llvm-svn: 253117
2015-11-14 01:56:04 +00:00
Matthias Gehre 09a134eca3 CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt
Summary:
VisitReturnStmt would create a new block with including Dtors, so the Dtors created
in VisitCompoundStmts would be in an unreachable block.

Example:

struct S {
  ~S();
};

void f()
{
  S s;
  return;
}

void g()
{
  S s;
}

Before this patch, f has one additional unreachable block containing just the
destructor of S. With this patch, both f and g have the same blocks.

Reviewers: krememek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13973

llvm-svn: 253107
2015-11-14 00:36:50 +00:00
Justin Bogner f905256386 Revert "[AArch64] Unconditionally pass subtarget feature reserve-x18 on Darwin."
This reverts r243310, which is redundant as of r253102.

Conflicts:
	lib/Driver/Tools.cpp

llvm-svn: 253104
2015-11-13 23:07:31 +00:00
Juergen Ributzka 8aaae5a911 Fix auto-link for text-based dynamic library SDKs.
When linking against text-based dynamic library SDKs the library name of a
framework has now more than one possible filename extensions. This fix tests for
both possible extensions (none, and .tbd).

This fixes rdar://problem/20609975

llvm-svn: 253060
2015-11-13 19:08:07 +00:00
David Majnemer 9658ecc53b [Sema] __is_constructible should return false for function types
While functions types are complete, they cannot be constructed.

This fixes PR25513.

llvm-svn: 253013
2015-11-13 05:32:43 +00:00
Richard Smith 26210db67f [modules] Follow the C++ standard's rule for linkage of enumerators: they have
the linkage of the enumeration. For enumerators of unnamed enumerations, extend
the -Wmodules-ambiguous-internal-linkage extension to allow selecting an
arbitrary enumerator (but only if they all have the same value, otherwise it's
ambiguous).

llvm-svn: 253010
2015-11-13 03:52:13 +00:00
Akira Hatanaka 7828b1e604 Add support for function attribute 'disable_tail_calls'.
The ``disable_tail_calls`` attribute instructs the backend to not
perform tail call optimization inside the marked function.

For example, 

int callee(int);

int foo(int a) __attribute__((disable_tail_calls)) {
  return callee(a); // This call is not tail-call optimized.
}

Note that this attribute is different from 'not_tail_called', which
prevents tail-call optimization to the marked function.

rdar://problem/8973573

Differential Revision: http://reviews.llvm.org/D12547

llvm-svn: 252986
2015-11-13 00:42:21 +00:00
John McCall d6da23d2df Remove -Wobjc-weak-compat; there isn't a compelling use case for this.
llvm-svn: 252971
2015-11-12 23:39:39 +00:00
Richard Smith 4b213d73d8 Avoid duplicated diagnostic when lookup for a nested-name-specifier fails due to ambiguity.
llvm-svn: 252967
2015-11-12 22:40:09 +00:00
Richard Smith 97135cc94a [modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:

 * It is visible (not in a module, or in an imported module), or
 * We're doing redeclaration lookup and it's externally-visible, or
 * We're doing typo correction and looking for unimported decls.

We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.

This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on).  It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).

This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.

llvm-svn: 252960
2015-11-12 22:19:45 +00:00
Richard Smith 990668b7d0 DR407: Rationalize how we handle tags being hidden by typedefs. Even with
DR407, the C++ standard doesn't really say how this should work. Here's what we
do (which is consistent with DR407 as far as I can tell):

 * When performing name lookup for an elaborated-type-specifier, a tag
   declaration hides a typedef declaration that names the same type.
 * When performing any other kind of lookup, a typedef declaration hides
   a tag declaration that names the same type.

In any other case where lookup finds both a typedef and a tag (that is, when
they name different types), the lookup will be ambiguous. If lookup finds a
tag and a typedef that name the same type, and finds anything else, the lookup
will always be ambiguous (even if the other entity would hide the tag, it does
not also hide the typedef).

llvm-svn: 252959
2015-11-12 22:04:34 +00:00
Richard Smith 5e3fb7616d Revert r240335.
This failed to solve the problem it was aimed at, and introduced just as many
issues as it resolved. Realistically, we need to deal with the possibility that
multiple modules might define different internal linkage symbols with the same
name, and this isn't a problem unless two such symbols are simultaneously
visible.

The case where two modules define equivalent internal linkage symbols is
handled by r252063: if lookup finds multiple sufficiently-similar entities from
different modules, we just pick one of them as an extension (but we keep them
separate).

llvm-svn: 252957
2015-11-12 21:55:58 +00:00
James Y Knight 7aefb5b623 Correct atomic libcall support for __atomic_*_fetch builtins.
In r244063, I had caused these builtins to call the same-named library
functions, __atomic_*_fetch_SIZE. However, this was incorrect: while
those functions are in fact supported by GCC's libatomic, they're not
documented by the spec (and gcc doesn't ever call them).

Instead, you're /supposed/ to call the __atomic_fetch_* builtins and
then redo the operation inline to return the final value.

Differential Revision: http://reviews.llvm.org/D14385

llvm-svn: 252920
2015-11-12 18:37:29 +00:00
Akira Hatanaka 0202848ad0 Add support for driver option -mno-ms-bitfields.
This option is used to cancel -mms-bitfields on the command line.

rdar://problem/15898553

llvm-svn: 252912
2015-11-12 17:21:22 +00:00
Artyom Skrobov ab2fab926f Cull non-standard variants of ARM architectures (NFC)
Summary: Clang-side update, corresponding to D14577

Reviewers: rengolin

Subscribers: aemerson, cfe-commits, rengolin

Differential Revision: http://reviews.llvm.org/D14578

llvm-svn: 252904
2015-11-12 15:52:02 +00:00
James Molloy c16a60b63e [C++] Add the "norecurse" attribute to main() if in C++ mode
The C++ spec (3.6.1.3) says "The function `main` shall not be used within a program". This implies that it cannot recurse, so add the norecurse attribute to help the midend out a bit.

llvm-svn: 252902
2015-11-12 15:36:04 +00:00
Vasileios Kalintiris c744e120f6 Re-recommit: Add support for the new mips-mti-linux toolchain.
Last time, this caused two Windows buildbots and a single ARM buildbot to fail.
I XFAIL'd the failing test on win32,win64 machines in order to see if the ARM
buildbot complains again.

llvm-svn: 252901
2015-11-12 15:26:54 +00:00
Craig Topper 71a51ff10e Use %select to merge two diagnostics that only differ in one word and are emitted in the same place. NFC
llvm-svn: 252861
2015-11-12 07:36:50 +00:00
Nathan Wilson 3702255bc9 [Sema] Remove unnecessary parens in check using logical or; NFC.
llvm-svn: 252855
2015-11-12 04:25:03 +00:00
David Blaikie 5df25338a0 Refactor out some common code from r252834
llvm-svn: 252840
2015-11-12 01:09:58 +00:00
Eric Christopher 2b2d56f059 Provide a frontend based error for always_inline functions that require
target features that the caller function doesn't provide. This matches
the existing backend failure to inline functions that don't have
matching target features - and diagnoses earlier in the case of
always_inline.

Fix up a few test cases that were, in fact, invalid if you tried
to generate code from the backend with the specified target features
and add a couple of tests to illustrate what's going on.

This should fix PR25246.

llvm-svn: 252834
2015-11-12 00:44:12 +00:00
Eric Christopher fbfd97ed5c Move checkTargetFeatures to CodeGenFunction.cpp to make it
more obvious that it's generic.

llvm-svn: 252833
2015-11-12 00:44:07 +00:00
Eric Christopher c7e79dbec8 In preparation to use it in more places rename
checkBuiltinTargetFeatures to checkTargetFeatures and sink
the error handling into the function.

llvm-svn: 252832
2015-11-12 00:44:04 +00:00
Vedant Kumar 5eeeab7dcf [Basic] Fix DRY violation, just call getLineTable() (NFC)
llvm-svn: 252828
2015-11-12 00:11:19 +00:00
Nathan Wilson 68b2b9b3dc Add diagnostics which fall under [dcl.spec.concept]p5
Summary: Diagnose when a function concept declaration has parameter(s)

Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D14352

llvm-svn: 252827
2015-11-11 23:53:35 +00:00
Manman Ren f93fff27f0 [TLS on Darwin] treat all Darwin platforms in the same way.
rdar://problem/9001553

llvm-svn: 252820
2015-11-11 23:08:18 +00:00
Eric Christopher 2b90a64e31 Extract out a function onto CodeGenModule for getting the map of
features for a particular function, then use it to clean up some
code.

llvm-svn: 252819
2015-11-11 23:05:08 +00:00
Manman Ren 6815026991 [TLS on Darwin] change how we handle globals with linkonce or weak linkage.
This is about how we handle static member of a template. Before this commit,
we use internal linkage for the IR thread-local variable, which is inefficient.
With this commit, we will start to follow Itanium C++ ABI.

rdar://problem/23415206

Reviewed by John McCall.

llvm-svn: 252814
2015-11-11 22:42:31 +00:00
Davide Italiano 5be2233a81 [SemaDeclCXX] Use isTemplateParamScope() rather than accessing raw bits.
llvm-svn: 252793
2015-11-11 20:06:35 +00:00
Manman Ren 14f88158c7 [TLS] move setting tls_guard in tls_init.
We used to emit the store prior to branch in the entry block. To make it more
efficient, this commit moves it to the init block. We still mark as initialized
before initializing anything else.

llvm-svn: 252777
2015-11-11 19:19:26 +00:00
Aaron Ballman a9a728513c Silencing a -Wreturn-type warning for control reaching the end of a non-void function.
llvm-svn: 252727
2015-11-11 13:42:02 +00:00
Yury Gribov 5bfeca1201 [ASan] Allow -fsanitize-recover=address.
Differential Revision: http://reviews.llvm.org/D14243

llvm-svn: 252721
2015-11-11 10:45:48 +00:00
Craig Topper fb79b5f273 [X86] Add 'pause' builtin that's already in llvm and use it instead of inline assembly to implement _mm_pause.
llvm-svn: 252712
2015-11-11 08:13:33 +00:00
Craig Topper a5455524c2 [X86] Use __builtin_ia32_paddq and __builtin_ia32_psubq to implement a couple intrinsics that were supposed to operate on MMX registers. Otherwise we end up operating on GPRs. Throw in a test for _mm_mul_su32 while I was there.
llvm-svn: 252711
2015-11-11 08:00:41 +00:00
Craig Topper 880f60b7b3 [X86] Header formatting fixes. NFC
llvm-svn: 252710
2015-11-11 08:00:39 +00:00
Craig Topper d619eaaae4 [X86] Add missing typecasts in intrinsic macros. This should make them more robust against inputs that aren't already the right type.
llvm-svn: 252700
2015-11-11 03:47:10 +00:00
Craig Topper 19744ee6ad [X86] Change pointer type in AVX2 gather builtins to be the scalar type instead of the vector type. This matches gcc and removes extras casts.
llvm-svn: 252697
2015-11-11 02:51:18 +00:00
Eric Christopher ed60b436d4 Fix a FIXME about using std::is_sorted.
llvm-svn: 252691
2015-11-11 02:04:08 +00:00