Commit Graph

19248 Commits

Author SHA1 Message Date
David Majnemer bee2bc3932 [MSVC Compat] Make -Wmicrosoft-cast not an error by default
Too much code is sloppy about this to error by default.

llvm-svn: 253506
2015-11-18 21:42:38 +00:00
Aaron Ballman 8e7f00b0eb Re-committing r253473 after hopefully fixing the bot breakage. There was a copy-pasta issue that my local testing did not catch.
llvm-svn: 253481
2015-11-18 17:56:55 +00:00
Aaron Ballman 81d17f2f7e Reverting r253473 while I investigate build bot failures.
llvm-svn: 253475
2015-11-18 17:16:01 +00:00
Aaron Ballman 34e0bd40e4 Adding AST matchers for VarDecl storage durations. Can now determine whether a VarDecl has automatic, static, or thread storage duration. This also updates the documentation for matchers, which appear to be missing some previous additions.
llvm-svn: 253473
2015-11-18 17:05:39 +00:00
Benjamin Kramer c02670ed50 [libclang] Add entry points that take a full command line including argv[0].
This provides both a more uniform interface and makes libclang behave like
clang tooling wrt relative paths against argv[0]. This is necessary for
finding paths to a c++ standard library relative to a clang binary given
in a compilation database. It can also be used to find paths relative to
libclang.so if the full path to it is passed in.

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

llvm-svn: 253466
2015-11-18 16:14:27 +00:00
Eugene Leviant 0d8103e975 Set flag for lldb when qualified name lookup is being done
llvm-svn: 253456
2015-11-18 12:48:05 +00:00
Rafael Espindola cd67662ad9 Update for llvm change.
llvm-svn: 253440
2015-11-18 06:54:13 +00:00
NAKAMURA Takumi 64705c8e7b BuildUniversalActions(): Prune obsolete \param(s). [-Wdocumentation]
FIXME: Describe BAInputs.
llvm-svn: 253434
2015-11-18 05:15:21 +00:00
Richard Smith 2a40fb78c0 Don't expose iterators into the list of types on the ASTContext; these are
unsafe, since many operations on the types can trigger lazy deserialization of
more types and invalidate the iterators. This fixes a crasher, but I've not
been able to reduce it to a reasonable testcase yet.

llvm-svn: 253420
2015-11-18 01:19:02 +00:00
Akira Hatanaka 8c26ea663d Produce a better diagnostic for global register variables.
Currently, when there is a global register variable in a program that
is bound to an invalid register, clang/llvm prints an error message that
is not very user-friendly.

This commit improves the diagnostic and moves the check that used to be
in the backend to Sema. In addition, it makes changes to error out if
the size of the register doesn't match the declared variable size.

e.g., volatile register int B asm ("rbp");

rdar://problem/23084219

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

llvm-svn: 253405
2015-11-18 00:15:28 +00:00
Richard Smith 752ada870d [modules] When a #include is mapped to a module import and appears somewhere
other than the top level, we issue an error. This breaks a fair amount of C++
code wrapping C libraries, where the C library is #included within a namespace
/ extern "C" combination, because the C library (probably) includes C++
standard library headers which may be within modules.

Without modules, this setup is harmless if (and *only* if) the corresponding
standard library module was already included outside the namespace, so
downgrade the error to a default-error extension in that case, so that it can
be selectively disabled for such misbehaving libraries.

llvm-svn: 253398
2015-11-17 23:32:01 +00:00
Artem Belevich 34f481acc6 [CUDA] Detect and link with CUDA's libdevice bitcode library.
- added detection of libdevice bitcode file and API to find one appropriate for the GPU we're compiling for.
- pass additional cc1 options for linking with detected libdevice bitcode
- added -nocudalib to prevent automatic linking with libdevice
- added test cases to verify new functionality

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

llvm-svn: 253387
2015-11-17 22:28:50 +00:00
Artem Belevich fa11ab53c0 [CUDA] added include paths for both sides of CUDA compilation.
In order to compile a CUDA file clang must be able to find
include files for both both host and device.

This patch passes AuxToolchain to AddPreprocessingOptions and
uses it to add include paths for the opposite side of compilation.

We also must be able to find CUDA include files. If the driver
found CUDA installation, it adds appropriate include path
to CUDA headers. This can be disabled with '-nocudainc'.

- Added include paths for the opposite side of compilation.
- Added include paths to detected CUDA installation.
- Added -nocudainc to prevent adding CUDA include path.
- Added test cases to verify new functionality.

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

llvm-svn: 253386
2015-11-17 22:28:46 +00:00
Artem Belevich 5e2a3ecd48 [CUDA] use -aux-triple to pass target triple of opposite side of compilation
Clang needs to know target triple for both sides of compilation so that
preprocessor macros and target builtins from both sides are available.

This change augments Compilation class to carry information about
toolchains used during different CUDA compilation passes and refactors
BuildActions to use it when it constructs CUDA jobs.

Removed DeviceTriple from CudaHostAction/CudaDeviceAction as it's no
longer needed.

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

llvm-svn: 253385
2015-11-17 22:28:40 +00:00
Douglas Katzman 6059ef98d9 Add trivial utility to append -L arguments to linker step. NFC
llvm-svn: 253350
2015-11-17 17:41:23 +00:00
Manuel Klimek ff39366de5 Revert "Make FP_CONTRACT ON the default."
This reverts commit r253269.

This leads to assert / segfault triggering on the following reduced example:
float foo(float U, float base, float cell) { return (U = 2 * base) - cell; }

llvm-svn: 253337
2015-11-17 15:40:10 +00:00
Craig Topper da7b27ff0b [Sema] Combine similar diagnostics using %select. NFC
llvm-svn: 253315
2015-11-17 05:40:09 +00:00
Richard Smith 10568d8c1c [modules] Fix some more cases where we used to reject a conflict between two
declarations that are not simultaneously visible, and where at least one of
them has internal/no linkage.

llvm-svn: 253283
2015-11-17 03:02:41 +00:00
Stephen Canon 916be92955 Make FP_CONTRACT ON the default.
Differential Revision: D14200

llvm-svn: 253269
2015-11-16 23:09:11 +00:00
Daniel Jasper da44677082 clang-format: Enable #include sorting by default.
This has seen quite some usage and I am not aware of any issues. Also
add a style option to enable/disable include sorting. The existing
command line flag can from now on be used to override whatever is set
in the style.

llvm-svn: 253202
2015-11-16 12:38:56 +00:00
Vedant Kumar 678125d7ec [Basic] Replace vector<bool> with BitVector in SourceManager. NFC.
llvm-svn: 253181
2015-11-16 04:39:22 +00:00
Vedant Kumar a52fa8efe6 [Basic] Use a bitfield in SLocEntry for clarity. NFC.
llvm-svn: 253177
2015-11-16 00:11:58 +00:00
Craig Topper 177f6b9758 [Sema] Remove unnecessary includes and forward declarations. NFC
llvm-svn: 253173
2015-11-15 17:27:52 +00:00
Sergey Kalinichev 8f3b187e21 [libclang] Visit TypeAliasTemplateDecl
This makes TypeAliasTemplateDecl accessible via LibClang and python bindings

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

llvm-svn: 253166
2015-11-15 13:48:32 +00:00
Sergey Kalinichev c015120b53 [libclang] Expose AutoType
Expose the AutoType via LibClang and python bindings

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

llvm-svn: 253165
2015-11-15 13:10:10 +00:00
Craig Topper 2512241b31 Fix a layering oddity by passing Sema to DeclSpec::Finish instead of DiagnosticsEngine and Preprocessor. Everything the preprocessor was being used for can be acquired from Sema.
llvm-svn: 253158
2015-11-15 03:32:11 +00:00
David Majnemer 7f77eb90a5 [Sema] Don't crash trying to diagnose abs called on a pointer type
Clang tries to figure out if a call to abs is suspicious by looking
through implicit casts to look at the underlying, implicitly converted
type.
Interestingly, C has implicit conversions from pointer-ish types like
function to less exciting types like int.  This trips up our 'abs'
checker because it doesn't know which variant of 'abs' is appropriate.

Instead, diagnose 'abs' called on function types upfront.  This sort of
thing is highly suspicious and is likely indicative of a missing
pointer dereference/function call/array index operation.

This fixes PR25532.

llvm-svn: 253156
2015-11-15 03:04:34 +00:00
Dan Gohman ce70b42bce [WebAssembly] Remove the "const" attribute from __builtin_wasm_memory_size.
llvm-svn: 253146
2015-11-14 22:57:34 +00:00
Craig Topper abb83aed5c Move diagnostics from Parse to Sema to remove Sema's dependency on ParserDiagnostic.h diagnostics.
llvm-svn: 253143
2015-11-14 19:31:56 +00:00
Craig Topper 54a6a68c70 Merge some similar diagnostics using %select.
llvm-svn: 253136
2015-11-14 18:16:08 +00:00
Eric Christopher ce83677666 Add support for the always_inline + target feature diagnostic to print
out the first missing target feature that's required and reword
the diagnostic accordingly.

llvm-svn: 253121
2015-11-14 02:38:37 +00:00
Craig Topper 7f5ff2175f Use %select to merge similar diagnostics. NFC
llvm-svn: 253119
2015-11-14 02:09:55 +00:00
Yaron Keren 3e43cda61c Deduplicate three identical copies of isExplicitInstantiationOrSpecialization, NFC.
llvm-svn: 253046
2015-11-13 15:39:39 +00:00
Richard Smith 6e132bef6f [modules] When a declaration has non-trivial visibility, check whether it's
actually hidden before we check its linkage. This avoids computing the linkage
"too early" for an anonymous struct with a typedef name for linkage.

llvm-svn: 253012
2015-11-13 05:14:45 +00:00
Richard Smith 26210db67f [modules] Follow the C++ standard's rule for linkage of enumerators: they have
the linkage of the enumeration. For enumerators of unnamed enumerations, extend
the -Wmodules-ambiguous-internal-linkage extension to allow selecting an
arbitrary enumerator (but only if they all have the same value, otherwise it's
ambiguous).

llvm-svn: 253010
2015-11-13 03:52:13 +00:00
Akira Hatanaka 7828b1e604 Add support for function attribute 'disable_tail_calls'.
The ``disable_tail_calls`` attribute instructs the backend to not
perform tail call optimization inside the marked function.

For example, 

int callee(int);

int foo(int a) __attribute__((disable_tail_calls)) {
  return callee(a); // This call is not tail-call optimized.
}

Note that this attribute is different from 'not_tail_called', which
prevents tail-call optimization to the marked function.

rdar://problem/8973573

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

llvm-svn: 252986
2015-11-13 00:42:21 +00:00
John McCall d6da23d2df Remove -Wobjc-weak-compat; there isn't a compelling use case for this.
llvm-svn: 252971
2015-11-12 23:39:39 +00:00
Richard Smith 97135cc94a [modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:

 * It is visible (not in a module, or in an imported module), or
 * We're doing redeclaration lookup and it's externally-visible, or
 * We're doing typo correction and looking for unimported decls.

We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.

This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on).  It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).

This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.

llvm-svn: 252960
2015-11-12 22:19:45 +00:00
Richard Smith 5e3fb7616d Revert r240335.
This failed to solve the problem it was aimed at, and introduced just as many
issues as it resolved. Realistically, we need to deal with the possibility that
multiple modules might define different internal linkage symbols with the same
name, and this isn't a problem unless two such symbols are simultaneously
visible.

The case where two modules define equivalent internal linkage symbols is
handled by r252063: if lookup finds multiple sufficiently-similar entities from
different modules, we just pick one of them as an extension (but we keep them
separate).

llvm-svn: 252957
2015-11-12 21:55:58 +00:00
Akira Hatanaka 0202848ad0 Add support for driver option -mno-ms-bitfields.
This option is used to cancel -mms-bitfields on the command line.

rdar://problem/15898553

llvm-svn: 252912
2015-11-12 17:21:22 +00:00
Craig Topper 71a51ff10e Use %select to merge two diagnostics that only differ in one word and are emitted in the same place. NFC
llvm-svn: 252861
2015-11-12 07:36:50 +00:00
Saleem Abdulrasool 6003443b8e libclang: add clang_Cursor_getCXXManglings
This function permits the mangling of a C++ 'structor.  Depending on the ABI and
the declaration, the declaration may contain more than one associated symbol for
a given declaration.  This allows the consumer to retrieve all of the associated
symbols for the declaration the cursor points to.

llvm-svn: 252853
2015-11-12 03:57:22 +00:00
Saleem Abdulrasool 5d92eaeb17 libclang: add new StringSet type
This allows the return of a set of CXStrings from libclang.  This is setup work
for an upcoming change to permit returning multiple mangled symbols.

llvm-svn: 252852
2015-11-12 03:57:16 +00:00
Akira Hatanaka 645af38957 [AttrDocs] Insert blank lines before and after code-block directives.
The code snippets were not being displayed. This commit fixes the bug.

llvm-svn: 252849
2015-11-12 02:41:56 +00:00
Eric Christopher 2b2d56f059 Provide a frontend based error for always_inline functions that require
target features that the caller function doesn't provide. This matches
the existing backend failure to inline functions that don't have
matching target features - and diagnoses earlier in the case of
always_inline.

Fix up a few test cases that were, in fact, invalid if you tried
to generate code from the backend with the specified target features
and add a couple of tests to illustrate what's going on.

This should fix PR25246.

llvm-svn: 252834
2015-11-12 00:44:12 +00:00
Nathan Wilson 68b2b9b3dc Add diagnostics which fall under [dcl.spec.concept]p5
Summary: Diagnose when a function concept declaration has parameter(s)

Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast

Subscribers: cfe-commits

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

llvm-svn: 252827
2015-11-11 23:53:35 +00:00
Craig Topper fb79b5f273 [X86] Add 'pause' builtin that's already in llvm and use it instead of inline assembly to implement _mm_pause.
llvm-svn: 252712
2015-11-11 08:13:33 +00:00
Craig Topper 19744ee6ad [X86] Change pointer type in AVX2 gather builtins to be the scalar type instead of the vector type. This matches gcc and removes extras casts.
llvm-svn: 252697
2015-11-11 02:51:18 +00:00
Richard Smith e301ba2b48 Add support for GCC's '__auto_type' extension, per the GCC manual:
https://gcc.gnu.org/onlinedocs/gcc/Typeof.html

Differences from the GCC extension:
 * __auto_type is also permitted in C++ (but only in places where
   it could appear in C), allowing its use in headers that might
   be shared across C and C++, or used from C++98
 * __auto_type can be combined with a declarator, as with C++ auto
   (for instance, "__auto_type *p")
 * multiple variables can be declared in a single __auto_type
   declaration, with the C++ semantics (the deduced type must be
   the same in each case)

This patch also adds a missing restriction on applying typeof to
a bit-field, which GCC has historically rejected in C (due to
lack of clarity as to whether the operand should be promoted).
The same restriction also applies to __auto_type in C (in both
GCC and Clang).

This also fixes PR25449.

Patch by Nicholas Allegra!

llvm-svn: 252690
2015-11-11 02:02:15 +00:00
Richard Smith 42b1057244 N3922: direct-list-initialization of an auto-typed variable no longer deduces a
std::initializer_list<T> type. Instead, the list must contain a single element
and the type is deduced from that.

In Clang 3.7, we warned by default on all the cases that would change meaning
due to this change. In Clang 3.8, we will support only the new rules -- per
the request in N3922, this change is applied as a Defect Report against earlier
versions of the C++ standard.

This change is not entirely trivial, because for lambda init-captures we
previously did not track the difference between direct-list-initialization and
copy-list-initialization. The difference was not previously observable, because
the two forms of initialization always did the same thing (the elements of the
initializer list were always copy-initialized regardless of the initialization
style used for the init-capture).

llvm-svn: 252688
2015-11-11 01:36:17 +00:00