Commit Graph

59062 Commits

Author SHA1 Message Date
Jordan Rose 9503501dae [analyzer] When forced to fake a block type, do it correctly.
BlockDecl has a poor AST representation because it doesn't carry its type
with it. Instead, the containing BlockExpr has the full type. This almost
never matters for the analyzer, but if the block decl contains static
local variables we need to synthesize a region to put them in, and this
region will necessarily not have the right type.

Even /that/ doesn't matter, unless

(1) the block calls the function or method containing the block, and
(2) the value of the block expr is used in some interesting way.

In this case, we actually end up needing the type of the block region,
and it will be set to our synthesized type. It turns out we've been doing
a terrible job faking that type -- it wasn't a block pointer type at all.
This commit fixes that to at least guarantee a block pointer type, using
the signature written by the user if there is one.

This is not really a correct answer because the block region's type will
/still/ be wrong, but further efforts to make this right in the analyzer
would probably be silly. We should just change the AST.

rdar://problem/21698099

llvm-svn: 241944
2015-07-10 21:41:59 +00:00
David Majnemer c0c42f3dea [MS ABI] Don't generates code for unreferenced inline definitions of library builtins
We should only consider declarations which were written, implicit
declarations shouldn't be considered.

This fixes PR24084.

llvm-svn: 241941
2015-07-10 20:55:38 +00:00
Richard Smith 8692a4d199 [modules] Fix "prefer own module over others" rule when selecting a module for a header to work in the presence of module hierarchy.
llvm-svn: 241936
2015-07-10 20:09:49 +00:00
Evgeniy Stepanov 45be9e0d24 Add an experimental flag -fsanitize-memory-use-after-dtor.
This flag will enable detection of use-after-destructor (but before
memory deallocation) bugs. No actual functionality yet.

https://code.google.com/p/address-sanitizer/issues/detail?id=73

Patch by Naomi Musgrave.

llvm-svn: 241935
2015-07-10 20:07:16 +00:00
Artem Belevich 959e0542b8 Changed Driver::getToolChain() to use Triple as an argument.
Differential Revision: http://reviews.llvm.org/D11105

llvm-svn: 241934
2015-07-10 19:47:55 +00:00
Akira Hatanaka 10bdb2b144 [inlineasm] Attach readonly and readnone to inline-asm instructions.
Previously, clang/llvm treated inline-asm instructions conservatively,
choosing not to eliminate the instructions or hoisting them out of a loop
even when it was safe to do so. This commit makes changes to attach a
readonly or readnone attribute to an inline-asm instruction, which enables
passes such as LICM and EarlyCSE to move or optimize away the instruction.

rdar://problem/11358192

Differential Revision: http://reviews.llvm.org/D10546

llvm-svn: 241930
2015-07-10 18:44:40 +00:00
Yaron Keren 425b1a5106 Teach clang that -no-pthread is a valid command line option
The winpthreads library in mingw-w64 passes -no-pthread when building
since pthreads is not available to build itself and pthreads it is linked 
by default. clang does not link to pthreads by default but did error on 
unknown -no-pthread option thus stopping the winpthreads build.

http://reviews.llvm.org/D11087

Patch by Martell Malone.

llvm-svn: 241929
2015-07-10 18:42:13 +00:00
Eric Christopher 71e5e3defe Refactor PPC ABI handling to accept and silently ignore -mabi=altivec.
All of the ABIs we support are altivec style anyhow and so the option
doesn't make much sense with the modern ABIs. We could make this a more
noisy ignore, but it would break builds for projects that just pass
it along by default because of historical reasons.

llvm-svn: 241925
2015-07-10 18:25:54 +00:00
Eric Christopher e6b7cf4787 Fix a couple of typos: specifc->specific.
llvm-svn: 241924
2015-07-10 18:25:52 +00:00
Diego Novillo a05459691f Factor PGO and coverage flag processing out of Clang::ConstructJob
The function is massively large and GCC is emitting stack overflow
errors when building it (stack, as counted by the compiler, grows to
more than 16Kb).

The new flag processing logic added in r241825 took it over the limit.

llvm-svn: 241918
2015-07-10 18:00:07 +00:00
Ulrich Weigand 03ce2a16bf Respect alignment of nested bitfields
tools/clang/test/CodeGen/packed-nest-unpacked.c contains this test:

struct XBitfield {
  unsigned b1 : 10;
  unsigned b2 : 12;
  unsigned b3 : 10;
};
struct YBitfield {
  char x;
  struct XBitfield y;
} __attribute((packed));
struct YBitfield gbitfield;

unsigned test7() {
  // CHECK: @test7
  // CHECK: load i32, i32* getelementptr inbounds (%struct.YBitfield, %struct.YBitfield* @gbitfield, i32 0, i32 1, i32 0), align 4
  return gbitfield.y.b2;
}

The "align 4" is actually wrong.  Accessing all of "gbitfield.y" as a single
i32 is of course possible, but that still doesn't make it 4-byte aligned as
it remains packed at offset 1 in the surrounding gbitfield object.

This alignment was changed by commit r169489, which also introduced changes
to bitfield access code in CGExpr.cpp.  Code before that change used to take
into account *both* the alignment of the field to be accessed within the
current struct, *and* the alignment of that outer struct itself; this logic
was removed by the above commit.

Neglecting to consider both values can cause incorrect code to be generated
(I've seen an unaligned access crash on SystemZ due to this bug).

In order to always use the best known alignment value, this patch removes
the CGBitFieldInfo::StorageAlignment member and replaces it with a
StorageOffset member specifying the offset from the start of the surrounding
struct to the bitfield's underlying storage.  This offset can then be combined
with the best-known alignment for a bitfield access lvalue to determine the
alignment to use when accessing the bitfield's storage.

Differential Revision: http://reviews.llvm.org/D11034

llvm-svn: 241916
2015-07-10 17:30:00 +00:00
Adrian Prantl 9b82de78fd Add a missing dependency to unittests/Frontend.
PR24067.

llvm-svn: 241915
2015-07-10 15:47:36 +00:00
Nemanja Ivanovic 672a14768d The test case still runs on non-ppc targets. Added -target triple.
llvm-svn: 241912
2015-07-10 14:11:38 +00:00
Daniel Jasper b9a52814bf clang-format: [JS] Assign proper penalties when breaking a type annotation
Before:
  class Test {
    aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa:
                         aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {}
  }

After:
  class Test {
    aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa):
        aaaaaaaaaaaaaaaaaaaaaa {}
  }

llvm-svn: 241908
2015-07-10 13:39:26 +00:00
Nemanja Ivanovic 26c3534b84 Add missing builtins to altivec.h for ABI compliance (vol. 3)
This patch corresponds to review:
http://reviews.llvm.org/D10972

Fix for the handling of dependent features that are enabled by default
on some CPU's (such as -mvsx, -mpower8-vector).

Also provides a number of new interfaces or fixes existing ones in
altivec.h.

Changed signatures to conform to ABI:
vector short vec_perm(vector signed short, vector signed short, vector unsigned char)
vector int vec_perm(vector signed int, vector signed int, vector unsigned char)
vector long long vec_perm(vector signed long long, vector signed long long, vector unsigned char)
vector signed char vec_sld(vector signed char, vector signed char, const int)
vector unsigned char vec_sld(vector unsigned char, vector unsigned char, const int)
vector bool char vec_sld(vector bool char, vector bool char, const int)
vector unsigned short vec_sld(vector unsigned short, vector unsigned short, const int)
vector signed short vec_sld(vector signed short, vector signed short, const int)
vector signed int vec_sld(vector signed int, vector signed int, const int)
vector unsigned int vec_sld(vector unsigned int, vector unsigned int, const int)
vector float vec_sld(vector float, vector float, const int)
vector signed char vec_splat(vector signed char, const int)
vector unsigned char vec_splat(vector unsigned char, const int)
vector bool char vec_splat(vector bool char, const int)
vector signed short vec_splat(vector signed short, const int)
vector unsigned short vec_splat(vector unsigned short, const int)
vector bool short vec_splat(vector bool short, const int)
vector pixel vec_splat(vector pixel, const int)
vector signed int vec_splat(vector signed int, const int)
vector unsigned int vec_splat(vector unsigned int, const int)
vector bool int vec_splat(vector bool int, const int)
vector float vec_splat(vector float, const int)

Added a VSX path to:
vector float vec_round(vector float)

Added interfaces:
vector signed char vec_eqv(vector signed char, vector signed char)
vector signed char vec_eqv(vector bool char, vector signed char)
vector signed char vec_eqv(vector signed char, vector bool char)
vector unsigned char vec_eqv(vector unsigned char, vector unsigned char)
vector unsigned char vec_eqv(vector bool char, vector unsigned char)
vector unsigned char vec_eqv(vector unsigned char, vector bool char)
vector signed short vec_eqv(vector signed short, vector signed short)
vector signed short vec_eqv(vector bool short, vector signed short)
vector signed short vec_eqv(vector signed short, vector bool short)
vector unsigned short vec_eqv(vector unsigned short, vector unsigned short)
vector unsigned short vec_eqv(vector bool short, vector unsigned short)
vector unsigned short vec_eqv(vector unsigned short, vector bool short)
vector signed int vec_eqv(vector signed int, vector signed int)
vector signed int vec_eqv(vector bool int, vector signed int)
vector signed int vec_eqv(vector signed int, vector bool int)
vector unsigned int vec_eqv(vector unsigned int, vector unsigned int)
vector unsigned int vec_eqv(vector bool int, vector unsigned int)
vector unsigned int vec_eqv(vector unsigned int, vector bool int)
vector signed long long vec_eqv(vector signed long long, vector signed long long)
vector signed long long vec_eqv(vector bool long long, vector signed long long)
vector signed long long vec_eqv(vector signed long long, vector bool long long)
vector unsigned long long vec_eqv(vector unsigned long long, vector unsigned long long)
vector unsigned long long vec_eqv(vector bool long long, vector unsigned long long)
vector unsigned long long vec_eqv(vector unsigned long long, vector bool long long)
vector float vec_eqv(vector float, vector float)
vector float vec_eqv(vector bool int, vector float)
vector float vec_eqv(vector float, vector bool int)
vector double vec_eqv(vector double, vector double)
vector double vec_eqv(vector bool long long, vector double)
vector double vec_eqv(vector double, vector bool long long)
vector bool long long vec_perm(vector bool long long, vector bool long long, vector unsigned char)
vector double vec_round(vector double)
vector double vec_splat(vector double, const int)
vector bool long long vec_splat(vector bool long long, const int)
vector signed long long vec_splat(vector signed long long, const int)
vector unsigned long long vec_splat(vector unsigned long long,
vector bool int vec_sld(vector bool int, vector bool int, const int)
vector bool short vec_sld(vector bool short, vector bool short, const int)

llvm-svn: 241904
2015-07-10 13:11:34 +00:00
NAKAMURA Takumi ddb44b85f0 Tweak a couple of -fprofile tests in clang/test to accept backslash in path.
llvm-svn: 241903
2015-07-10 13:11:08 +00:00
Benjamin Kramer 0429b7aeb4 Try to fix the test harder, it still fails on windows for unknown reasons.
llvm-svn: 241902
2015-07-10 13:04:41 +00:00
Benjamin Kramer 3cfdf2043c Reapply test for r241811 with a fix for msvc compat mode.
Delayed template parsing interferes with code completion, just distable it for
this test. This reverts r241811.

llvm-svn: 241899
2015-07-10 11:37:54 +00:00
Ulrich Weigand 6e2cea6f0c Respect alignment when loading up a coerced function argument
Code in CGCall.cpp that loads up function arguments that need to be
coerced to a different type may in some cases ignore the fact that
the source of the argument is not naturally aligned. This may cause
incorrect code to be generated. In some places in CreateCoercedLoad,
we already have setAlignment calls to address this, but I ran into one
where it was missing, causing wrong code generation on SystemZ.

However, in that location, we do not actually know what alignment of
the source location we can rely on; the callers do not pass anything
to this routine. This is already an issue in other places in
CreateCoercedLoad; and the same problem exists for CreateCoercedStore.

To avoid pessimising code, and to fix the FIXMEs already in place,
this patch also adds an alignment argument to the CreateCoerced*
routines and uses it instead of forcing an alignment of 1. The
callers are changed to pass in the best information they have.

This actually requires changes in a number of existing test cases
since we now get better alignment in many places.

Differential Revision: http://reviews.llvm.org/D11033

llvm-svn: 241898
2015-07-10 11:31:43 +00:00
Daniel Jasper 7450f91716 Re-use a single SmallString instance to reduce the stack frame size
In certain builds (msan), this can otherwise exceed the stack frame
limit set for certain environments.

llvm-svn: 241894
2015-07-10 08:25:54 +00:00
Daniel Jasper 7dc6b50047 Remove test that tests referring to the current working directory. You
cannot assume that the current working directory is writable in all test
environments. I don't know a better way to write this test of hand, lets
discuss. Possibly, a better option would be to put these together with
other test testing the driver directly.

llvm-svn: 241885
2015-07-10 05:57:23 +00:00
NAKAMURA Takumi 0de292f5d0 Revert test lines added in r241811, "[CodeCompletion] Don't crash on member inits of templated constructors.", for now.
It doesn't pass for targeting MS mode.

llvm-svn: 241882
2015-07-10 03:09:19 +00:00
Peter Collingbourne 4957217440 Driver: Make all of -f{,no-}sanitize{,-recover,-trap} core options.
This allows them to be used from clang-cl.

llvm-svn: 241881
2015-07-10 02:17:22 +00:00
Reid Kleckner 8819a4065f Re-enable 32-bit SEH after the alignment fix
llvm-svn: 241878
2015-07-10 00:16:25 +00:00
Gabor Horvath fc4c4d4441 [Static Analyzer] Basic per checker command line option validation.
Differential Revision: http://reviews.llvm.org/D8077

llvm-svn: 241863
2015-07-09 21:43:45 +00:00
Peter Collingbourne e570644285 CFI: Emit correct bit set information if RTTI is disabled under MS ABI.
We were previously creating bit set entries at virtual table offset
sizeof(void*) unconditionally under the Microsoft C++ ABI. This is incorrect
if RTTI data is disabled; in that case the "address point" is at offset
0. This change modifies bit set emission to take into account whether RTTI
data is being emitted.

Also make a start on a blacklisting scheme for records.

Differential Revision: http://reviews.llvm.org/D11048

llvm-svn: 241845
2015-07-09 19:56:14 +00:00
Adrian Prantl 5a88e1a8c6 Rename ModuleContainerGenerator to PCHContainergenerator for consistency
and re-clang-format (NFC).

llvm-svn: 241841
2015-07-09 19:46:39 +00:00
Diego Novillo 578caf5da7 Add GCC-compatible flags -fprofile-generate and -fprofile-use.
This patch adds support for specifying where the profile is emitted in a
way similar to GCC. These flags are used to specify directories instead
of filenames. When -fprofile-generate=DIR is used, the compiler will
generate code to write to <DIR>/default.profraw.

The patch also adds a couple of extensions: LLVM_PROFILE_FILE can still be
used to override the directory and file name to use and -fprofile-use
accepts both directories and filenames.

To simplify the set of flags used in the backend, all the flags get
canonicalized to -fprofile-instr-{generate,use} when passed to the
backend. The decision to use a default name for the profile is done
in the driver.

llvm-svn: 241825
2015-07-09 17:23:53 +00:00
Benjamin Kramer 2d46980ebb [Driver] semi-annual ubuntu version bump.
llvm-svn: 241812
2015-07-09 15:31:17 +00:00
Benjamin Kramer a4f8df0b5e [CodeCompletion] Don't crash on member inits of templated constructors.
Also fixes a crash (on invalid) member functions with a colon
initializer. PR23948.

llvm-svn: 241811
2015-07-09 15:31:10 +00:00
Yaron Keren 45a5bfef44 Add clang_free to libclang to free memory allocated in libclang.
One of the problems libclang tests has running under Windows is memory
allocated in libclang.dll but being freed in the test executable, possibly
by a different memory manager. This patch exposes a new export function,
clang_free(), used to free any allocated memory with the same libclang.dll
memory manager that allocated the memory.

http://reviews.llvm.org/D10949

Reviewed by Reid Kleckner, Douglas Gregor.

llvm-svn: 241789
2015-07-09 07:53:23 +00:00
Justin Bogner ed9cbe015c Driver: Include the driver arguments in crash reports
Similarly to r231989, the driver arguments can be quite helpful in
diagnosing a crash.

llvm-svn: 241786
2015-07-09 06:58:31 +00:00
Adrian Prantl 075bf567f9 Revert r241770 and add Basic to the dependencies of clang-check instead.
PR24067.

llvm-svn: 241782
2015-07-09 02:53:05 +00:00
Adrian Prantl 6335057824 Move the definition of ~PCHContainerOperations from Basic into Frontend.
Fixes PR24067.

llvm-svn: 241770
2015-07-09 01:01:52 +00:00
Reid Kleckner e7844ea7f8 Disable 32-bit SEH, again
Move the diagnostic back to codegen so that we can compile ATL on the
self-host bot. We don't actually end up emitting code for the __try, so
the diagnostic won't be hit.

llvm-svn: 241761
2015-07-08 23:57:03 +00:00
Adrian Prantl 2ecf89ebb3 DeclObjC: Move computing the type of self into a separate function (NFC).
This function will be used for emitting debug info.

llvm-svn: 241748
2015-07-08 22:15:59 +00:00
Richard Smith b1d8ea4635 [modules] Fix merging support for forward-declared enums with fixed underlying types. A visible declaration is enough to make the type complete, but not enough to make the definition visible.
llvm-svn: 241743
2015-07-08 21:49:31 +00:00
Adrian Prantl 3e8bad42f3 Cleanup the doxygen comments in CGDebugInfo.cpp according to the coding
standards. Remove several hilariously out-of-date and redundant comments
and move the non-redundant ones into the header file.

llvm-svn: 241733
2015-07-08 21:18:34 +00:00
Richard Smith 696e812bb3 [modules] Fix crash when writing an update record for a redeclaration of an empty namespace.
llvm-svn: 241732
2015-07-08 21:15:32 +00:00
Peter Collingbourne 3d4114b609 CodeGen: Fix off-by-one error in CFI class identification function for MS ABI.
We were previously ignoring classes laid out at offset zero.

llvm-svn: 241729
2015-07-08 21:08:08 +00:00
Peter Collingbourne 4bdceaa4de Driver: enable support for -fsanitize=cfi on Windows.
There are known issues, but the current implementation is good enough for
the check-cfi test suite.

Differential Revision: http://reviews.llvm.org/D11030

llvm-svn: 241728
2015-07-08 21:08:05 +00:00
Adrian Prantl 8f0bd5a5dd Cleanup the doxygen comments in CGDebugInfo.h according to the coding
standards and clang-format the file.

llvm-svn: 241723
2015-07-08 20:53:55 +00:00
Adrian Prantl e8b1cda091 Fix the spelling of Objective-C.
llvm-svn: 241722
2015-07-08 20:53:53 +00:00
Benjamin Kramer f448c783af Remove unused diagnostics. NFC.
llvm-svn: 241711
2015-07-08 19:10:43 +00:00
Davide Italiano 3d5b610c86 [Driver] print-multi-os-directory is unsupported.
Until somebody writes the code for it, be loud about the fact that
it's not implemented yet.

Differential Revision:	http://reviews.llvm.org/D11020

llvm-svn: 241708
2015-07-08 18:49:41 +00:00
Gabor Horvath c3177f2ed4 [Static Analyzer] Make the paths relative from the project root when generating reference results in the test suite.
llvm-svn: 241706
2015-07-08 18:39:31 +00:00
Justin Bogner 25bf8cb3c0 AST: Avoid reading an unitialized value
Desugar doesn't necessarily initialize ShouldAKA, but as of r241542 it
may read it. Fix the misuse of the API and initialize this before
passing it in.

Found by ubsan.

llvm-svn: 241705
2015-07-08 18:32:26 +00:00
Reid Kleckner 338635389f [SEH] Re-enable SEH on x86 Windows after r241699
llvm-svn: 241704
2015-07-08 18:27:10 +00:00
Adrian Prantl 26686c4af0 Update PCHInternals.rst to document PCH wrapped in object file containers.
llvm-svn: 241690
2015-07-08 16:52:51 +00:00
Adrian Prantl dfb9618687 Revert "Fix a linker issue with clang-check on Linux."
This reverts commit r241636 as it turned out to be unnecessary.

llvm-svn: 241684
2015-07-08 15:57:42 +00:00