Commit Graph

18178 Commits

Author SHA1 Message Date
Chandler Carruth 0d745bcf66 [modules] Teach the AST reader to handle the case of importing a module
with a subset of the existing target CPU features or mismatched CPU
names.

While we can't check that the CPU name used to build the module will end
up being able to codegen correctly for the translation unit, we actually
check that the imported features are a subset of the existing features.

While here, rewrite the code to use std::set_difference and have it
diagnose all of the differences found.

Test case added which walks the set relationships and ensures we
diagnose all the right cases and accept the others.

No functional change for implicit modules here, just better diagnostics.

llvm-svn: 232248
2015-03-14 04:47:43 +00:00
Peter Collingbourne d2926c91d5 Implement bad cast checks using control flow integrity information.
This scheme checks that pointer and lvalue casts are made to an object of
the correct dynamic type; that is, the dynamic type of the object must be
a derived class of the pointee type of the cast. The checks are currently
only introduced where the class being casted to is a polymorphic class.

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

llvm-svn: 232241
2015-03-14 02:42:25 +00:00
David Majnemer ba3e5ecf07 MS ABI: Implement __GetExceptionInfo for std::make_exception_ptr
std::make_exception_ptr calls std::__GetExceptionInfo in order to figure
out how to properly copy the exception object.

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

llvm-svn: 232188
2015-03-13 18:26:17 +00:00
Benjamin Kramer 1553727ed3 Sema: Replace the SetVector/DenseMap/std::sort combination with a simple std::map
This guarantees the order and doesn't increase malloc counts a lot as there are
typically very few elements int the map. Provide a little iterator adapter to
keep the same interface as we had with the flat sorted list.

No functional change intended.

llvm-svn: 232173
2015-03-13 16:10:42 +00:00
Alexey Bataev 1d160b1945 [OPENMP] Additional sema analysis for 'omp atomic[ update]'.
Adds additional semantic analysis + generation of helper expressions for proper codegen.

llvm-svn: 232164
2015-03-13 12:27:31 +00:00
Richard Smith df8a83127f Deduplicate #undef directives imported from multiple modules.
No functionality change, but deeply-importing module files are smaller and
faster now.

llvm-svn: 232140
2015-03-13 04:05:01 +00:00
Sanjay Patel 0a6da5de55 [X86, AVX2] Replace inserti128 and extracti128 intrinsics with generic shuffles
This is nearly identical to the v*f128_si256 parts of r231792 and r232052.

AVX2 introduced proper integer variants of the hacked integer insert/extract
C intrinsics that were created for this same functionality with AVX1.

This should complete the front end fixes for insert/extract128 intrinsics. 
Corresponding LLVM patch to follow.

llvm-svn: 232109
2015-03-12 21:54:24 +00:00
Benjamin Kramer 8cbf749690 Sema: Make BoundTypeDiagnoser a variadic template
llvm-svn: 232101
2015-03-12 20:58:06 +00:00
Sanjay Patel 0c351aba25 [X86, AVX] replace vextractf128 intrinsics with generic shuffles
This is very much like D8088 (checked in at r231792).

Now that we've replaced the vinsertf128 intrinsics,
do the same for their extract twins.

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

llvm-svn: 232052
2015-03-12 15:50:36 +00:00
Manuel Klimek bfa4357271 Add support for a few Objective-C matchers.
Add some matchers for Objective-C selectors and messages to
ASTMatchers.h. Minor mods to ASTMatchersTest.h to allow test files with
".m" extension in addition to ".cpp".  New tests added to
ASTMatchersTest.c.

Patch by Dean Sutherland.

llvm-svn: 232051
2015-03-12 15:48:15 +00:00
Aaron Ballman e9f931f974 Reverting r232034, as it broke one of the bots with link errors. Details at: http://bb.pgr.jp/builders/ninja-clang-x64-mingw64-RA/builds/6352/steps/build/logs/stdio
llvm-svn: 232038
2015-03-12 14:14:48 +00:00
Aaron Ballman 12865302b7 Added some matchers for objective c selectors and messages to ASTMatchers.h. Minor mods to ASTMatchersTest.h to allow test files with ".m" extension in addition to ".cpp". New tests added to ASTMatchersTest.c.
Patch by Dean Sutherland, reviewed by Manuel Klimek. From http://reviews.llvm.org/D7710

llvm-svn: 232034
2015-03-12 13:21:19 +00:00
Joerg Sonnenberger 27173288c2 Under duress, move check for target support of __builtin_setjmp/
__builtin_longjmp to Sema as requested by John McCall.

llvm-svn: 231986
2015-03-11 23:46:32 +00:00
Alexey Samsonov ce2e77c771 Add deprecation notice for -f(no-)sanitize-recover flags.
These flags should be replaced with corresponding
-f(no-)sanitize-recover=<list> flags.

llvm-svn: 231983
2015-03-11 23:34:25 +00:00
David Majnemer dfa6d2067c MS ABI: Implement copy-ctor closures, finish implementing throw
This adds support for copy-constructor closures.  These are generated
when the C++ runtime has to call a copy-constructor with a particular
calling convention or with default arguments substituted in to the call.

Because the runtime has no mechanism to call the function with a
different calling convention or know-how to evaluate the default
arguments at run-time, we create a thunk which will do all the
appropriate work and package it in a way the runtime can use.

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

llvm-svn: 231952
2015-03-11 18:36:39 +00:00
Anastasia Stulova e8d88ac185 Reverted OpenCL2.0 atomic type commits r231932, r231935
(caused undesirable update of -std flag to use _Atomic)  

llvm-svn: 231942
2015-03-11 17:26:37 +00:00
Fariborz Jahanian 20cfff3d31 revert r231700 (designated initializer patch) which broke
several projects. rdar://20120666.

llvm-svn: 231939
2015-03-11 16:59:48 +00:00
Anastasia Stulova 7263c35440 OpenCL: CL2.0 atomic type diagnostics
Added restictions for atomic type usage from OpenCL C Spec Section 6.13.11.8

llvm-svn: 231935
2015-03-11 16:23:10 +00:00
Anastasia Stulova 0cb5d3333a OpenCL: CL2.0 atomic types
OpenCL C Spec v2.0 Section 6.13.11

- Made c11 _Atomic being accepted only for c11 compilations

- Implemented CL2.0 atomics by aliasing them to the corresponding c11 atomic types using implicit typedef

- Added diagnostics for atomics Khronos extension enabling

llvm-svn: 231932
2015-03-11 15:57:53 +00:00
Kit Barton 8553bec911 Add builtins for the 64-bit vector integer arithmetic instructions added in POWER8.
These are the Clang-related changes for the instructions added to LLVM in http://reviews.llvm.org/D7959.

Phabricator review: http://reviews.llvm.org/D8041

llvm-svn: 231931
2015-03-11 15:57:19 +00:00
David Majnemer f9bde287e8 Sema: Properly track mangling number/name for linkage for using decls
Using declarations which are aliases to struct types have their name
used as the struct type's name for linkage purposes.  Otherwise, make
sure to give an anonymous struct defined inside a using declaration a
mangling number to disambiguate it from other anonymous structs in the
same context.

This fixes PR22809.

llvm-svn: 231909
2015-03-11 06:45:39 +00:00
Richard Smith 8ce51084b8 [modules] Avoid accidentally completing the redeclaration chain when updating
all the existing declarations of a record-like entity with a pointer to its
definition.

llvm-svn: 231901
2015-03-11 01:44:51 +00:00
Fariborz Jahanian 2954c67e4b [Objective-C Sema]. Remove -Wreceiver-is-weak warning.
It is incorrect and better warning is issued under
-Warc-repeated-use-of-weak. rdar://16316934.

llvm-svn: 231851
2015-03-10 21:28:33 +00:00
David Majnemer 999cbf9d21 MS ABI: Mangle the location of the catchable type into it's name
Because the catchable type has a reference to its name, mangle the
location to ensure that two catchable types with different locations are
distinct.

llvm-svn: 231819
2015-03-10 19:01:51 +00:00
Sanjay Patel 7f6aa52e93 [X86, AVX] Replace vinsertf128 intrinsics with generic shuffles.
We want to replace as much custom x86 shuffling via intrinsics
as possible because pushing the code down the generic shuffle
optimization path allows for better codegen and less complexity
in LLVM.

This is the sibling patch for the LLVM half of this change:
http://reviews.llvm.org/D8086

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

llvm-svn: 231792
2015-03-10 15:19:26 +00:00
Renato Golin 496059c8c9 Allow -target= and --target options
Using clang as a cross-compiler with the 'target' option could be confusing
for those inexperienced in the realm of cross compiling.

This patch would allow the use of all these four variants of the target option:
-target <triple>
--target <triple>
-target=<triple>
--target=<triple>

Patch by Gabor Ballabas.

llvm-svn: 231787
2015-03-10 13:58:33 +00:00
Richard Smith f81340096d [modules] Don't clobber a destructor's operator delete when adding another one;
move the operator delete updating into a separate update record so we can cope
with updating another module's destructor's operator delete.

llvm-svn: 231735
2015-03-10 01:41:22 +00:00
Alexey Samsonov 21d2dda3d2 [UBSan] Split -fsanitize=shift into -fsanitize=shift-base and -fsanitize=shift-exponent.
This is a recommit of r231150, reverted in r231409. Turns out
that -fsanitize=shift-base check implementation only works if the
shift exponent is valid, otherwise it contains undefined behavior
itself.

Make sure we check that exponent is valid before we proceed to
check the base. Make sure that we actually report invalid values
of base or exponent if -fsanitize=shift-base or
-fsanitize=shift-exponent is specified, respectively.

llvm-svn: 231711
2015-03-09 21:50:19 +00:00
Fariborz Jahanian 29dec576e6 [PATCH Sema Objective-C]. Patch to warn on missing designated initializer
override where at least a declaration of a designated initializer is in a super
class and not necessarily in the current class. rdar://19653785.

llvm-svn: 231700
2015-03-09 20:39:51 +00:00
Alexander Kornienko 85fb1be610 Correct doxygen for matcher macros that require a body. NFC.
http://reviews.llvm.org/D8146

Patch by Richard Thomson!

llvm-svn: 231670
2015-03-09 16:57:49 +00:00
Benjamin Kramer 66a97ee957 Hide away implementation details of the ThreadSafetyAnalysis in anonymous namespaces
NFC.

llvm-svn: 231653
2015-03-09 14:19:54 +00:00
Nico Weber ce90329824 Fix a theoretical bug when ParseCompoundStatement() returns StmtError.
ParseCompoundStatement() currently never returns StmtError, but if it did,
Sema would keep the __finally scope on its stack indefinitely.  Explicitly
add an error callback that clears it.

llvm-svn: 231625
2015-03-09 03:17:15 +00:00
Nico Weber d64657f298 Warn when jumping out of a __finally block via continue, break, return, __leave.
Since continue, break, return are much more common than __finally, this tries
to keep the work for continue, break, return O(1).  Sema keeps a stack of active
__finally scopes (to do this, ActOnSEHFinally() is split into
ActOnStartSEHFinally() and ActOnFinishSEHFinally()), and the various jump
statements then check if the current __finally scope (if present) is deeper
than then destination scope of the jump.

The same warning for goto statements is still missing.

This is the moral equivalent of MSVC's C4532.

llvm-svn: 231623
2015-03-09 02:47:59 +00:00
Benjamin Kramer 72b7d3ed4b Fix the MSVC build.
Type traits are hard.

llvm-svn: 231604
2015-03-08 18:20:22 +00:00
Benjamin Kramer d503c1c531 Make Token a real POD type.
We copy them around a lot and skip construction in favor of startToken,
make the default construction trivial to reflect that.

llvm-svn: 231603
2015-03-08 18:11:59 +00:00
Argyrios Kyrtzidis 69e6f1f257 [Rewrite] Make RewriteBuffer accessible on its own, and add a unit test for it.
llvm-svn: 231588
2015-03-08 04:00:33 +00:00
Argyrios Kyrtzidis fe0d61d245 [Rewrite] Move RewriteBuffer into its own header.
llvm-svn: 231587
2015-03-08 04:00:28 +00:00
Benjamin Kramer 57dd9bd5cc ASTMatchers: Make AST_POLYMORPHIC_SUPPORTED_TYPES a variadic macro
C++11 finally allows us to use this C99 feature.

llvm-svn: 231575
2015-03-07 20:38:15 +00:00
Richard Smith f19e12794d Replace Sema's map of locally-scoped extern "C" declarations with a DeclContext
of extern "C" declarations. This is simpler and vastly more efficient for
modules builds (we no longer need to load *all* extern "C" declarations to
determine if we have a redeclaration).

No functionality change intended.

llvm-svn: 231538
2015-03-07 00:04:49 +00:00
David Majnemer e7a818fec8 MS ABI: Insert copy-constructors into the CatchableType
Find all unambiguous public classes of the exception object's class type
and reference all of their copy constructors.  Yes, this is not
conforming but it is necessary in order to implement their ABI.  This is
because the copy constructor is actually referenced by the metadata
describing which catch handlers are eligible to handle the exception
object.

N.B.  This doesn't yet handle the copy constructor closure case yet,
that work is ongoing.

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

llvm-svn: 231499
2015-03-06 18:53:55 +00:00
Benjamin Kramer 7761a04715 Sema: We can use delegating ctors now. NFC.
llvm-svn: 231488
2015-03-06 16:36:50 +00:00
Samuel Benzaquen bb5093fefd Fix isOverride() for the case of a dependent typed base class.
The method decl is not marked as overriding any other method decls
until the template is instantiated.
Use the override attribute as another signal.

llvm-svn: 231487
2015-03-06 16:24:47 +00:00
Richard Smith fe620d26ea [modules] Rework merging of redeclaration chains on module import.
We used to save out and eagerly load a (potentially huge) table of merged
formerly-canonical declarations when we loaded each module. This was extremely
inefficient in the presence of large amounts of merging, and didn't actually
save any merging lookup work, because we still needed to perform name lookup to
check that our merged declaration lists were complete. This also resulted in a
loss of laziness -- even if we only needed an early declaration of an entity, we
would eagerly pull in all declarations that had been merged into it regardless.

We now store the relevant fragments of the table within the declarations
themselves. In detail:

 * The first declaration of each entity within a module stores a list of first
   declarations from imported modules that are merged into it.
 * Loading that declaration pre-loads those other entities, so that they appear
   earlier within the redeclaration chain.
 * The name lookup tables list the most recent local lookup result, if there
   is one, or all directly-imported lookup results if not.

llvm-svn: 231424
2015-03-05 23:24:12 +00:00
Alexey Samsonov 48a9db034a Revert "[UBSan] Split -fsanitize=shift into -fsanitize=shift-base and -fsanitize=shift-exponent."
It's not that easy. If we're only checking -fsanitize=shift-base we
still need to verify that exponent has sane value, otherwise
UBSan-inserted checks for base will contain undefined behavior
themselves.

llvm-svn: 231409
2015-03-05 21:57:35 +00:00
Toma Tabacu 18ca267d7a Recommit "[IAS] Teach -cc1as about the 'target-abi' option."
Added a REQUIRES for the Mips target.
Also, switched to using plain CHECKs, at the suggestion of Eric Christopher.

llvm-svn: 231363
2015-03-05 13:39:14 +00:00
David Majnemer 7c23707174 MS ABI: Implement support for throwing a C++ exception
Throwing a C++ exception, under the MS ABI, is implemented using three
components:
- ThrowInfo structure which contains information like CV qualifiers,
  what destructor to call and a pointer to the CatchableTypeArray.
- In a significant departure from the Itanium ABI, copying by-value
  occurs in the runtime and not at the catch site.  This means we need
  to enumerate all possible types that this exception could be caught as
  and encode the necessary information to convert from the exception
  object's type to the catch handler's type.  This includes complicated
  derived to base conversions and the execution of copy-constructors.

N.B. This implementation doesn't support the execution of a
copy-constructor from within the runtime for now.  Adding support for
that functionality is quite difficult due to things like default
argument expressions which may evaluate arbitrary code hiding in the
copy-constructor's parameters.

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

llvm-svn: 231328
2015-03-05 00:46:22 +00:00
Reid Kleckner 2a1332245f Implement section pragma feedback on r205810
Mostly short-circuits some conditionals.  Adds target validation of
sections passed to these pragmas.

llvm-svn: 231317
2015-03-04 23:39:17 +00:00
David Blaikie a4533b1016 Fix the clang self-host -Werror build
Sorry about the breakage.

llvm-svn: 231302
2015-03-04 22:15:41 +00:00
Nemanja Ivanovic 55e757db4a Add Clang support for PPC cryptography builtins
Review: http://reviews.llvm.org/D7951

llvm-svn: 231291
2015-03-04 21:48:22 +00:00
Gabor Horvath e40c71c10a [analyzer] Individual configuration options can be specified for checkers.
Reviewed by: Anna Zaks

Original patch by: Aleksei Sidorin

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

llvm-svn: 231266
2015-03-04 17:59:34 +00:00