Alexey Samsonov [Fri, 22 Aug 2014 01:06:06 +0000 (01:06 +0000)]
CGCall: Factor out the logic mapping call arguments to LLVM IR arguments.
Summary:
This refactoring introduces ClangToLLVMArgMapping class, which
encapsulates the information about the order in which function arguments listed
in CGFunctionInfo should be passed to actual LLVM IR function, such as:
1) positions of sret, if there is any
2) position of inalloca argument, if there is any
3) position of helper padding argument for each call argument
4) positions of regular argument (there can be many if it's expanded).
Simplify several related methods (ConstructAttributeList, EmitFunctionProlog
and EmitCall): now they don't have to maintain iterators over the list
of LLVM IR function arguments, dealing with all the sret/inalloca/this complexities,
and just use expected positions of LLVM IR arguments stored in ClangToLLVMArgMapping.
This may increase the running time of EmitFunctionProlog, as we have to traverse
expandable arguments twice, but in further refactoring we will be able
to speed up EmitCall by passing already calculated CallArgsToIRArgsMapping to
ConstructAttributeList, thus avoiding traversing expandable argument there.
David Blaikie [Thu, 21 Aug 2014 22:46:45 +0000 (22:46 +0000)]
Update for LLVM API change to remove discriminator tracking from DILexicalBlock (in favor of DILexicalBlockFile - where a default arg is used to avoid the need for API churn of those callers)
Richard Smith [Thu, 21 Aug 2014 20:51:13 +0000 (20:51 +0000)]
Return statements are initialization; don't forget to revert the initializer to
its syntactic form before re-analyzing it during template instantiation.
Alexey Samsonov [Thu, 21 Aug 2014 20:26:47 +0000 (20:26 +0000)]
Pass expressions instead of argument ranges to EmitCall/EmitCXXConstructorCall.
Summary:
This is a first small step towards passing generic "Expr" instead of
ArgBeg/ArgEnd pair into EmitCallArgs() family of methods. Having "Expr" will
allow us to get the corresponding FunctionDecl and its ParmVarDecls,
thus allowing us to alter CodeGen depending on the function/parameter
attributes.
Alex Lorenz [Thu, 21 Aug 2014 19:25:27 +0000 (19:25 +0000)]
Coverage Mapping: store function's hash in coverage function records.
The profile data format was recently updated and the new indexing api
requires the code coverage tool to know the function's hash as well
as the function's name to get the execution counts for a function.
Daniel Sanders [Thu, 21 Aug 2014 10:13:49 +0000 (10:13 +0000)]
Fix invalid test generation by utils/ABITest/ABITestGen.py when the same enum is generated more than once.
When generating records/unions, the same enum type may be generated more
than once (with different names). In these cases, the name of the enum
values are not sufficiently unique to prevent multiple declarations. E.g:
typedef enum T3 { enum0val0 } T3;
typedef T3 T2[3];
typedef enum T4 { enum0val0 } T4;
typedef union T1 { T2 field0; T4 field1; char field2; } T1;
Added a unique suffix to enum values so that multiple identical enum types do
not use the same enum value names.
One example of this bug is produced by:
ABITestGen.py --no-unsigned --no-vector --no-complex --no-bool \
--max-args 0 --max-record-depth 1 -o inputs/test.9921.a.c \
-T inputs/test.9921.b.c -D inputs/test.9921.driver.c \
--min=9921 --count=1
Hans Wennborg [Thu, 21 Aug 2014 01:14:01 +0000 (01:14 +0000)]
MS ABI: Don't always instantiate all members of dllexported class templates (PR20163)
Normally we mark all members of exported classes referenced to get them emitted.
However, MSVC doesn't do this for class templates that are implicitly specialized or
just have an explicit instantiation declaration. For such specializations, the members
are emitted when referenced.
The exception is the case when the dllexport attribute is propagated from a base class
to a base class template that doesn't have an explicit attribute: in this case all
methods of the base class template do get instantiated.
Jordan Rose [Wed, 20 Aug 2014 22:40:57 +0000 (22:40 +0000)]
[test] Turn off warnings for test/Analysis/identical-expressions.cpp.
Also, make it slightly clearer what's being tested by only differentiating integer
literals based on their suffix, rather than using a very large constant.
Alex Lorenz [Wed, 20 Aug 2014 17:29:47 +0000 (17:29 +0000)]
Test: CoverageMapping: use "RUN: FileCheck" command instead of "RUN: cat | Filecheck".
Change the lit RUN commands for 3 tests to use the following pattern
"FileCheck -input-file ..." instead of "cat ... | FileCheck ..." as
suggested by Justin Bogner.
Alex Lorenz [Tue, 19 Aug 2014 17:32:30 +0000 (17:32 +0000)]
Add tests for coverage mapping generation.
This patch adds the tests for the coverage mapping generation.
Most of the tests check the mapping regions produced by
the generator, and one checks the llvm IR.
Aaron Ballman [Tue, 19 Aug 2014 15:55:55 +0000 (15:55 +0000)]
C++1y is now C++14!
Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording.
Alexander Musman [Tue, 19 Aug 2014 11:27:13 +0000 (11:27 +0000)]
[OPENMP] Extract common superclass from all the loop directives. No functional changes (having common superclass is convenient for future loop directives CodeGen implementation)
David Majnemer [Tue, 19 Aug 2014 07:29:03 +0000 (07:29 +0000)]
MS ABI: Update alias template mangling for VC "14" CTP 3
MSVC "14" CTP 3 has fixed it's mangling for alias templates when used as
template-template arguments; update clang to be compatible with this
mangling.
Alexey Samsonov [Mon, 18 Aug 2014 22:10:42 +0000 (22:10 +0000)]
Update link strategy for sanitizer runtime libraries on Linux:
1. Always put static sanitizer runtimes to the front of the linker
invocation line. This was already done for all sanitizers except UBSan:
in case user provides static libstdc++ we need to make sure that new/delete
operator definitions are picked from sanitizer runtimes instead of libstdc++.
We have to put UBSan runtime first for similar reasons: it depends on some
libstdc++ parts (e.g. __dynamic_cast function), and has to go first in
link line to ensure these functions will be picked up from libstdc++.
2. Put sanitizer libraries system dependencies (-ldl, -lpthread etc.) right
after sanitizer runtimes. This will ensure these libraries participate in
the link even if user provided -Wl,-as-needed flag. This should fix PR15823.
3. In case we link in several sanitizer runtimes (e.g. "ubsan", "ubsan_cxx"
and "san"), add system dependencies (-ldl, -lpthread, ...) only once.
Ben Langmuir [Mon, 18 Aug 2014 19:32:45 +0000 (19:32 +0000)]
Fix the rececl chain for redeclarations of predefined decls
Predefined decls like 'Protocol' in objc are not loaded from AST files,
so we cannot rely on loading the canonical decl to complete the redecl
chain for redeclarations of these decls. The broken redecl chain was
non-circular, so looping over redecls() would hang.
Ben Langmuir [Sat, 16 Aug 2014 04:54:18 +0000 (04:54 +0000)]
When loading a module with no local entities, still bump the size of the
tables that correspond to ContinuousRangeMaps, since the keys to those
maps need to be unique, or we may map to the wrong offset.
This fixes a crash + malformed AST file seen when loading some modules
that import Cocoa on Darwin, which is a module with no contents except
imports of other modules. Unfortunately I have not been able to find a
reduced test case that reproduces this problem.
Also add an assert that we aren't mapping one key to multiple values
in CRM. We ought to be able to say there are no duplicate keys at all,
but there are a bunch of 0 -> 0 mappings that are showing up, probably
coming from the source location table.
Nico Weber [Fri, 15 Aug 2014 23:21:41 +0000 (23:21 +0000)]
Make sure that vtables referenced from delay-parsed templates get referenced.
This fixes PR20671, see the bug for details. In short, ActOnTranslationUnit()
calls DefineUsedVTables() and only then PerformPendingInstantiations(). But
PerformPendingInstantiations() is what does delayed template parsing, so
vtables only references from late-parsed templates weren't marked used.
As a fix, move the SavePendingInstantiationsAndVTableUsesRAII in
PerformPendingInstantiations() up above the delayed template parsing code.
That way, vtables referenced from templates end up in the RAII object, and the
call to DefineUsedVTables() in PerformPendingInstantiations() marks them used.
Sean Silva [Fri, 15 Aug 2014 23:18:49 +0000 (23:18 +0000)]
Update for LLVM change (StringSaver)
There is more cleanup to be done here. Once
llvm::sys::Process::GetArgumentVector is switched over to StringSaver,
we can simplify this code a fair amount.
David Blaikie [Fri, 15 Aug 2014 21:11:25 +0000 (21:11 +0000)]
DebugInfo: While loop backedge should be attribute to the start of the while statement.
A little test case simplification - this could be simplified further,
though there are certainly interesting connections to the if/else
construct so I'm hesitant to remove that entirely though it does appear
somewhat unrelated.
David Blaikie [Fri, 15 Aug 2014 20:50:45 +0000 (20:50 +0000)]
DebugInfo: Fix PR19864 better - attribute the jump at the end of a range-for loop, to the start of the loop.
This avoids debuggers stepping to strange places (like the last
statement in the loop body, or the first statement in the if).
This is not the whole answer, though - similar bugs no doubt exist in
other loops (patches to follow) and attributing exception handling code
to the correct line is also tricky (based on the previous fix to
PR19864, exception handling is still erroneously attributed to the 'if'
line).
Sean Silva [Fri, 15 Aug 2014 19:23:53 +0000 (19:23 +0000)]
[cleanup] Rename this function to better reflect its purpose. NFC.
This also suggests some refactoring to simplify this code. Basically, a
ton of complexity in this argument handling code comes from the need to
save const char *'s in stable storage for pushing onto argv.
It seems like llvm::cl::StringSaver can be improved to cover all the
needs here.
Sean Silva [Fri, 15 Aug 2014 18:50:00 +0000 (18:50 +0000)]
[cleanup] Factor out some checks. NFC.
The core logic in main() is actually pretty simple, but there's lots of
stuff that has been added over time which obscures the flow of the code.
In upcoming patches, I'll be pulling more stuff out of the main
codepath.
I'm open to naming suggestions for these helper functions.
Objective-C. Do not warn if user is using property-dox syntax to name a
user provided setter name (as declared in @property attribute declaration).
rdar://18022762
Keno Fischer [Fri, 15 Aug 2014 01:39:12 +0000 (01:39 +0000)]
Make sure CallExpr::getLocStart doesn't segfault
Summary:
When the CallExpr passed to Sema::ConvertArgumentsForCall has all default parameters, and the number of actual arguments passed is zero, this function will segfault in the call to Call->getLocStart() if the Callee has an invalid getLocStart(), the reason being that since ConvertArgumentsForCall has set the correct number of arguments, but has not filled them in yet, getLocStart() will try to access the first (not yet existent) argument and thus segfaults.
This fixes that by making getLocStart return an invalid source location if the queried argument is NULL rather than segfaulting.
Reid Kleckner [Thu, 14 Aug 2014 23:34:52 +0000 (23:34 +0000)]
Limit our MSVC compat hack for nested names from dependent bases
Previously, any undeclared unqualified id starting a nested name
specifier in a dependent context would have its lookup retried during
template instantiation. Now we limit that retry hack to methods of a
class with dependent bases. Free function templates in particular are
no longer affected by this hack.
Also, diagnose this as a Microsoft extension. This has the downside that
template authors may see this warning *and* an error during
instantiation time about this identifier. Fixing that will probably
require formalizing some kind of "delayed" identifier, instead of our
ad-hoc solutions of forming dependent AST nodes when lookup fails.
Thread Safety Analysis: Move -Wthread-safety-negative out of the
-Wthread-safety umbrella flag, pending updates to documentation. The flag
works, but is likely to be confusing to existing users of -Wthread-safety.