Modules: add command line option fmodules-disable-diagnostic-validation
With PCH+Module, sometimes compiler gives a hard error:
Module file ‘<some-file path>.pcm' is out of date and needs to be rebuilt
This happens when we have a pch importing a module and the module gets
overwritten by another compiler instance after we build the pch (one example is
that both compiler instances hash to the same pcm file but use different
diagnostic options). When we try to load the pch later on, the compiler notices
that the imported module is out of date (modification date, size do not match)
but it can't handle this out of date pcm (i.e it does not know how to rebuild
the pch).
This commit introduces a new command line option so for PCH + module, we can
turn on this option and if two compiler instances only differ in diagnostic
options, the latter instance will not invalidate the original pcm.
Martin Bohme [Tue, 26 Jul 2016 15:19:10 +0000 (15:19 +0000)]
Make RecursiveASTVisitor visit lambda capture initialization expressions
Summary:
Lambda capture initializations are part of the explicit source code and therefore should be visited by default but, so far, RecursiveASTVisitor does not visit them.
This appears to be an oversight. Because the lambda body needs custom handling (calling TraverseLambdaBody()), the DEF_TRAVERSE_STMT for LambdaExpr sets ShouldVisitChildren to false but then neglects to visit the lambda capture initializations. This patch adds code to visit the expressions associated with lambda capture initializations.
Kelvin Li [Tue, 26 Jul 2016 04:32:50 +0000 (04:32 +0000)]
[OpenMP] diagnose orphaned teams construct
The OpenMP spec mandates that 'a teams construct must be contained within a
target construct'. Currently, this scenario is not diagnosed. This patch is
to add check for orphaned teams construct and issue an error message.
[Coverage] Do not write out coverage mappings with zero entries
After r275121, we stopped mapping regions from system headers. Lambdas
declared in regions belonging to system headers started producing empty
coverage mappings, since the files corresponding to their spelling locs
were being ignored.
The coverage reader doesn't know what to do with these empty mappings.
This commit makes sure that we don't produce them and adds a test. I'll
make the reader stricter in a follow-up commit.
Chris Bieneman [Mon, 25 Jul 2016 23:48:14 +0000 (23:48 +0000)]
[CMake] Pass DYLD_LIBRARY_PATH as CMake variable instead of as envar
On OS X 10.11 System Integrity Protection prevents the DYLD environment variables from being set on system binaries. To work around this r276710 accepts DYLD_LIBRARY_PATH as a CMake variable and sets it directly on the archiver commands.
To make this work with bootstrapping we need to set DYLD_LIBRARY_PATH to the current stage's library directory and pass that into the next stage's configuration.
[Sema][ObjC] Compute the nullability of a conditional expression based
on the nullabilities of its operands.
This commit is a follow-up to r276076 and enables
computeConditionalNullability to compute the merged nullability when
the operands are objective-c pointers.
Chris Bieneman [Mon, 25 Jul 2016 18:54:30 +0000 (18:54 +0000)]
[CMake] Cleaning up some CMake warnings
In Bootstrap builds Clang logs some warnings. These are caused because Clang passes CLANG_STAGE and BOOTSTRAP_DEFAULT_PASSTHROUGH into the next stage's configuration.
BOOTSTRAP_DEFAULT_PASSTHROUGH shouldn't be passed, so it is renamed to _BOOTSTRAP_DEFAULT_PASSTHROUGH, to prevent passthrough.
CLANG_STAGE should be passed, so I've changed the code to log it if it is set outside the if(CLANG_ENABLE_BOOTSTRAP) block. This makes the variable always used, so the warning goes away.
The '#pragma once' directive was erroneously ignored when encountered
in the header-file specified in generate-PCH-mode. This resulted in
compile-time errors in some cases with legal code, and also a misleading
warning being produced.
Summary:
This patch moves the MPIFunctionClassifier header to `clang/include/clang/StaticAnalyzer/Checkers`,
in order to make it accessible in other parts of the architecture.
I'm told that some optimizers like lambdas a lot more than mem_fn.
Given that the readability difference is basically nil, and we seem to
use lambdas basically everywhere else, it seems sensible to just use
lambdas.
[cxx1z-constexpr-lambda] Make a lambda's closure type eligible as a literal-type in C++1z
Additionally, for pre-C++1z, instead of forbidding a lambda's closure type from being a literal type through circumlocutorily setting HasNonLiteralTypeFieldsOrBases falsely to true -- handle lambda's more directly in CXXRecordDecl::isLiteral().
One additional small step towards implementing constexpr-lambdas.
Thanks to Richard Smith for his review!
https://reviews.llvm.org/D22662
Richard Smith [Sat, 23 Jul 2016 02:39:52 +0000 (02:39 +0000)]
Work around MSVC's lack of support for unrestricted unions by making this
struct a bit bigger under MSVC (this shouldn't be a big deal; we typically
allocate no more than two of these at a time, on the stack).
Richard Smith [Fri, 22 Jul 2016 23:36:59 +0000 (23:36 +0000)]
P0217R3: Parsing support and framework for AST representation of C++1z
decomposition declarations.
There are a couple of things in the wording that seem strange here:
decomposition declarations are permitted at namespace scope (which we partially
support here) and they are permitted as the declaration in a template (which we
reject).
[modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
Processing update records (and loading a module, in general) might trigger
unexpected calls to the ASTWriter (being a mutation listener). Now we have a
mechanism to suppress those calls to the ASTWriter but notify other possible
mutation listeners.
Add .rgba syntax extension to ext_vector_type types
Summary:
This patch enables .rgba accessors to ext_vector_type types and adds
tests for syntax validation and code generation.
'a' and 'b' can appear either in the point access mode or the numeric
access mode (for indices 10 and 11). To disambiguate between the two
usages, the accessor type is explicitly passed to relevant methods.
Anna Thomas [Fri, 22 Jul 2016 17:50:08 +0000 (17:50 +0000)]
Clang changes for overloading invariant.start and end intrinsics
This change depends on the corresponding LLVM change at:
https://reviews.llvm.org/D22519
The llvm.invariant.start and llvm.invariant.end intrinsics currently
support specifying invariant memory objects only in the default address
space.
With this LLVM change, these intrinsics are overloaded for any adddress space
for memory objects and we can use these llvm invariant intrinsics in
non-default address spaces.
Simon Pilgrim [Fri, 22 Jul 2016 13:58:56 +0000 (13:58 +0000)]
[X86][AVX] Added support for lowering to VBROADCASTF128/VBROADCASTI128 with generic IR
As discussed on D22460, I've updated the vbroadcastf128 pd256/ps256 builtins to map directly to generic IR - load+splat a 128-bit vector to both lanes of a 256-bit vector.
The updated test in r276367 expects path separators to be either '/' or
'\\', so it chokes on the unexpected "5C" stuff. I'm not sure what that
is, but I included a kludge that should work around it.
We should be able to use `mkdir` without turning on `REQUIRES: shell`.
Moreover, this test should check for a path separator which precedes the
relative filename to make sure that absolute paths are being used.
[analyzer] Add checker modeling potential C++ self-assignment
This checker checks copy and move assignment operators whether they are
protected against self-assignment. Since C++ core guidelines discourages
explicit checking for `&rhs==this` in general we take a different approach: in
top-frame analysis we branch the exploded graph for two cases, where &rhs==this
and &rhs!=this and let existing checkers (e.g. unix.Malloc) do the rest of the
work. It is important that we check all copy and move assignment operator in top
frame even if we checked them already since self-assignments may happen
undetected even in the same translation unit (e.g. using random indices for an
array what may or may not be the same).
This reapplies r275820 after fixing a string-lifetime issue discovered by the
bots.
Wolfgang Pieb [Thu, 21 Jul 2016 23:28:18 +0000 (23:28 +0000)]
Reverting r275115 which caused PR28634.
When empty (forwarding) basic blocks that are referenced by user labels
are removed, incorrect code may be generated.
David Majnemer [Thu, 21 Jul 2016 23:03:43 +0000 (23:03 +0000)]
[Sema] Handle errors during rewriteBuiltinFunctionDecl
rewriteBuiltinFunctionDecl can encounter errors when performing
DefaultFunctionArrayLvalueConversion. These errors were not handled
which led to a null pointer dereference.
Adrian McCarthy [Thu, 21 Jul 2016 13:16:14 +0000 (13:16 +0000)]
Include unreferenced nested types in member list only for CodeView
Unreferenced nested structs and classes were omitted from the debug info. In DWARF, this was intentional, to avoid bloat. But for CodeView, we want this information to be consistent with what Microsoft tools would produce and expect.
Provide __GLIBCXX_TYPE_INT_N_0 and __GLIBCXX_BITSIZE_INT_N_0 when in C++ gnu language extensions.
These are used by libstdc++ <type_traits> for is_integral<__int128>.
Addresses http://llvm.org/pr23156.
Davide Italiano [Thu, 21 Jul 2016 06:28:48 +0000 (06:28 +0000)]
[CodeGen] Handle recursion in LLVMIRGeneration Timer.
This can happen when emitting a local decl, which triggers
loading a decl imported from an AST file, which we then
hand to the AST consumer. Timer is not allowed to recurse
so an assertion fire. Keep a reference counter to avoid this
problem. LGTM'd by Richard Smith on IRC.
John McCall [Wed, 20 Jul 2016 21:02:43 +0000 (21:02 +0000)]
When copying an array into a lambda, destroy temporaries from
the copy-constructor immediately and enter a partial array
cleanup for previously-copied elements.
Kelvin Li [Wed, 20 Jul 2016 20:45:29 +0000 (20:45 +0000)]
[OpenMP] Allow negative lower bound in array sections based on pointers
OpenMP 4.5 removed the restriction that array section lower bound must be non negative.
This change is to allow negative values for array section based on pointers.
For array section based on array type there is still a restriction: "The array section must be a subset of the original array."
Yaxun Liu [Wed, 20 Jul 2016 19:21:11 +0000 (19:21 +0000)]
[OpenCL] AMDGCN target will generate images in constant address space
Allows AMDGCN target to generate images (such as %opencl.image2d_t) in constant address space.
Images will still be generated in global address space by default.
Added tests to existing opencl-types.cl in test\CodeGenOpenCL.
Richard Smith [Wed, 20 Jul 2016 19:10:16 +0000 (19:10 +0000)]
[modules] Don't emit initializers for VarDecls within a module eagerly whenever
we first touch any part of that module. Instead, defer them until the first
time that module is (transitively) imported. The initializer step for a module
then recursively initializes modules that its own headers imported.
For example, this avoids running the <iostream> global initializer in programs
that don't actually use iostreams, but do use other parts of the standard
library.
[MS] Improve VPtrInfo field names and doc comments
'ReusingBase' was a terrible name. It might actually refer to the most
derived class, which is not a base. 'BaseWithVPtr' was also bad, since
again, it could refer to the most derived class. It was actually the
first base to introduce the vptr, so now it is 'IntroducingObject'.
Simon Pilgrim [Wed, 20 Jul 2016 10:18:01 +0000 (10:18 +0000)]
[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR
D20859 and D20860 attempted to replace the SSE (V)CVTTPS2DQ and VCVTTPD2DQ truncating conversions with generic IR instead.
It turns out that the behaviour of these intrinsics is different enough from generic IR that this will cause problems, INF/NAN/out of range values are guaranteed to result in a 0x80000000 value - which plays havoc with constant folding which converts them to either zero or UNDEF. This is also an issue with the scalar implementations (which were already generic IR and what I was trying to match).
This patch changes both scalar and packed versions back to using x86-specific builtins.
It also deals with the other scalar conversion cases that are runtime rounding mode dependent and can have similar issues with constant folding.
[Sema] Compute the nullability of a conditional expression based on the
nullabilities of its operands.
This patch defines a function to compute the nullability of conditional
expressions, which enables Sema to precisely detect implicit conversions
of nullable conditional expressions to nonnull pointers.
Concepts: Create space for requires-clause in TemplateParameterList; NFC
Summary:
Space for storing the //constraint-expression// of the
//requires-clause// associated with a `TemplateParameterList` is
arranged by taking a bit out of the `NumParams` field for the purpose
of determining whether there is a //requires-clause// or not, and by
adding to the trailing objects tied to the `TemplateParameterList`. An
accessor is provided.
An appropriate argument is supplied to `TemplateParameterList::Create`
at the various call sites.
Serialization changes will addressed as the Concepts implementation
becomes more solid.
Drive-by fix:
This change also replaces the custom
`FixedSizeTemplateParameterListStorage` implementation with one that
follows the interface provided by `llvm::TrailingObjects`.
[SemaObjC] Improve ObjCDictionaryLiteral and ObjCArryLiteral diagnostics
Sema actions on ObjCDictionaryLiteral and ObjCArryLiteral are currently
done as a side-effect of Sema upon parent expressions, which incurs of
delayed typo corrections for such literals to be performed by TypoTransforms
upon the ObjCDictionaryLiteral and ObjCArryLiteral themselves instead of
its elements individually.
This is specially bad because it was not designed to act on several
elements; searching through all possible combinations of corrections for
several elements is very expensive. Additionally, when one of the
elements has no correction candidate, we still explore all options and
at the end emit no typo corrections whatsoever.
Do the proper sema actions by acting on each element alone during appropriate
literal parsing time to get proper diagonistics and decent compile time
behavior.
Yaxun Liu [Tue, 19 Jul 2016 19:39:45 +0000 (19:39 +0000)]
[OpenCL] Fixes bug of missing OCL version metadata on the AMDGCN target
Added the opencl.ocl.version metadata to be emitted with amdgcn. Created a static function emitOCLVerMD which is shared between triple spir and target amdgcn.
Also added new testcases to existing test file, spir_version.cl inside test/CodeGenOpenCL.
It's a patch for PR28050. Seems like overloading resolution wipes out
the first standard conversion sequence (before user-defined conversion)
in case of deprecated string literal conversion.
Kelvin Li [Mon, 18 Jul 2016 22:49:16 +0000 (22:49 +0000)]
[OpenMP] Fix incorrect diagnostics in map clause
Having the following code pattern will result in incorrect diagnostic
int main() {
int arr[10];
#pragma omp target data map(arr[:])
#pragma omp target map(arr)
{}
}
t.cpp:4:24: error: original storage of expression in data environment is shared
but data environment do not fully contain mapped expression storage
#pragma omp target map(arr)
^~~
t.cpp:3:29: note: used here
#pragma omp target data map(arr[:])
^~~~~~
1 error generated.
This fixes the issue of having duplicate entries for the same file in a
coverage report s.t none of the entries actually displayed the correct
coverage information.
[Sema] Create a separate group for incompatible function pointer warning
Give incompatible function pointer warning its own diagnostic group
but still leave it as a subgroup of incompatible-pointer-types. This is in
preparation to promote -Wincompatible-function-pointer-types to error on
darwin.
[Driver] Compute effective target triples once per job (NFCI)
Compute an effective target triple exactly once in ConstructJob(), and
then simply pass around references to it. This eliminates wasteful
re-computation of effective triples (e.g in getARMFloatABI()).
For assembly files without .intel_syntax or .att_syntax directives, allow the
-masm= flag to supply a default assembly dialect. For example,
C:\TMP> type intel.s
.text
mov al,0
C:\TMP> clang -masm=intel -c intel.s
Without this patch, one would need to pass an "-mllvm -x86-asm-syntax=" flag
directly to the backend.
C:\TMP> clang -mllvm --x86-asm-syntax=intel -c intel.s
[analyzer] Add checker modeling potential C++ self-assignment
This checker checks copy and move assignment operators whether they are
protected against self-assignment. Since C++ core guidelines discourages
explicit checking for `&rhs==this` in general we take a different approach: in
top-frame analysis we branch the exploded graph for two cases, where &rhs==this
and &rhs!=this and let existing checkers (e.g. unix.Malloc) do the rest of the
work. It is important that we check all copy and move assignment operator in top
frame even if we checked them already since self-assignments may happen
undetected even in the same translation unit (e.g. using random indices for an
array what may or may not be the same).
Kelvin Li [Mon, 18 Jul 2016 16:09:53 +0000 (16:09 +0000)]
[OpenMP] update test cases for -std=c++11 compile
target_parallel_for_simd_collapse_messages.cpp and target_parallel_for_simd_ordered_messages.cpp give different diagnostic messages in compiling with -std=c++11. The test cases are updated to make it compatible.