Richard Smith [Tue, 8 Dec 2015 03:21:47 +0000 (03:21 +0000)]
Explicitly permit undefined behavior in constant initializers for global
variables in C, in the cases where we can constant-fold it to a value
regardless (such as floating-point division by zero and signed integer
overflow). Strictly enforcing this rule breaks too much code.
Reid Kleckner [Tue, 8 Dec 2015 01:08:09 +0000 (01:08 +0000)]
[diagnostics] Avoid crashes while printing macro backtraces
When attempting to map a source into a given level of macro expansion,
this code was ignoring the possibility that the start and end of the
range might take wildly different paths through the tree of macro
expansions. It was assuming that the begin spelling location would
always precede the end spelling location, which is false. A macro can
easily transpose its arguments.
This also fixes a related issue where there are extra macro arguments
between the begin location and the end location. In this situation, we
now highlight the entire macro invocation.
Devin Coughlin [Mon, 7 Dec 2015 23:01:53 +0000 (23:01 +0000)]
[analyzer] Fix crash when lambda captures a variable-length array.
When a C++ lambda captures a variable-length array, it creates a capture
field to store the size of the array. The initialization expression for this
capture is null, which led the analyzer to crash when initializing the field.
To avoid this, use the size expression from the VLA type to determine the
initialization value.
Teresa Johnson [Mon, 7 Dec 2015 20:40:36 +0000 (20:40 +0000)]
Remove target specifier from new tests
Hopefully fix the remaining bot failure from r254927. Remove
target specification since it shouldn't be needed, and this causes
an error when trying to check the pass execution structure in
test/CodeGen/thinlto_backend.c on non-x86 arches.
Justin Bogner [Mon, 7 Dec 2015 20:04:57 +0000 (20:04 +0000)]
AST: defer to TypeLoc::copy in TypeLoc::initializeFullCopy
If we're initializing a TypeLoc from one that's been allocated with
different alignment, memcpy will get the padding wrong. The `copy`
method already checks and handles this case, so we should just defer
to it.
This also drops the `const` off of the `initializeFullCopy`
declarations, since it isn't even remotely true (and the compiler
notices when we try to call copy() instead of tricking it with
memcpy).
Teresa Johnson [Mon, 7 Dec 2015 19:21:34 +0000 (19:21 +0000)]
[ThinLTO] Option to invoke ThinLTO backend passes and importing
Summary:
Adds new option -fthinlto-index=<file> to invoke the LTO pipeline
along with function importing via clang using the supplied function
summary index file. This supports invoking the parallel ThinLTO
backend processes in a distributed build environment via clang.
Additionally, this causes the module linker to be invoked on the bitcode
file being compiled to perform any necessary promotion and renaming of
locals that are exported via the function summary index file.
Add a couple tests that confirm we get expected errors when we try to
use the new option on a file that isn't bitcode, or specify an invalid
index file. The tests also confirm that we trigger the expected function
import pass.
Alexey Bataev [Mon, 7 Dec 2015 12:52:51 +0000 (12:52 +0000)]
[OPENMP 4.5] parsing/sema support for 'grainsize' clause.
OpenMP 4.5 adds 'taksloop' and 'taskloop simd' directives, which have 'grainsize' clause. Patch adds parsing/sema analysis of this clause.
Alexey Bataev [Mon, 7 Dec 2015 10:51:44 +0000 (10:51 +0000)]
[OPENMP 4.5] parsing/sema support for 'nogroup' clause.
OpenMP 4.5 adds 'taskloop' and 'taskloop simd' directives. These directives have new 'nogroup' clause. Patch adds basic parsing/sema support for this clause.
Faisal Vali [Mon, 7 Dec 2015 02:37:44 +0000 (02:37 +0000)]
Fix PR20334: invalid assertion while diagnosing list initialization failure
https://llvm.org/bugs/show_bug.cgi?id=20334
Unfortunately, clang currently checks for a certain brokenness of implementations of std::initializer_list in CodeGen (void
AggExprEmitter::VisitCXXStdInitializerListExpr), not in SemaInit. Until that is fixed, make sure we don't let broken attempts that are aggregates leak through into sema, which allows maintenance of expected invariants, and avoids triggering an assertion.
Serge Pavlov [Sun, 6 Dec 2015 14:32:39 +0000 (14:32 +0000)]
[PGO] Instrument only base constructors and destructors.
Constructors and destructors may be represented by several functions
in IR. Only base structors correspond to source code, others are
small pieces of code and eventually call the base variant. In this
case instrumentation of non-base structors has little sense, this
fix remove it. Now profile data of a declaration corresponds to
exactly one function in IR, it agrees with the current logic of the
profile data loading.
Simon Pilgrim [Sat, 5 Dec 2015 11:12:23 +0000 (11:12 +0000)]
[X86][3DNow!] Stripped backend codegen tests
As discussed on the ml, backend tests need to be put in llvm/test/CodeGen/X86 as fast-isel tests using IR that is as close to what is generated here as possible.
Simon Pilgrim [Sat, 5 Dec 2015 10:37:35 +0000 (10:37 +0000)]
[X86][F16C] Stripped backend codegen tests
As discussed on the ml, backend tests need to be put in llvm/test/CodeGen/X86 as fast-isel tests using IR that is as close to what is generated here as possible.
Craig Topper [Sat, 5 Dec 2015 07:41:44 +0000 (07:41 +0000)]
[AST] Use std::copy and std::fill to simplify some memcpy and memset calls. Also const-correct some methods being used since the std::copy catches the mismatch where memcpy didn't.
Reid Kleckner [Sat, 5 Dec 2015 01:52:14 +0000 (01:52 +0000)]
Revert "[x86] Exclusion of incorrect include headers paths for MCU target"
This reverts commit r254195.
From the description, I suspect that the wrong patch was committed here,
and this is causing assertion failures in EmitDeferred() when the global
value ends up being a bitcast of a global.
Devin Coughlin [Sat, 5 Dec 2015 00:22:36 +0000 (00:22 +0000)]
[analyzer] Fix MemRegion crash casting non-struct to derived struct (PR25426).
This commit prevents MemRegion::getAsOffset() from crashing when the analyzed
program casts a symbolic region of a non-record type to some derived type and
then attempts to access a field of the base type.
Nico Weber [Fri, 4 Dec 2015 19:14:14 +0000 (19:14 +0000)]
Fix debug info for Objective-C properties from class extensions after r251874
After r251874, properties from class extensions no longer show up in
ObjCInterfaceDecl::properties(). Make debug info emission explicitly
look for properties in class extensions before looking at direct properties.
Also add a test that checks for this. There are three interesting cases:
1. A property is only declared in a class extension, and the @implementation
is in a different file. This used to generated a DIObjcProperty before
r251874 and does again with this fix.
2. A property is declared as readonly in the class itself and redeclared as
readwrite in a class extension. clang before r251874 put the DIObjcProperty
on the first declaration. clang after r251874 didn't emit any DIObjcProperty,
and clang with this fix puts it on the readwrite redeclaration (which is
what lookup finds). This seems like a progression.
3. Like 2, but with an @implementation in the same file. In this case,
the property debug info gets generated a second time through the ivar
from the definition. In this case, lookup and declaration code need
to agree on the line number so that the DIObjcProperty isn't emitted
twice. In this case, clang before r251874 emitted one DIObjcProperty
on the first declaration, clang with r251874 emitted one on the second
declaration, and clang with this patch still does the latter.
Alexey Samsonov [Fri, 4 Dec 2015 17:30:29 +0000 (17:30 +0000)]
Clang documentation for UBSan.
Summary:
Create a separate page describing UBSan tool, move the description of
fine-grained checks there, provide extra information about supported
platforms, symbolization etc. This text is compiled from four parts:
* Existing documentation copied from User's Manual
* Layout used in documentation for another sanitizers (ASan, MSan etc.)
* Text written from scratch
* Small parts taken from Michael Morrison's attempt at creating UBSan
page:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20141215/249503.html
Devin Coughlin [Fri, 4 Dec 2015 05:00:36 +0000 (05:00 +0000)]
[analyzer] Support inlining lambda-converted blocks.
clang converts C++ lambdas to blocks with an implicit user-defined conversion
operator method on the lambda record. This method returns a block that captures a copy
of the lambda. To inline a lambda-converted block, the analyzer now calls the lambda
records's call operator method on the lambda captured by the block.
Richard Smith [Fri, 4 Dec 2015 03:00:44 +0000 (03:00 +0000)]
Don't assert if evaluation of an expression that we're syntactically required
to treat as an ICE results in undefined behavior. Instead, return the "natural"
result of the operation (signed wraparound / inf / nan).
Stephen Hines [Fri, 4 Dec 2015 01:39:30 +0000 (01:39 +0000)]
LLDB JIT needs android vector passing rules.
Summary:
Looking into some recent issues with LLDBs expression parser highlighted that upstream clang passes vectors types differently to Android Open Source Project's clang for Arm Android targets.
This patch reflects the changes present in the AOSP and allows LLDB's JIT expression evaluation to work correctly for Arm Android targets when passing vectors.
This is submitted with consent of the original author Stephen Hines.
Richard Smith [Thu, 3 Dec 2015 23:24:04 +0000 (23:24 +0000)]
PR25731: namespace alias declarations can appear at block scope; ensure that we
do scope-based lookup when looking for redeclarations of them. Add some related
missing checks for the scope-based redeclaration lookup: properly filter the
list of found declarations to match the scope, and diagnose shadowing of a
template parameter name.
The tests were failing because the types of some member functions, when
printed, unexpectedly had "__attribute__((thiscall))" at the end. The
types in question were relatively unimportant to begin with, so they
were removed/replaced with regexes.
The introduction of pass_object_size fixed a few bugs related to taking
the address of a function with enable_if attributes. This patch adds
tests for the cases that were fixed.
Devin Coughlin [Thu, 3 Dec 2015 19:41:24 +0000 (19:41 +0000)]
[analyzer] Suppress stack address escape on CK_CopyAndAutoreleaseBlockObject.
Don't warn about addresses of stack-allocated blocks escaping if the block
region was cast with CK_CopyAndAutoreleaseBlockObject. These casts, which
are introduced in the implicit conversion operator for lambda-to-block
conversions, cause the block to be copied to the heap -- so the warning is
spurious.
These additions were meant to go in as a part of r254554; while it's
certainly nice to have new functionality, it's nicer if we have tests to
go with it. :)
Nico Weber [Thu, 3 Dec 2015 17:44:51 +0000 (17:44 +0000)]
Fix Objective-C metadata for properties from class extensions after r251874
After, properties from class extensions no longer show up in
ObjCInterfaceDecl::properties(). Make ObjCCommonMac::EmitPropertyList()
explicitly look for properties in class extensions before looking at
direct properties.
Also add a test that passes both with clang before r251874 and after this
patch (but fails with r251874 and without this patch).
Nico Weber [Thu, 3 Dec 2015 15:40:23 +0000 (15:40 +0000)]
Make check-clang depend on LTO.
r249143 added test/Driver/darwin-ld-lto.c which requires libLTO.dylib
to pass, but when running `ninja check-clang` in a fresh build directory
nothing caused libLTO.dylib to be built and the test would fail.
Revert "Fix for merging decls in pragma weak Calling CheckFunctionDeclaration so that 2 decls for the 'weak' are merged. Differential Revision: http://reviews.llvm.org/D13048"
This reverts commit r254143 which introduces a crash on the following input:
f(char *);
g(char *);
#pragma weak f = g
int g(char *p) {}
Alexey Bataev [Thu, 3 Dec 2015 09:34:49 +0000 (09:34 +0000)]
PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type, patch by D. Polukhin
This CL is for discussion how to better fix bit-filed layout compatibility issue with GCC (see PR25575 for test case and more details). Current clang behavior is compatible with GCC 4.1-4.3 series but it was fixed in 4.4+. Ignoring packed attribute looks very odd and because it was also fixed in GCC 4.4+, it makes sense also fix it in clang.
Differential Revision: http://reviews.llvm.org/D14872
Simon Pilgrim [Thu, 3 Dec 2015 08:45:21 +0000 (08:45 +0000)]
[X86] Stripped backend codegen tests
As discussed on the ml, backend tests need to be put in llvm/test/CodeGen/X86 as fast-isel tests using IR that is as close to what is generated here as possible.
Richard Smith [Thu, 3 Dec 2015 01:36:22 +0000 (01:36 +0000)]
PR17381: Treat undefined behavior during expression evaluation as an unmodeled
side-effect, so that we don't allow speculative evaluation of such expressions
during code generation.
This caused a diagnostic quality regression, so fix constant expression
diagnostics to prefer either the first "can't be constant folded" diagnostic or
the first "not a constant expression" diagnostic depending on the kind of
evaluation we're doing. This was always the intent, but didn't quite work
correctly before.
This results in certain initializers that used to be constant initializers to
no longer be; in particular, things like:
float f = 1e100;
are no longer accepted in C. This seems appropriate, as such constructs would
lead to code being executed if sanitizers are enabled.
This patch is a fix to r252901 which changed the behavior of
clang driver. In the presence of "-nostdlib" none of the standard
libraries should be passed to link line.
Samuel Antao [Wed, 2 Dec 2015 17:44:43 +0000 (17:44 +0000)]
[OpenMP] Update target directive codegen to use 4.5 implicit data mappings.
Summary:
This patch implements the 4.5 specification for the implicit data maps. OpenMP 4.5 specification changes the default way data is captured into a target region. All the non-aggregate kinds are passed by value by default. This required activating the capturing by value during SEMA for the target region. All the non-aggregate values that can be encoded in the size of a pointer are properly casted and forwarded to the runtime library. On top of fixing the previous weird behavior for mapping pointers in nested data regions (an explicit map was always required), this also improves performance as the number of allocations/transactions to the device per non-aggregate map are reduced from two to only one - instead of passing a reference and the value, only the value passed.
Explicit maps will be added later on once firstprivate, private, and map clauses' SEMA and parsing are available.
Aaron Ballman [Wed, 2 Dec 2015 15:05:47 +0000 (15:05 +0000)]
Amending r254423 by deleting the copy constructor and adding a move constructor instead; NFC as neither of these constructors are currently called, but this is a safer design.
Alexey Bataev [Tue, 1 Dec 2015 10:17:31 +0000 (10:17 +0000)]
[OPENMP 4.5] Parsing/sema analysis for 'priority' clause.
OpenMP 4.5 defines new clause 'priority' for 'task', 'taskloop' and 'taskloop simd' directives. Added parsing and sema analysis for 'priority' clause in 'task' and 'taskloop' directives.
Craig Topper [Tue, 1 Dec 2015 07:12:59 +0000 (07:12 +0000)]
[X86] Improve codegen for AVX2 gather with an all 1s mask.
Use undefined instead of setzero as the pass through input since its going to be fully overwritten. Use cmpeq of two zero vectors to produce the all 1s vector. Casting -1 to a double and vectorizing causes a constant load of a -1.0 floating point value.
Richard Smith [Tue, 1 Dec 2015 01:10:48 +0000 (01:10 +0000)]
Fix use-after-free when a C++ thread_local variable gets replaced (because its
type changes when the initializer is attached). Don't hold onto the
GlobalVariable*; recompute it from the VarDecl* instead.