Commit Graph

18037 Commits

Author SHA1 Message Date
Richard Smith ec216500f2 [modules] Improve llvm-bcanalyzer output on AST files a little. No functionality change.
llvm-svn: 229145
2015-02-13 19:48:37 +00:00
Nico Weber 7ce96b853d Revert r229082 for a bit, it caused PR22577.
llvm-svn: 229123
2015-02-13 16:27:00 +00:00
David Majnemer abc482effc MS ABI: Implement /volatile:ms
The /volatile:ms semantics turn volatile loads and stores into atomic
acquire and release operations.  This distinction is important because
volatile memory operations do not form a happens-before relationship
with non-atomic memory.  This means that a volatile store is not
sufficient for implementing a mutex unlock routine.

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

llvm-svn: 229082
2015-02-13 07:55:47 +00:00
Ben Langmuir 18dd78a8fd Mangle the IsSystem bit into the .pcm file name
When mangling the module map path into a .pcm file name, also mangle the
IsSystem bit, which can also depend on the header search paths. For
example, the user may change from -I to -isystem.  This can affect
diagnostics in the importing TU.

llvm-svn: 228966
2015-02-12 21:51:31 +00:00
Richard Smith 420fa12dfd Improve the "braces around scalar init" warning to determine whether to warn
based on whether "redundant" braces are ever reasonable as part of the
initialization of the entity, rather than whether the initialization is
"top-level". In passing, add a warning flag for it.

llvm-svn: 228896
2015-02-12 01:50:05 +00:00
Richard Smith 215f423ff2 Add a warning for direct-list-initialization of a variable with a deduced type
(or of a lambda init-capture, which is sort-of such a variable). The semantics
of such constructs will change when we implement N3922, so we intend to warn on
this in Clang 3.6 then change the semantics in Clang 3.7.

llvm-svn: 228792
2015-02-11 02:41:33 +00:00
Samuel Benzaquen ef621f43ff Add translationUnitDecl matcher.
Summary: Add translationUnitDecl matcher.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 228694
2015-02-10 14:46:45 +00:00
James Molloy 256f7ecad4 Fix __ldrexd arm intrinsic.
The parameter definition of this API is const volatile __int64*, but it is not defined correctly in clang. Move the 'CD' to the correct location.

Bug tracked here: http://llvm.org/bugs/show_bug.cgi?id=21004

Patch by Daniel Jump!

llvm-svn: 228678
2015-02-10 09:09:04 +00:00
Richard Smith e8292b10a6 [modules] When determining whether a name from a module replaces a name we
already have, check whether the name from the module is actually newer than the
existing declaration. If it isn't, we might (say) replace a visible declaration
with an injected friend, and thus make it invisible (or lose a default argument
or an array bound).

llvm-svn: 228661
2015-02-10 03:28:10 +00:00
Ben Langmuir 1daf480146 Diagnose timeouts in the LockFileManager and delete the dead lock file
If the lock file manager times out, we should give an error rather than
silently trying to load the existing module.  And delete the
(presumably) dead lock file, since it will otherwise prevent progress in
future invokations. This is unsound since we have no way to prove that
the lock file we are deleting is the same one we timed out on, but since
the lock is only to avoid excessive rebuilding anyway it should be okay.
Depends on llvm r228603.

llvm-svn: 228604
2015-02-09 20:35:13 +00:00
Filipe Cabecinhas 2177fc1732 Make the byte-shift SSE intrinsics emit vector shuffles which we know the backend can handle.
Also removed unused builtins.

Original patch by Andrea Di Biagio!

Reviewers: craig.topper, nadav

Subscribers: cfe-commits

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

llvm-svn: 228481
2015-02-07 01:37:09 +00:00
Richard Smith a3271c1390 [modules] Don't accidentally trigger deserialization from DeclContext::noload_lookup.
llvm-svn: 228475
2015-02-07 00:45:52 +00:00
Ben Langmuir 79fdb75a34 Make FileEntry::closeFile public
If you request that the file manager not close your file immediately
after reading, it's useful to be able to close it later to prevent a
file descriptor leak.

llvm-svn: 228407
2015-02-06 17:34:28 +00:00
Tom Stellard 96d5dc77fa Revert "OpenCL: handle shift operator with vector operands"
This reverts commit r228382.

This breaks the following case:  Reported by Jeroen Ketema:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150202/122961.html

typedef __attribute__((ext_vector_type(3))) char char3;

void foo() {
 char3 v = {1,1,1};
 char3 w = {1,2,3};

 w <<= v;
}

If I compile with:

 clang -x cl file.c

Then an error is produced:

file.c:10:5: error: expression is not assignable
 w <<= v;
 ~ ^
1 error generated.

llvm-svn: 228406
2015-02-06 17:30:04 +00:00
Benjamin Kramer b4ef66832d Update APIs that return a pair of iterators to return an iterator_range instead.
Convert uses of those APIs into ranged for loops. NFC.

llvm-svn: 228404
2015-02-06 17:25:10 +00:00
Sameer Sahasrabuddhe c65605d008 OpenCL: handle shift operator with vector operands
Introduce a number of checks:
1. If LHS is a scalar, then RHS cannot be a vector.
2. Operands must be of integer type.
3. If both are vectors, then the number of elements must match.

Relax the requirement for "usual arithmetic conversions":
When LHS is a vector, a scalar RHS can simply be expanded into a
vector; OpenCL does not require that its rank be lower than the LHS.
For example, the following code is not an error even if the implicit
type of the constant literal is "int".

  char2 foo(char2 v) { return v << 1; }

Consolidate existing tests under CodeGenOpenCL, and add more tests
under SemaOpenCL.

llvm-svn: 228382
2015-02-06 05:44:55 +00:00
Richard Smith b3761916fc [modules] Refactor: unify the code that picks which declaration goes into a
name lookup table.

llvm-svn: 228354
2015-02-05 23:08:52 +00:00
Reid Kleckner deeddeced3 Re-land r228258 and make clang-cl's /EHs- disable -fexceptions again
After r228258, Clang started emitting C++ EH IR that LLVM wasn't ready
to deal with, even when exceptions were disabled with /EHs-. This time,
make /EHs- turn off -fexceptions while still emitting exceptional
constructs in functions using __try.  Since Sema rejects C++ exception
handling constructs before CodeGen, landingpads should only appear in
such functions as the result of a __try.

llvm-svn: 228329
2015-02-05 18:56:03 +00:00
Nico Weber 94b2368c24 Revert r228258.
It caused a chromium base unittest that tests throwing and catching SEH
exceptions to fail (http://crbug.com/455488) and I suspect it might also
be the cause of the chromium clang win 64-bit shared release builder timing
out during compiles.  So revert to see if that's true.

llvm-svn: 228262
2015-02-05 02:08:50 +00:00
Richard Smith 4eca9b9372 [modules] When using -E, we may try to merge decls despite having no Sema
object. In such a case, use the TU's DC for merging global decls rather than
giving up when we find there is no TU scope.

Ultimately, we should probably avoid all loading of decls when preprocessing,
but there are other reasonable use cases for loading an AST file with no Sema
object for which this is the right thing.

llvm-svn: 228234
2015-02-04 23:37:59 +00:00
Reid Kleckner aca01db706 Implement IRGen for SEH __finally and AbnormalTermination
Previously we would simply double-emit the body of the __finally block,
but that doesn't work when it contains any kind of Decl, which we can't
double emit.

This fixes that by emitting the block once and branching into a shared
code region and then branching back out.

llvm-svn: 228222
2015-02-04 22:37:07 +00:00
Reid Kleckner 2689cecd67 Update inaccurate comment about inalloca
I meant to say it was like indirect+byval and not direct. It is not at
all like direct.

llvm-svn: 228191
2015-02-04 20:50:29 +00:00
Alexey Samsonov a511cdd247 Allow to specify multiple -fsanitize-blacklist= arguments.
Summary:
Allow user to provide multiple blacklists by passing several
-fsanitize-blacklist= options. These options now don't override
default blacklist from Clang resource directory, which is always
applied (which fixes PR22431).

-fno-sanitize-blacklist option now disables all blacklists that
were specified earlier in the command line (including the default
one).

This change depends on http://reviews.llvm.org/D7367.

Test Plan: regression test suite

Reviewers: timurrrr

Subscribers: cfe-commits, kcc, pcc

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

llvm-svn: 228156
2015-02-04 17:40:08 +00:00
Daniel Jasper 774e6b55b3 Rewrite r228138 to be somewhat saner.
While probably technically correct, the solution r228138 was quite hard
to read/understand. This should be simpler.

Also added a test to ensure that we are still visiting the syntactic form
as well.

llvm-svn: 228144
2015-02-04 14:29:47 +00:00
Daniel Jasper 1d8ecbdffc Let RecursiveASTVisitor walk both syntactic and semantic form of InitListExprs.
Otherwise, this can lead to unexpected results when AST matching as
some nodes are only present in the semantic form.

For example, only looking at the syntactic form does not find the
DeclRefExpr to f() in:

  struct S { S(void (*a)()); };
  void f();
  S s[1] = {&f};

llvm-svn: 228138
2015-02-04 13:11:42 +00:00
David Majnemer 631a90b6bc Sema: Add support for __declspec(restrict)
__declspec(restrict) and __attribute(malloc) are both handled
identically by clang: they are allowed to the noalias LLVM attribute.

Seeing as how noalias models the C99 notion of 'restrict', rename the
internal clang attribute to Restrict from Malloc.

llvm-svn: 228120
2015-02-04 07:23:21 +00:00
Anna Zaks a3d9534248 Register parameters have local storage.
Fixes a regression introduced in r209149.

llvm-svn: 228119
2015-02-04 07:15:12 +00:00
Sameer Sahasrabuddhe e8d2aaf320 OpenCL: handle ternary operator when the condition is a vector
When the condition is a vector, OpenCL specifies additional
requirements on the operand types, and also the operations
required to determine the result type of the operator. This is a
combination of OpenCL v1.1 s6.3.i and s6.11.6, and the semantics
remain unchanged in later versions of OpenCL.

llvm-svn: 228118
2015-02-04 06:38:18 +00:00
Alexey Bataev 8f01bb983c [MSVC2012] Allow 'mutable' references
Some standard header files from MSVC2012 use 'mutable' on references, though it is directly prohibited by the standard.
Fix for http://llvm.org/PR22444
Differential Revision: http://reviews.llvm.org/D7370

llvm-svn: 228113
2015-02-04 04:45:32 +00:00
Reid Kleckner 11ca834bef SEH: Track users of __try so we can pick a per-func EH personality
There are four major kinds of declarations that cause code generation:
- FunctionDecl (includes CXXMethodDecl etc)
- ObjCMethodDecl
- BlockDecl
- CapturedDecl

This patch tracks __try usage on FunctionDecls and diagnoses __try usage
in other decls. If someone wants to use __try from ObjC, they can use it
from a free function, since the ObjC code will need an ObjC-style EH
personality.

Eventually we will want to look through CapturedDecls and track SEH
usage on the parent FunctionDecl, if present.

llvm-svn: 228058
2015-02-03 22:52:35 +00:00
Weiming Zhao 71ac240620 Diagnose CXX 'this' pointer reference in funcs with naked attr
Clang asserts for this pointer reference in asms of naked functions.
This patch diagnoses if this pointer reference is used.

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

llvm-svn: 228052
2015-02-03 22:35:58 +00:00
DeLesley Hutchins ab1dc2d54d Thread Safety Analysis: add support for before/after annotations on mutexes.
These checks detect potential deadlocks caused by inconsistent lock
ordering.  The checks are implemented under the -Wthread-safety-beta flag.

This patch also replaces calls to getAttrs() with calls to attrs() throughout
ThreadSafety.cpp, which fixes the earlier issue that cause assert failures.

llvm-svn: 228051
2015-02-03 22:11:04 +00:00
Reid Kleckner 6c5e36ae3b Revert "Thread Safety Analysis: add support for before/after annotations on mutexes."
This reverts r227997, as well as r228009. It does not pass check-clang
for me locally on Linux.

llvm-svn: 228020
2015-02-03 19:51:16 +00:00
DeLesley Hutchins 4980df623f Thread Safety Analysis: add support for before/after annotations on mutexes.
These checks detect potential deadlocks caused by inconsistent lock
ordering.  The checks are implemented under the -Wthread-safety-beta flag.

llvm-svn: 227997
2015-02-03 18:17:48 +00:00
Nico Weber b14f872269 Implement jump scope SEHmantic analysis.
Thou shall not jump into SEH blocks. Jumping out of SEH __try and __excepts
is A-ok. Jumping out of __finally blocks is B-ok (msvc doesn't error about it,
but warns that it has undefined behavior).

I've checked that clang's behavior with this patch matches msvc's behavior.
We don't have the warning on jumping out of a __finally yet, see the FIXME
in the test. clang also currently crashes on codegen for a jump out of a
__finally block, see PR22414 comment 7.

I also added a few tests for the interaction of indirect jumps and SEH blocks.
MSVC doesn't support indirect jumps, so there's no way to know if clang behave
the same way as msvc here.  clang's behavior with this patch does make sense
to me, but maybe it could be argued that it should be more permissive (see
FIXME in the indirect jump tests -- shout if you have an opinion on this).

llvm-svn: 227982
2015-02-03 17:06:08 +00:00
Daniel Jasper e03491d390 Move "inline" to the right place.
llvm-svn: 227957
2015-02-03 09:54:58 +00:00
Daniel Jasper d142381cd8 Add some overloads so that floating point literals can be AST matched properly.
I am not entirely sure whether the implemented sematics are ideal. In
particular, should floatLiteral(equals(0.5)) match "0.5f" and should
floatLiteral(equals(0.5f)) match "0.5". With the overloads in this
patch, the answer to both questions is yes, but I am happy to change
that.

llvm-svn: 227956
2015-02-03 09:45:52 +00:00
Richard Smith 2a9e5c57ef [modules] Be sure to load the lexical definition of a class template
specialization from an update record exactly once, even if we needed to fake up
the definition.

llvm-svn: 227939
2015-02-03 03:32:14 +00:00
Daniel Jasper 05ce1eed0a Revert "Add some overloads so that floating point literals can be AST matched properly."
Apparently the build bots get angry for some reason. Can't reproduce
that in a local cmake/ninja build. Will look closer. Rolling back for
now.

llvm-svn: 227895
2015-02-02 23:35:39 +00:00
Daniel Jasper 88de3d7284 Add some overloads so that floating point literals can be AST matched properly.
I am not entirely sure whether the implemented sematics are ideal. In
particular, should floatLiteral(equals(0.5)) match "0.5f" and should
floatLiteral(equals(0.5f)) match "0.5". With the overloads in this
patch, the answer to both questions is yes, but I am happy to change
that.

llvm-svn: 227892
2015-02-02 23:04:00 +00:00
Reid Kleckner 68eb60b8c4 PR 17421: Implemented -save-temps={obj|cwd} option
-save-temps=cwd is equivalent to -save-temps
-save-temps=obj saves temporary file in the same directory as output

This helps to avoid clobbering of temp files in case of parallel
compilation with -save-temps of the files that have the same name
but located in different directories.

Patch by Artem Belevich

Reviewed By: rnk

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

llvm-svn: 227886
2015-02-02 22:41:48 +00:00
Reid Kleckner e71759103e SEH: Diagnose use of C++ EH and SEH in the same function
This check does not apply when Borland extensions are enabled, as they
have a checked in test case indicating that mixed usage of SEH and C++
is supported.

llvm-svn: 227876
2015-02-02 22:15:31 +00:00
Ben Langmuir 532d2104ce Add cc1 option '-fmodule-feature' to add custom values for 'requires' decls
This allows clang-based tools to specify custom features that can be
tested by the 'requires' declaration in a module map file.

llvm-svn: 227868
2015-02-02 21:56:15 +00:00
David Majnemer 8ab003a0db The prefix 'Ms-' should be 'MS-'
Clang is otherwise consistent that Microsoft be abbreviated as MS, not
Ms.

llvm-svn: 227842
2015-02-02 19:30:52 +00:00
David Majnemer 2ba2b26632 MS ABI: Add more documentation and tests for novtable
llvm-svn: 227838
2015-02-02 19:05:46 +00:00
David Majnemer 129f417efd MS ABI: Implement support for 'novtable'
It is common for COM interface classes to be marked as 'novtable' to
tell the compiler that constructors and destructors should not reference
virtual function tables.

This commit implements this feature in clang.

llvm-svn: 227796
2015-02-02 10:22:20 +00:00
John McCall 2859258e2f Allow objc_bridge(id) to be used on typedefs of [cv] void*.
rdar://19678874

llvm-svn: 227774
2015-02-01 22:34:06 +00:00
Craig Topper 2a898bfc67 [X86] Add the AVX512 exp2a23 intrinsics.
llvm-svn: 227769
2015-02-01 21:34:11 +00:00
Benjamin Kramer 95514e0422 Remove decltype in an attempt to fix the MSVC build.
C++ is hard, attempt #1 of n.

llvm-svn: 227768
2015-02-01 21:32:12 +00:00
Benjamin Kramer 06e0f5a784 Actually we can just inline the base typedef and use the injected class name for the base class.
llvm-svn: 227765
2015-02-01 20:47:51 +00:00