[clang/asan] call __asan_poison_cxx_array_cookie after operator new[]
Summary:
PR19838
When operator new[] is called and an array cookie is created
we want asan to detect buffer overflow bugs that touch the cookie.
For that we need to
a) poison the shadow for the array cookie (call __asan_poison_cxx_array_cookie).
b) ignore the legal accesses to the cookie generated by clang (add 'nosanitize' metadata)
Alexey Samsonov [Mon, 25 Aug 2014 20:17:35 +0000 (20:17 +0000)]
Pass actual CallExpr instead of CallExpr-specific iterators
into EmitCXXMemberOrOperatorCall methods. In the end we want
to make declaration visible in EmitCallArgs() method, that
would allow us to alter CodeGen depending on function/parameter
attributes.
Richard Smith [Mon, 25 Aug 2014 02:10:01 +0000 (02:10 +0000)]
[modules] Fix false report of an ODR violation when merging friend
declarations. We can't expect to find them in the canonical definition
of the class, because that's not where they live.
This means we no longer reject real ODR violations with friend declarations,
but we weren't consistently doing so anyway.
Hal Finkel [Sun, 24 Aug 2014 04:50:19 +0000 (04:50 +0000)]
Move __vector long deprecation checking into DeclSpec::Finish
__vector long is deprecated, but __vector long long is not. As a result, we
cannot check for __vector long (to issue the deprecation warning) as we parse
the type because we need to know how many 'long's we have first.
DeclSpec::Finish seems like a more-appropriate place to perform the check
(which places it with several other similar Altivec vector checks).
Hal Finkel [Sun, 24 Aug 2014 03:47:06 +0000 (03:47 +0000)]
Implement __builtin_signbitl for PowerPC
PowerPC uses the special PPC_FP128 type for long double on Linux, which is
composed of two 64-bit doubles. The higher-order double (which contains the
overall sign) comes first, and so the __builtin_signbitl implementation
requires special handling to extract the sign bit.
Richard Smith [Sat, 23 Aug 2014 01:45:27 +0000 (01:45 +0000)]
[modules] When merging a tag declaration that has a typedef name for linkage
purposes, look for other typedefs with that same name and merge into their
named tag declaration if there is one.
Richard Smith [Sat, 23 Aug 2014 00:49:01 +0000 (00:49 +0000)]
[modules] Put class template declarations into the scope in which they're
declared, rather than putting them into the template parameter scope. We
previously had *no record* in the scope for class template declarations, once
those declarations completed and their template parameter scopes were popped.
This in turn caused us to be unable to merge class template declarations that
were declared in the global scope (where we use scope lookup rather than
DeclContext lookup for merging), when loading a module.
Objective-C. Warn when @encode'ing provides an incomplete
type encoding because in certain cases, such as for vector
types, because we still haven't designed encoding for them.
rdar://9255564
David Blaikie [Fri, 22 Aug 2014 22:29:50 +0000 (22:29 +0000)]
DebugInfo: Test that the loop backedge in a range-for is attribute to the loop header.
This already works, but somewhat by accident (due to the order of
emission in clang, the location is set to the loop header (during the
emission of the iteratior increment) before the loop backedge is
emitted), so let's just add a test for symmetry and future-proofing.
David Blaikie [Fri, 22 Aug 2014 22:25:37 +0000 (22:25 +0000)]
DebugInfo: for loop backedge should be attributed to the start of the for statement.
Similar to r215768 (which fixed the same case for while loops). To quote
r215768's commit message:
"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, 22 Aug 2014 21:37:04 +0000 (21:37 +0000)]
DebugInfo: Scope for condition variables more narrowly than the loop variable.
for loops introduce two scopes - one for the outer loop variable and its
initialization, and another for the body of the loop, including any
variable declared inside the loop condition.
Hans Wennborg [Fri, 22 Aug 2014 20:33:18 +0000 (20:33 +0000)]
Ignore -Wunsupported-dll-base-class-template by default
The situation it is warning about (see PR20725) is not very likely
to be a real problem, and it is unclear what action the user should take
if the warning does fire.
Reid Kleckner [Fri, 22 Aug 2014 19:29:30 +0000 (19:29 +0000)]
Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind
This patch aims at fixing PR17239.
This bug happens because the /link (clang-cl.exe argument) is marked as
"consume all remaining arguments". However, when inside a response file,
/link should only consume all remaining arguments inside the response
file where it is located, not the entire command line after expansion.
The LLVM side of the patch will change the semantics of the
RemainingArgsClass kind to always consume only until the end of the
response file when the option originally came from a response file.
There are only two options in this class: dash dash (--) and /link.
This is the Clang side of the patch in http://reviews.llvm.org/D4899
Quentin Colombet [Fri, 22 Aug 2014 18:08:37 +0000 (18:08 +0000)]
[test/CodeGen/ARM] Adpat test to match new codegen after r216274.
Moreover, rework some patterns to actually check the emitted instructions
instead of matching unrelated string!
E.g.,
some of the "// CHECK: vmov" were matching stuff like ".globl
funcname_with_vmov" instead of actual instructions.
Reid Kleckner [Fri, 22 Aug 2014 16:52:57 +0000 (16:52 +0000)]
-fms-extensions: Alias _intNN to __intNN
Fixes build for SPEC 2000 CPU. MSVC disables these aliases under /Za,
which enables stricter standards compliance. We don't currently have any
way to disable them.
Aaron Ballman [Fri, 22 Aug 2014 13:26:37 +0000 (13:26 +0000)]
Fixing MSVC warning: "warning C4373: 'blah': virtual function overrides 'blah', previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers."
This warning is basically useless because the "previous versions" being referred to is MSVC 2005 and earlier, and we obviously do not care about them. However, this warning isn't particularly chatty (I don't recall ever seeing it previously), and it has the opportunity to point out cases where the cv-qualifiers differ unintentionally (like this case), so I am leaving it enabled for now.
Akira Hatanaka [Fri, 22 Aug 2014 06:05:21 +0000 (06:05 +0000)]
[AArch64, inline-asm] Improve diagnostic that is printed when the size of a
variable that has regiser constraint "r" is not 64-bit.
General register operands are output using 64-bit "x" register names, regardless
of the size of the variable, unless the asm operand is prefixed with the "%w"
modifier. This surprises and confuses many users who aren't familiar with
aarch64 inline assembly rules.
With this commit, a note and fixit hint are printed which tell the users that
they need modifier "%w" in order to output a "w" register instead of an "x"
register.
David Majnemer [Fri, 22 Aug 2014 04:22:50 +0000 (04:22 +0000)]
MS ABI: Don't use the Itanium scheme for numbering lambdas
The Itanium ABI will give out the same mangling number for two different
lambdas if their call operators have different types. The MS ABI cannot
do the same because it does not mangle the return type into it's
lambdas.
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.