Commit Graph

2456 Commits

Author SHA1 Message Date
Richard Smith 979b9b1234 [modules] Allow the error on importing a C++ module within an extern "C"
context (but otherwise at the top level) to be disabled, to support use of C++
standard library implementations that (legitimately) mark their <blah.h>
headers as being C++ headers from C libraries that wrap things in 'extern "C"'
a bit too enthusiastically.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250137 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 00:39:40 +00:00
David Majnemer 7ad1bdf876 [MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enum
consider the following:
enum E *p;
enum E { e };

The above snippet is not ANSI C because 'enum E' has not bee defined
when we are processing the declaration of 'p'; however, it is a popular
extension to make the above work.  This would fail using the Microsoft
enum semantics because the definition of 'E' would implicitly have a
fixed underlying type of 'int' which would trigger diagnostic messages
about a mismatch between the declaration and the definition.

Instead, treat fixed underlying types as not fixed for the purposes of
the diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249674 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 10:04:46 +00:00
David Majnemer 1d63a6b8d6 [Sema] Tweak incomplete enum types on MSVC ABI targets
Enums without an explicit, fixed, underlying type are implicitly given a
fixed 'int' type for ABI compatibility with MSVC.  However, we can
enforce the standard-mandated rules on these types as-if we didn't know
this fact if the tag is not part of a definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249667 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 07:45:35 +00:00
David Majnemer e1572f4b76 [MSVC Compat] Enable ABI impacting non-conforming behavior independently of -fms-compatibility
No ABI for C++ currently makes it possible to implement the standard
100% perfectly.  We wrongly hid some of our compatible behavior behind
-fms-compatibility instead of tying it to the compiler ABI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249656 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 04:53:31 +00:00
Douglas Gregor 4090e3ae47 Don't inherit the "unavailable" attribute from an overridden superclass method.
Fixes rdar://problem/22922259.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248950 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 21:34:33 +00:00
Douglas Gregor bd3ba16165 Don't inherit availability information when implementing a protocol requirement.
When an Objective-C method implements a protocol requirement, do not
inherit any availability information from the protocol
requirement. Rather, check that the implementation is not less
available than the protocol requirement, as we do when overriding a
method that has availability. Fixes rdar://problem/22734745.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248949 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 21:27:42 +00:00
Anastasia Stulova 9dc179d618 [OpenCL 2.0] Enable program scope variables, Section 6.5.1.
- Remove virtual SC_OpenCLWorkGroupLocal storage type specifier
as it conflicts with static local variables now and prevents
diagnosing static local address space variables correctly.

 - Allow static local and global variables (OpenCL2.0 s6.8 and s6.5.1).

 - Improve diagnostics of allowed ASes for variables in different scopes:
(i) Global or static local variables have to be in global
or constant ASes (OpenCL1.2 s6.5, OpenCL2.0 s6.5.1);
(ii) Non-kernel function variables can't be declared in local
or constant ASes (OpenCL1.1 s6.5.2 and s6.5.3).

http://reviews.llvm.org/D13105



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248906 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 14:08:20 +00:00
Richard Smith b548f3d654 Remove warning on over-wide bit-field of boolean type; there's no risk that
someone thought all the bits would be value bits in this case.

Also fix the wording of the warning -- it claimed that the width of 'bool' is
8, which is not correct; the width is 1 bit, whereas the size is 8 bits in our
implementation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248435 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-23 22:07:44 +00:00
Artem Belevich 675c6b4346 [CUDA] Allow parsing of host and device code simultaneously.
* adds -aux-triple option to specify target triple
 * propagates aux target info to AST context and Preprocessor
 * pulls in target specific preprocessor macros.
 * pulls in target-specific builtins from aux target.
 * sets appropriate host or device attribute on builtins.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248299 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 17:23:22 +00:00
Artem Belevich 3fd3179dd7 [CUDA] Add appropriate host/device attribute to builtins.
The changes are part of attribute-based CUDA function overloading (D12453)
and as such are only enabled when it's in effect (-fcuda-target-overloads).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248296 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 17:23:05 +00:00
Artem Belevich 72de1e381c [CUDA] Allow function overloads in CUDA based on host/device attributes.
The patch makes it possible to parse CUDA files that contain host/device
functions with identical signatures, but different attributes without
having to physically split source into host-only and device-only parts.

This change is needed in order to parse CUDA header files that have
a lot of name clashes with standard include files.

Gory details are in design doc here: https://goo.gl/EXnymm
Feel free to leave comments there or in this review thread.

This feature is controlled with CC1 option -fcuda-target-overloads
and is disabled by default.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248295 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 17:22:59 +00:00
Serge Pavlov 5bd7ce1215 [Modules] More descriptive diagnostics for misplaced import directive
If an import directive was put into wrong context, the error message was obscure,
complaining on misbalanced braces. To get more descriptive messages, annotation
tokens related to modules are processed where they must not be seen.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248085 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-19 05:32:57 +00:00
Alexander Musman 729bae0b12 Fix for assertion fail for pragma weak on typedef.
Example:
typedef int __td3;
#pragma weak td3 = __td3

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247975 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-18 07:40:22 +00:00
David Majnemer 4152b49377 [MS ABI] Restore our warning for overwide bitfields using the MS ABI
This restores a diagnostic lost in r247651.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247659 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-15 02:36:41 +00:00
David Majnemer f4a9596475 [MS ABI] Overwide bool bitfields should be permitted
Overwide bool bitfields have eight bits of storage size, make sure we
take the padding into account when determining whether or not they are
problematic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247651 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-15 01:00:55 +00:00
Andrey Bokhanko 53cd9bb62b PR24595: Ignore calling convention modifiers for structors in MS ABI.
MS compiler ignores calling convention modifiers for structors. This patch makes
clang do the same (for MS ABI). This fixes PR24595 and makes vswriter.h header
(from Windows SDK 8.1) compilable.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247619 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-14 21:29:57 +00:00
Rachel Craik 146b63d2d0 C11 _Bool bitfield diagnostic
Summary: Implement DR262 (for C). This patch will mainly affect bitfields of type _Bool

Reviewers: fraggamuffin, rsmith

Subscribers: hubert.reinterpretcast, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247618 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-14 21:27:36 +00:00
Nathan Wilson 1694b9d193 [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration
Summary: Diagnose variable and function concept declarations when an invalid specifier appears

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

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247194 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-09 21:48:31 +00:00
Hans Wennborg c270524308 Don't allow dllexport/import on static local variables
They might technically have external linkage, but it still doesn't make sense
for the user to try and export such variables. This matches MSVC's and MinGW's
behaviour.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246864 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-04 19:59:39 +00:00
Richard Smith 3282a972a0 Cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246837 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-04 04:09:21 +00:00
Richard Smith f2f9b412ba Fix a potential APInt memory leak when using __attribute__((flag_enum)), and
simplify the implementation a bit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246830 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-04 01:03:03 +00:00
Vedant Kumar 5c10cb7c14 [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)
Differential Revision: http://reviews.llvm.org/D12444

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246618 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-02 03:27:15 +00:00
Aaron Ballman e2415b5e4b Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.
This corresponds to the CERT secure coding rule ERR53-CPP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246548 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-01 14:49:24 +00:00
David Majnemer d17ec04400 [MS ABI] Correctly mangle classes without names for linkage purposes
A class without a name for linkage purposes gets a name along the lines
of <unnamed-type-foo> where foo is either the name of a declarator which
defined it (like a variable or field) or a
typedef-name (like a typedef or alias-declaration).

We handled the declarator case correctly but it would fall down during
template instantiation if the declarator didn't share the tag's type.
We failed to handle the typedef-name case at all.

Instead, keep track of the association between the two and keep it up to
date in the face of template instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246469 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 18:48:39 +00:00
Hans Wennborg 7033dfaec4 Follow-up to r246338: use getParentFunctionOrMethod
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246348 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 22:56:21 +00:00
Hans Wennborg 2c55320819 Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)
This patch does two things:

1) Don't error about dllimport/export on thread-local static local variables.
   We put those attributes on static locals in dllimport/export functions
   implicitly in case the function gets inlined. Now, for TLS variables this
   is a problem because we can't import such variables, but it's a benign
   problem becase:

2) Make sure we never inline a dllimport function TLS static locals. In fact,
   never inline a dllimport function that references a non-imported function
   or variable (because these are not defined in the importing library). This
   seems to match MSVC's behaviour.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246338 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 21:47:01 +00:00
Artem Belevich 294a21a0cd [CUDA] Check register names on appropriate side of cuda compilation only.
Differential Revision: http://reviews.llvm.org/D11950

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246193 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 19:54:21 +00:00
Nathan Wilson c56d3e3191 Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange
Summary:
- Store the exception specification range's begin and end SourceLocation in DeclaratorChuck::FunctionTypeInfo. These SourceLocations can be used in a FixItHint Range.
- Add diagnostic; function concept having an exception specification.


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

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246005 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-26 04:19:36 +00:00
Richard Smith 298fde4657 [modules] When we see a definition of a function for which we already have a
non-visible definition, skip the new definition to avoid ending up with a
function with multiple definitions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245664 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21 03:04:33 +00:00
Artem Belevich ebd9620ac7 Revert r245496 "[CUDA] Add appropriate host/device attribute to builtins."
It's breaking internal test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245592 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 18:28:56 +00:00
Artem Belevich 2063b03d43 [CUDA] Add appropriate host/device attribute to builtins.
Differential Revision: http://reviews.llvm.org/D12122

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245496 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 20:48:20 +00:00
Richard Smith 5df6568d40 [modules] When parsing the base specifiers of a parse-merged class, the current
context is the class itself but lookups should be performed starting with the
lookup parent of the class (class and base members don't shadow types from the
surrounding context because they have not been declared yet).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245236 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-17 20:24:17 +00:00
Nathan Wilson b1e2f13498 [CONCEPTS] Add diagnostic; invalid tag when concept specified
Summary: Adding check to emit diagnostic for invalid tag when concept is specified and associated tests.

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

Subscribers: aaron.ballman, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245123 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-14 23:19:32 +00:00
Davide Italiano 93fc20d91c [Sema] main can't be declared as global variable, in C++.
So, we now reject that. We also warn for any external-linkage global
variable named main in C, because it results in undefined behavior.

PR:	  24309
Differential Revision:	http://reviews.llvm.org/D11658
Reviewed by:	rsmith


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245051 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-14 14:13:29 +00:00
Yaron Keren f49d6b8491 Remove and forbid raw_svector_ostream::flush() calls.
After r244870 flush() will only compare two null pointers and return,
doing nothing but wasting run time. The call is not required any more
as the stream and its SmallString are always in sync.

Thanks to David Blaikie for reviewing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244928 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-13 18:12:56 +00:00
Eric Christopher b70ce903c2 Rename the non-coding style conformant functions in namespace Builtins
to match the rest of their brethren and reformat the bits that need it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244186 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-06 01:01:12 +00:00
Benjamin Kramer 52d1e12b0a [AST] ArrayRefize template param list info setters. No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244028 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05 09:40:49 +00:00
Nathan Wilson 86b5a658bc [CONCEPTS] Add concept to VarDecl and diagnostic for uninitialized variable concept
Summary: Add IsConcept bit to VarDecl::NonParmVarDeclBitfields and associated isConcept/setConcept member functions. Set IsConcept to true when 'concept' specifier is in variable declaration. Create diagnostic when variable concept is not initialized.

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

Subscribers: aemerson, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243876 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-03 14:25:45 +00:00
Nathan Wilson bd3dcdc301 test commit; wrap ellipses in comment with brackets
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243776 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31 20:00:02 +00:00
Hubert Tong 720bfb4891 [Concepts] Add diagnostic: non template declaration
Summary:
Adding diagnostic for concepts declared as non template (function
or variable)

Reviewers: faisalv, fraggamuffin, rsmith, hubert.reinterpretcast

Subscribers: nwilson, cfe-commits

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

Patch by Nathan Wilson!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243690 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30 21:20:55 +00:00
Pete Cooper 34219cae4a Use llvm::reverse to make a bunch of loops use foreach. NFC.
In llvm commit r243581, a reverse range adapter was added which allows
us to change code such as

  for (auto I = Fields.rbegin(), E = Fields.rend(); I != E; ++I) {

in to

  for (const FieldDecl *I : llvm::reverse(Fields))

This commit changes a few of the places in clang which are eligible to use
this new adapter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243663 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30 17:22:52 +00:00
Benjamin Kramer af49942c7c [AST] Turn the callbacks of lookupInBases and forallBases into a function_ref
This lets us pass functors (and lambdas) without void * tricks. On the
downside we can't pass CXXRecordDecl's Find* members (which are now type
safe) to lookupInBases directly, but a lambda trampoline is a small
price to pay. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243217 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-25 15:07:25 +00:00
Hans Wennborg 987bbbe471 Downgrade error about adding 'dllimport' to used free function to warning (PR24215)
The code will still work as it can reference the function via its thunk.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242973 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 23:54:51 +00:00
Hubert Tong 174a281e55 [CONCEPTS] Add diagnostics: non-defining function; non-namespace scope
Summary:
Create diagnostic for function concept declaration which is not a
definition.

Create diagnostic for concept declaration which isn't in namespace
scope.

Create associated tests.

Reviewers: rsmith, faisalv, fraggamuffin, hubert.reinterpretcast

Subscribers: cfe-commits

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

Patch by Nathan Wilson!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 13:32:36 +00:00
Richard Smith a4f29fcf3b [modules] In C++, stop serializing and deserializing a list of declarations in
the identifier table. This is redundant, since the TU-scope lookups are also
serialized as part of the TU DeclContext, and wasteful in a number of ways. We
still emit the decls for PCH / preamble builds, since for those we want
identical results, not merely semantically equivalent ones.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242855 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 23:54:07 +00:00
Richard Smith 1b8c2ec280 [modules] Don't save uninteresting identifiers, and don't consider identifiers
to be interesting just because they are the name of a builtin. Reduces the size
of an empty module by over 80% (~100KB).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242650 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-19 21:41:12 +00:00
Aaron Ballman 236d794324 Disable #pragma redefine_extname for C++ code as it does not make sense in such a context.
Patch by Andrey Bokhanko!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242420 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 17:06:53 +00:00
Paul Robinson d574782178 Add a "maximum TLS alignment" characteristic to the target info, so it
can be different from the normal variable maximum.
Add an error diagnostic for when TLS variables exceed maximum TLS alignment.
Currenty only PS4 sets an explicit maximum TLS alignment.

Patch by Charles Li!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242198 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 20:52:32 +00:00
David Majnemer 810e25ed9e [Sema] Emit a better diagnostic when variable redeclarations disagree
We referred to all declaration in definitions in our diagnostic messages
which is can be inaccurate.  Instead, classify the declaration and emit
an appropriate diagnostic for the new declaration and an appropriate
note pointing to the old one.

This fixes PR24116.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242190 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 20:08:49 +00:00
Justin Bogner 2290c8daa2 Sema: Allow null names to be passed in to isAcceptableTagRedeclaration
It's possible for TagRedeclarations to involve decls without a name,
ie, anonymous enums. We hit some undefined behaviour if we bind these
null names to the reference here.

We never dereference the name, so it's harmless if it's null - make it
a pointer to allow that.

Fixes the Modules/submodules-merge-defs.cpp test under ubsan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241963 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10 23:05:47 +00:00