Samuel Antao [Sun, 8 May 2016 06:43:56 +0000 (06:43 +0000)]
[OpenMP] Check for associated statements with hasAssociatedStmt() when scanning for device code.
Summary: `getAssociatedStmt()` contains an assertion that assumes the statement always exists. In device code scanning, we need to look into the associated statement therefore we check its existence. This patch replaces `getAssociatedStmt` by `hasAssociatedStmt` so that we do not trigger the assertion for directives that happen not to have an associated statement (e.g target enter/exit data).
[CrashReproducer] Always use realpath for destination
When running reproducer scripts we need that original symlinks from the
source filesystem are reproduced in the VFS so that different virtual
paths can map to the same file, allowing the FileManager to share the
same UID between these virtual entries. This avoids all sorts of module
redefinition errors when using frameworks.
Use a StringRef instead of a FileEntry in the moduleMapAddHeader
callback to allow more flexibility on what to collect on further
patches. This changes the interface I introduced in r264971.
Richard Smith [Fri, 6 May 2016 23:14:07 +0000 (23:14 +0000)]
[modules] Attempt to improve performance for declaration merging without a Sema
object in C. Rather than using the DeclContext (which is very slow because it
triggers us to build a lookup table for the DeclContext), use a separate map
from identifiers to decls for this case, containing only the ones we've
actually deserialized. For convenience, this map is implemented as an
IdentifierResolver.
Manman Ren [Fri, 6 May 2016 19:57:16 +0000 (19:57 +0000)]
Availability: attach the note to the declaration with the attributes.
Sometimes, the declaration we found has inherited availability
attributes, attaching the note to it does not tell us where the
availability attributes are in the source.
Go through the redecl chain to find the declaration with actual
availability attributes.
Replace use of /dev/null with /var/empty. lit will substitute the /dev/null
include path resulting in failures. Use a path under /var/empty which is
supposed to be empty to ensure that we can successfully test.
-I dir
... If dir begins with =, then the = will be replaced by the sysroot prefix;
see --sysroot and -isysroot.
Add support to expand the `=` as a prefix of the include path with the sysroot
if specified. `-isysroot` takes precedence over `--sysroot` as the normal
argument behaviour occurs. The ordering of the `-isysroot` is relevant to the
path substituted. If no `--sysroot=` or `-isysroot` option is present, the = is
not expanded.
Ben Craig [Fri, 6 May 2016 13:29:46 +0000 (13:29 +0000)]
Adding omitted column to invalid loc diagnostic.
note_fe_backend_invalid_loc expects three arguments (file, line, column),
and will assert when only given two. The other two places in this file that
use note_fe_backend_invalid_loc already supply the Column for the third
parameter.
Alexey Bataev [Fri, 6 May 2016 09:40:08 +0000 (09:40 +0000)]
[OPENMP 4.0] Codegen for 'declare simd' directive.
OpenMP 4.0 adds support for elemental functions using declarative
directive '#pragma omp declare simd'. Patch adds mangling for simd
functions in accordance with
https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt
Akira Hatanaka [Thu, 5 May 2016 01:41:07 +0000 (01:41 +0000)]
Do not add uwtable attribute by default for MachO targets.
r217178 changed clang to add function attribute uwtable by default on
Win64, which caused the __eh_frame section to be emitted by default.
This commit restores the previous behavior for MachO targets.
Richard Smith [Thu, 5 May 2016 00:56:12 +0000 (00:56 +0000)]
[modules] Enforce the rules that an explicit or partial specialization must be
declared before it is used. Because we don't use normal name lookup to find
these, the normal code to filter out non-visible names from name lookup results
does not apply.
Fix the doc extraction script to work with hasAnyName and with equalsNode.
The change from llvm::VariadicFunction to internal::VariadicFunction
broke the extraction of hasAnyName().
equalsNode was broken because the argument type is 'const XXXX*' and
the internal space caused a failure on the regex.
Akira Hatanaka [Wed, 4 May 2016 18:07:20 +0000 (18:07 +0000)]
[ObjC] Enter a new evaluation context before calling
BuildBlockForLambdaConversion.
Previously, clang would build an incorrect AST for the following code:
id test() {
return @{@"a": [](){}, @"b": [](){}};
}
ReturnStmt 0x10d080448
`-ExprWithCleanups 0x10d080428
|-cleanup Block 0x10d0801f0 // points to the second BlockDecl
...
-BlockDecl 0x10d07f150 // First block
...
-BlockDecl 0x10d0801f0 // Second block
...
`-ExprWithCleanups 0x10d0801d0
|-cleanup Block 0x10d07f150 // points to the first BlockDecl
To fix the bug, this commit enters a new evaluation context to reset
ExprNeedsCleanups before each block is parsed.
Pete Cooper [Wed, 4 May 2016 17:37:27 +0000 (17:37 +0000)]
Update test CHECK lines after r268509. NFC.
r268509 causes this test case to be fully unrolled, so checking for an icmp is
no longer valid. Given that this test is for ARC anyway, checking for the icmp seems
unecessary.
Do not disable completely loop unroll when optimizing for size.
Let the loop unroll pass handle /Os. It already checks that option and adjust its thresholds accordingly. Also, will allow the #pragma unroll to have an effect in /Os.
Gabor Horvath [Wed, 4 May 2016 11:59:39 +0000 (11:59 +0000)]
[ASTMatchers] New matcher forFunction
Summary: Matcher proposed in the review of checker misc-assign-operator (name pending). Its goal is to find the direct enclosing function declaration of a statement and run the inner matcher on it. Two version is attached in this patch (thus it will not compile), to be decided which approach to take. The second one always chooses one single parent while the first one does a depth-first search upwards (thus a height-first search) and returns the first positive match of the inner matcher (thus it always returns zero or one matches, not more). Further questions: is it enough to implement it in-place, or ASTMatchersInternals or maybe ASTMatchFinder should be involved?
This code implements builtin_setjmp and builtin_longjmp exception handling intrinsics for 32-bit Sparc back-ends.
The code started as a mash-up of the PowerPC and X86 versions, although there are sufficient differences to both that had to be made for Sparc handling.
Note: I have manual tests running. I'll work on a unit test and add that to the rest of this diff in the next day.
Also, this implementation is only for 32-bit Sparc. I haven't focussed on a 64-bit version, although I have left the code in a prepared state for implementing this, including detecting pointer size and comments indicating where I suspect there may be differences.
Ben Langmuir [Wed, 4 May 2016 00:53:13 +0000 (00:53 +0000)]
Fix CodeCompletion & TypoCorrection when combining a PCH with Modules
This commit fixes the IdentifierIterator to actually include identifiers
from a PCH or precompiled preamble when there is also a global module
index. This was causing code-completion (outside of C++) and
typo-correction to be missing global identifiers defined in the
PCH/preamble. Typo-correction has been broken since we first started
using the module index, whereas code-completion only started relying on
identifier iterator in r232793.
David Blaikie [Tue, 3 May 2016 23:06:40 +0000 (23:06 +0000)]
[modules][debuginfo] Only include imported modules when targeting LLDB
These constructs are only applicable to a debugger capable of loading a
Clang AST, so omit them for brevity when not doing so.
We could potentially propagate more of CodeGenOptions through the
ObjectFilePCGContainerOperations for consistency (so the next person who
adds some CodeGenOpts feature that tweaks debug info output doesn't get
caught by this), so I'm open to objections/alternatives there, but went
with this for now.
Tested just a couple of basic cases (one direct, one indirect (through
the ObjectFilePCHContainerOperations) & fixed up other cases to pass the
-debugger-tuning flag as appropriate.
Tim Northover [Tue, 3 May 2016 19:22:41 +0000 (19:22 +0000)]
AArch64: simplify illegal vector check. NFC.
Use a utility function to check whether the number of elements is a power of 2
and drop the redundant upper limit (a 128-bit vector with more than 16 elements
would have each element < 8 bits, not possible).
Reid Kleckner [Tue, 3 May 2016 18:44:29 +0000 (18:44 +0000)]
[MS] Pass CalleeDecl to adjustThisArgumentForVirtualFunctionCall
If we are devirtualizing, then we want to compute the 'this' adjustment
of the devirtualized target, not the adjustment of the base's method
definition, which is usually zero.
Pete Cooper [Tue, 3 May 2016 18:32:01 +0000 (18:32 +0000)]
Change test to use regex instead of explicit value numbers. NFC.
We were seeing an internal failure when running this test. I can't
see a good reason for the difference, but the simple fix is to use
%{{.*}} instead of %1.
Reid Kleckner [Mon, 2 May 2016 22:42:34 +0000 (22:42 +0000)]
Fix argument expansion of reference fields of structs
r268261 made Clang "expand" more struct arguments on Windows. It removed
the check for 'RD->isCLike()', which was preventing us from attempting
to expand structs with reference type fields.
Our expansion code was attempting to load and pass each field of the
type in turn. We were accidentally doing one to many loads on reference
type fields.
On the function prologue side, we can use
EmitLValueForFieldInitialization, which obviously gets the address of
the field. On the call side, I tweaked EmitRValueForField directly,
since this is the only use of this method.
Akira Hatanaka [Mon, 2 May 2016 22:29:40 +0000 (22:29 +0000)]
Remove unneeded test in tryCaptureAsConstant.
It isn't necessary to call hasDefaultArg because we can't rematerialize
a captured variable that is a function parameter, regardless of whether
or not it has a default argument. NFC.
Artem Belevich [Mon, 2 May 2016 20:30:03 +0000 (20:30 +0000)]
[CUDA] Make sure device-side __global__ functions are always visible.
__global__ functions are a special case in CUDA.
Even when the symbol would normally not be externally
visible according to C++ rules, they still must be visible
in CUDA GPU object so host-side stub can launch them.
While using it in the shell is fine, this a problem when cc1as is
invoked directly by the driver because single quoting the clang full
version makes cc1as write out the version with the quotes in the final
binary.
If the user wants to copy-n-pastable output, it could use either -###
or CC_PRINT_OPTIONS=1 clang -v ...
Reid Kleckner [Mon, 2 May 2016 17:41:07 +0000 (17:41 +0000)]
Expand aggregate arguments more often on 32-bit Windows
Before this change, we would pass all non-HFA record arguments on
Windows with byval. Byval often blocks optimizations and results in bad
code generation. Windows now uses the existing workaround that other
x86_32 platforms use.
I also expanded the workaround to handle C++ records with constructors
on Windows. On non-Windows platforms, we have to keep generating the
same LLVM IR prototypes if we want our bitcode to be ABI compatible.
Otherwise we will encounter mismatch issues like PR21573.
Essentially fixes PR27522 in Clang instead of LLVM.
This exposes the Clang API bindings clang_getChildDiagnostics (which returns a
CXDiagnosticSet) and clang_getNumDiagnosticsInSet / clang_getDiagnosticInSet (to
traverse the CXDiagnosticSet), and adds a helper children property in the Python
Diagnostic wrapper.
Also, this adds the missing OVERLOAD_CANDIDATE (700) cursor type.
[NFC] Initialize a variable to make buildbot green.
In r268085 "[MS] Make #pragma pack use PragmaStack<> class." there was an
uninitialized variable 'Alignment', which caused the following failure:
http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/1758
Zero-initialize the variable to fix this failure.
Chris Bieneman [Fri, 29 Apr 2016 22:28:34 +0000 (22:28 +0000)]
Add a new warning to notify users of mismatched SDK and deployment target
Summary:
This patch adds a new driver warning -Wincompatible-sdk which notifies the user when they are mismatching the version min options and the sysroot.
The patch works by checking the sysroot (if present) for an SDK name, then matching that against the target platform. In the case of a mismatch it logs a warning.