Commit Graph

57326 Commits

Author SHA1 Message Date
Reid Kleckner bba3cb95cc MS ABI: Delay default constructor closure checking until the outermost class scope ends
Previously, we would error out on this code because the default argument
wasn't parsed until the end of Outer:

  struct __declspec(dllexport) Outer {
    struct __declspec(dllexport) Inner {
      Inner(void *p = 0);
    };
  };

Now we do the checking on the closing brace of Outer instead of Inner.

llvm-svn: 232519
2015-03-17 19:00:50 +00:00
Dmitri Gribenko 7fe22f66d0 Comment parsing: move a diagnostic to the correct group.
Based on a patch by LE GARREC Vincent.

llvm-svn: 232511
2015-03-17 18:03:42 +00:00
Hans Wennborg f9d865b059 Revert r232454 and r232456: "Fix the LLVM type used when lowering initializer list reference temporaries to global variables."
This caused PR22940.

llvm-svn: 232496
2015-03-17 16:38:58 +00:00
Renato Golin e11531f7ea [ARM] Add support for ARMV6K subtarget (Clang)
ARMv6K is another layer between ARMV6 and ARMV6T2. This is the Clang
side of the changes.

ARMV6 family LLVM implementation.

+-------------------------------------+
| ARMV6                               |
+----------------+--------------------+
| ARMV6M (thumb) | ARMV6K (arm,thumb) | <- From ARMV6K and ARMV6M processors
+----------------+--------------------+    have support for hint instructions
| ARMV6T2 (arm,thumb,thumb2)          |    (SEV/WFE/WFI/NOP/YIELD). They can
+-------------------------------------+    be either real or default to NOP.
| ARMV7 (arm,thumb,thumb2)            |    The two processors also use
+-------------------------------------+    different encoding for them.

Patch by Vinicius Tinti.

llvm-svn: 232469
2015-03-17 11:55:43 +00:00
Yaron Keren 1ee89fc432 Teach Twine to support SmallString.
Enable removing .str() member calls for these frequent cases. 

 http://reviews.llvm.org/D6372

llvm-svn: 232465
2015-03-17 09:51:17 +00:00
Nick Lewycky 563dfdb111 Fix test in release mode.
llvm-svn: 232456
2015-03-17 02:31:46 +00:00
Richard Smith 15e32fd215 [modules] Fix bug where an anonymous namespace could cause the containing
namespace to not merge properly.

We have an invariant here: after a declaration reads its canonical declaration,
it can assume the canonical declaration is fully merged. This invariant can be
violated if deserializing some declaration triggers the deserialization of a
later declaration, because that later declaration can in turn deserialize a
redeclaration of that first declaration before it is fully merged.

The anonymous namespace for a namespace gets stored with the first declaration
of that namespace, which may be before its parent namespace, so defer loading
it until after we've finished merging the surrounding namespace.

llvm-svn: 232455
2015-03-17 02:23:11 +00:00
Nick Lewycky cf191adaf5 Fix the LLVM type used when lowering initializer list reference temporaries to global variables.
llvm-svn: 232454
2015-03-17 02:21:31 +00:00
Duncan P. N. Exon Smith a7fd07f3fc CodeGenCXX: Test that linetables work with variadic virtual thunks
Add a frontend test for PR22929, which was fixed by LLVM r232449.
Besides the crash test, check that the `!dbg` attachment is sane since
its presence was the trigger.

llvm-svn: 232450
2015-03-17 01:19:01 +00:00
Justin Bogner c0a4b59c2f Fix typo in previous commit
llvm-svn: 232440
2015-03-17 00:04:57 +00:00
Justin Bogner 4e46237c6d GCOV: Expose the -coverage-exit-block-before-body flag in clang -cc1
This exposes the optional exit block placement logic from r232438 as a
clang -cc1 option. There is a test on the llvm side, but there isn't
really a way to inspect the gcov options from clang to test it here as
well.

llvm-svn: 232439
2015-03-16 23:52:21 +00:00
Rafael Espindola 55cfaa2552 Update for llvm API change.
llvm-svn: 232430
2015-03-16 22:30:13 +00:00
Richard Trieu a1877598aa Take the non-reference type when constructing a dummy expression.
Otherwise, Expr will assert during construction with a reference type.

llvm-svn: 232425
2015-03-16 21:49:43 +00:00
Richard Smith e687bf83c0 [modules] If we find more formerly-canonical declarations of an entity while
building its redecl chains, make sure we pull in the redeclarations of those
canonical declarations.

It's pretty difficult to reach a situation where we can find more canonical
declarations of an entity while building its redecl chains; I think the
provided testcase (4 modules and 7 declarations) cannot be reduced further.

llvm-svn: 232411
2015-03-16 20:54:07 +00:00
Richard Smith 2095ffea41 Lambdaify some helper functions. No functionality change.
llvm-svn: 232407
2015-03-16 20:11:03 +00:00
Joerg Sonnenberger 1d3b431c98 Global inline assembler blocks are merged before parsing, so no specific
location data is available. If pragma handling wants to look up the
position, it finds the LLVM buffer and wants to compare it with the
special built-in buffer, failing badly. Extend to the special handling
of the built-in buffer to also check for the inline asm buffer. Expect
only a single asm buffer. Sort it between the built-in buffers and the
normal file buffers.

Fixes the assert part of PR 22576.

llvm-svn: 232389
2015-03-16 17:54:54 +00:00
Gabor Horvath 98bd098205 [clang] Replacing asserts with static_asserts where appropriate
Summary: This patch consists of the suggestions of clang-tidy/misc-static-assert check.

Reviewers: alexfh

Subscribers: dblaikie, xazax.hun, cfe-commits

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

Patch by Szabolcs Sipos!

llvm-svn: 232367
2015-03-16 09:59:54 +00:00
Alexander Musman 7931b98735 [OPENMP] Enable codegen of the ‘private’ clause for ‘omp simd’ directive
llvm-svn: 232353
2015-03-16 07:14:41 +00:00
Benjamin Kramer 6eb776547e SimpleArray: Provide reverse iteration via std::reverse_iterator.
NFC intended.

llvm-svn: 232330
2015-03-15 18:47:26 +00:00
Benjamin Kramer 15b9717873 Implement PreprocessingRecord's and LazyVector's iterators on top of iterator_adaptor_base
This basically creates a wrapper around an 'int' that poses as an iterator.
While that looks a bit counter-intuitive it works just fine because iterator
operations and basic integer arithmetic works in exactly the same way.

Remove the manual integer wrapping code and reduce the reliance on iterator
internals in the implementation. No functionality change intended.

llvm-svn: 232322
2015-03-15 15:27:19 +00:00
Daniel Jasper bc46b939e6 clang-format: [JS] support cast syntax and type arguments.
Casts in TS syntax (foo = <type>bar;) should not be followed by
whitespace.

Patch by Martin Probst. Thank you.

llvm-svn: 232321
2015-03-15 13:59:51 +00:00
Daniel Jasper 60948b12bb clang-format: [JS] more precisely detect enums.
The current enum detection is overly aggressive. As NestingLevel only
applies per line (?) it classifies many if not most object literals as
enum declarations and adds superfluous line breaks into them. This
change narrows the heuristic by requiring an assignment just before the
open brace and requiring the line to start with an identifier.

Patch by Martin Probst. Thank you.

llvm-svn: 232320
2015-03-15 13:55:54 +00:00
David Majnemer ad803d4b76 MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptors
Qualifiers are located next to the TypeDescriptor in order to properly
ensure that a pointer type can only be caught by a more qualified catch
handler.  This means that a catch handler of type 'const int *' requires
an RTTI object for 'int *'.  We got this correct for 'throw' but not for
'catch'.

N.B.  We don't currently have the means to store the qualifiers because
LLVM's EH strategy is tailored to the Itanium scheme.  The Itanium ABI
stores qualifiers inside the type descriptor in such a way that the
manner of qualification is stored in addition to the pointee type's
descriptor.  Perhaps the best way of modeling this for the MS ABI is
using an aggregate type to bundle the qualifiers with the descriptor?
This is tricky because we want to make it clear to the optimization
passes which catch handlers invalidate other handlers.

My current thoughts on a design for this is along the lines of:
  { { TypeDescriptor* TD, i32 QualifierFlags }, i32 MiscFlags }

The idea is that the inner most aggregate is all that is needed to
communicate that one catch handler might supercede another.  The
'MiscFlags' field would be used to hold the bitpattern for the notion
that the 'catch' handler does not need to invoke a copy-constructor
because we are catching by reference.

llvm-svn: 232318
2015-03-15 07:10:01 +00:00
Dmitri Gribenko ad80af8f19 -Wempty-body: fix false negative triggered by macros
When if statement condition ended in a macro:

    if (ptr == NULL);

the check used to consider the definition location of NULL, instead of the
current line.

Patch by Manasij Mukherjee.

llvm-svn: 232295
2015-03-15 01:08:23 +00:00
David Majnemer 9ced3dd64c MS ABI: Tidy up references to the ASTContext
CGCXXABI has a handy getContext() method.  Use that instead of
explicitly going through the CodeGenModule.

llvm-svn: 232289
2015-03-14 23:44:48 +00:00
David Majnemer 8062eb6bed CodeGen: Correctly initialize bitfields with non-constant initializers
It is possible to construct an initializer for a bitfield which is not
constant.  Instead of emitting code to initialize the field before the
execution of main, clang would crash.

llvm-svn: 232285
2015-03-14 22:24:38 +00:00
Benjamin Kramer 0eb262fb28 Sort ObjCProtocolDecls with array_pod_sort.
The predicate is essentially a string comparison. NFC.

llvm-svn: 232264
2015-03-14 13:32:49 +00:00
Benjamin Kramer 5caa50e469 [analyzer] Sort path diagnostics with array_pod_sort.
They're expensive to compare and we won't sort many of them so std::sort
doesn't give any benefits and causes code bloat. Func fact: clang -O3 didn't
even bother to inline libc++'s std::sort here.

While there validate the predicate a bit harder, the sort is unstable and we
don't want to introduce any non-determinism. I had to spell out the function
pointer type because GCC 4.7 still fails to convert the lambda to a function
pointer :(

No intended functionality change.

llvm-svn: 232263
2015-03-14 12:39:22 +00:00
David Majnemer bc02d32f4d MS ABI: Mangle virtual member pointer thunks with the correct CC
Virtual member pointers are implemented using a thunk.  We assumed that
the calling convention for this thunk was always __thiscall for 32-bit
targets and __cdecl for 64-bit targets.  However, this is not the case.
Mangle in whichever calling convention is appropriate for this member
function thunk.

llvm-svn: 232254
2015-03-14 06:34:41 +00:00
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
Ahmed Bougacha 5a4aa42a59 Add a bunch of missing "CHECK" colons in tests. NFC.
llvm-svn: 232237
2015-03-14 01:10:19 +00:00
David Majnemer 37fd66e78b MS ABI: Generate default constructor closures
The MS ABI utilizes a compiler generated function called the "vector
constructor iterator" to construct arrays of objects with
non-trivial constructors/destructors.  For this to work, the constructor
must follow a specific calling convention.  A thunk must be created if
the default constructor has default arguments, is variadic or is
otherwise incompatible.  This thunk is called the default constructor
closure.

N.B.  Default constructor closures are only generated if the default
constructor is exported because clang itself does not utilize vector
constructor iterators.  Failing to export the default constructor
closure will result in link/load failure if a translation unit compiled
with MSVC is on the import side.

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

llvm-svn: 232229
2015-03-13 22:36:55 +00:00
Robert Lougher 7607b918a7 Make tests more robust. No functional change.
In preparation for recommit of revision 232190, change tests so that they
are resilient to operands being commuted by the reassociate pass.

llvm-svn: 232206
2015-03-13 20:35:45 +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
David Blaikie bdf40a62a7 Test case updates for explicit type parameter to the gep operator
llvm-svn: 232187
2015-03-13 18:21:46 +00:00
David Blaikie 81e96f8192 Update test case to make it easier to automatically port to typeless pointer gep operator changes coming soon
llvm-svn: 232185
2015-03-13 18:21:11 +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
Daniel Jasper 0ab544f1a5 When building a module, all headers of submodules can be used.
This extends r232159.

llvm-svn: 232168
2015-03-13 14:29:39 +00:00
Daniel Jasper 9ecb0e96b8 clang-format: Don't corrupt macros with open braces.
Formatting:
  #define A { {
  #define B } }

Before:
  #define A               \
    {                     \
      { #define B }       \
    }

After:
  #define A               \
    {                     \
      {
  #define B               \
    }                     \
    }

This fixes llvm.org/PR22884.

llvm-svn: 232166
2015-03-13 13:32:11 +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
Daniel Jasper b6ba46ef30 Make a module "use" also count as use of all its submodules
llvm-svn: 232159
2015-03-13 11:26:16 +00:00
Alexander Musman 21212e4198 [OPENMP] Re-factor __kmpc_for_static_init_* routine generation.
llvm-svn: 232154
2015-03-13 10:38:23 +00:00
Chandler Carruth c2132d8f33 [Modules] Teach Clang to survive ambiguous macros which come from system
headers even if they arrived when merging non-system modules.

The idea of this code is that we don't want to warn the user about
macros defined multiple times by their system headers with slightly
different definitions. We should have this behavior if either the
macro comes from a system module, or the definition within the module
comes from a system header. Previously, we would warn on ambiguous
macros being merged when they came from a users modules even though they
only showed up via system headers.

By surviving this we can handle common system header macro differences
like differing 'const' qualification of pointers due to some headers
predating 'const' being valid in C code, even when those systems headers
are pre-built into a system module.

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

llvm-svn: 232149
2015-03-13 08:29:54 +00:00
Argyrios Kyrtzidis ee1d76f361 [libclang] Fix crash when code-completing inside constructor initializer for a builtin type.
rdar://20149746

llvm-svn: 232145
2015-03-13 07:39:30 +00:00
Argyrios Kyrtzidis 58d0e7ab79 [libclang] During member ref expression visitation, ignore base anonymous struct/union fields.
Otherwise they will shadow the real field that that we are interested in.

rdar://19783938

llvm-svn: 232141
2015-03-13 04:40:07 +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
Joerg Sonnenberger dfd511e9bc Simplify.
llvm-svn: 232130
2015-03-13 00:54:30 +00:00
NAKAMURA Takumi 08b87a8c42 [CMake] Add clangBasic in ASTMatchersTests, according to r232051.
Jan Vesely noticed it. See also r232055.

llvm-svn: 232123
2015-03-12 23:49:06 +00:00
Benjamin Kramer 7f1f6b5370 Disambiguate call for GCC.
llvm-svn: 232122
2015-03-12 23:46:55 +00:00