summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [modules] Rationalize the behavior of Decl::declarationReplaces, and inRichard Smith2015-11-031-2/+2
| | | | | | | | | particular don't assume that two declarations of the same kind in the same context are declaring the same entity. That's not true when the same name is declared multiple times as internal-linkage symbols within a module. (getCanonicalDecl is cheap now, so we can just use it here.) llvm-svn: 251898
* Put global classes into the appropriate namespace.Benjamin Kramer2015-10-281-0/+2
| | | | | | | Most of the cases belong into an anonymous namespace. No functionality change intended. llvm-svn: 251514
* Refine r251469 to give better (and more localizable) diagnosticsJohn McCall2015-10-281-6/+4
| | | | | | for all the reasons that ARC makes things implicitly unavailable. llvm-svn: 251496
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* [coroutines] Initial stub Sema functionality for handling coroutine await / ↵Richard Smith2015-10-221-0/+3
| | | | | | yield / return. llvm-svn: 250993
* [modules] Allow the error on importing a C++ module within an extern "C"Richard Smith2015-10-131-6/+9
| | | | | | | | | 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. llvm-svn: 250137
* [MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enumDavid Majnemer2015-10-081-4/+11
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 249674
* [Sema] Tweak incomplete enum types on MSVC ABI targetsDavid Majnemer2015-10-081-2/+4
| | | | | | | | | 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. llvm-svn: 249667
* [MSVC Compat] Enable ABI impacting non-conforming behavior independently of ↵David Majnemer2015-10-081-1/+2
| | | | | | | | | | -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. llvm-svn: 249656
* Don't inherit the "unavailable" attribute from an overridden superclass method.Douglas Gregor2015-09-301-3/+1
| | | | | | Fixes rdar://problem/22922259. llvm-svn: 248950
* Don't inherit availability information when implementing a protocol requirement.Douglas Gregor2015-09-301-10/+17
| | | | | | | | | | 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. llvm-svn: 248949
* [OpenCL 2.0] Enable program scope variables, Section 6.5.1.Anastasia Stulova2015-09-301-25/+62
| | | | | | | | | | | | | | | | | | - 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 llvm-svn: 248906
* Remove warning on over-wide bit-field of boolean type; there's no risk thatRichard Smith2015-09-231-3/+8
| | | | | | | | | | 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. llvm-svn: 248435
* [CUDA] Allow parsing of host and device code simultaneously.Artem Belevich2015-09-221-5/+5
| | | | | | | | | | | | * 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 llvm-svn: 248299
* [CUDA] Add appropriate host/device attribute to builtins.Artem Belevich2015-09-221-0/+12
| | | | | | | | | 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 llvm-svn: 248296
* [CUDA] Allow function overloads in CUDA based on host/device attributes.Artem Belevich2015-09-221-0/+6
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 248295
* [Modules] More descriptive diagnostics for misplaced import directiveSerge Pavlov2015-09-191-4/+7
| | | | | | | | | | 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 llvm-svn: 248085
* Fix for assertion fail for pragma weak on typedef.Alexander Musman2015-09-181-1/+1
| | | | | | | | | | Example: typedef int __td3; #pragma weak td3 = __td3 Differential Revision: http://reviews.llvm.org/D12904 llvm-svn: 247975
* [MS ABI] Restore our warning for overwide bitfields using the MS ABIDavid Majnemer2015-09-151-19/+26
| | | | | | This restores a diagnostic lost in r247651. llvm-svn: 247659
* [MS ABI] Overwide bool bitfields should be permittedDavid Majnemer2015-09-151-4/+7
| | | | | | | | 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. llvm-svn: 247651
* PR24595: Ignore calling convention modifiers for structors in MS ABI.Andrey Bokhanko2015-09-141-1/+2
| | | | | | | | | | 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 llvm-svn: 247619
* C11 _Bool bitfield diagnosticRachel Craik2015-09-141-10/+10
| | | | | | | | | | | | 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 llvm-svn: 247618
* [Concepts] Add diagnostic; invalid specifier on function or variable concept ↵Nathan Wilson2015-09-091-1/+43
| | | | | | | | | | | | | | 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 llvm-svn: 247194
* Don't allow dllexport/import on static local variablesHans Wennborg2015-09-041-2/+4
| | | | | | | | 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. llvm-svn: 246864
* Cleanups, no functionality change.Richard Smith2015-09-041-18/+13
| | | | llvm-svn: 246837
* Fix a potential APInt memory leak when using __attribute__((flag_enum)), andRichard Smith2015-09-041-45/+20
| | | | | | simplify the implementation a bit. llvm-svn: 246830
* [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)Vedant Kumar2015-09-021-0/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D12444 llvm-svn: 246618
* Add a new frontend warning for referencing members from the handler of a ↵Aaron Ballman2015-09-011-1/+1
| | | | | | | | constructor or destructor function-try-block, which is UB in C++. This corresponds to the CERT secure coding rule ERR53-CPP. llvm-svn: 246548
* [MS ABI] Correctly mangle classes without names for linkage purposesDavid Majnemer2015-08-311-8/+9
| | | | | | | | | | | | | | | | 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. llvm-svn: 246469
* Follow-up to r246338: use getParentFunctionOrMethodHans Wennborg2015-08-281-1/+1
| | | | llvm-svn: 246348
* Allow TLS vars in dllimport/export functions; only inline dllimport ↵Hans Wennborg2015-08-281-3/+11
| | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 246338
* [CUDA] Check register names on appropriate side of cuda compilation only.Artem Belevich2015-08-271-2/+4
| | | | | | Differential Revision: http://reviews.llvm.org/D11950 llvm-svn: 246193
* Modify DeclaratorChuck::getFunction to be passed an Exception Specification ↵Nathan Wilson2015-08-261-1/+17
| | | | | | | | | | | | | | | | | 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 llvm-svn: 246005
* [modules] When we see a definition of a function for which we already have aRichard Smith2015-08-211-19/+41
| | | | | | | non-visible definition, skip the new definition to avoid ending up with a function with multiple definitions. llvm-svn: 245664
* Revert r245496 "[CUDA] Add appropriate host/device attribute to builtins."Artem Belevich2015-08-201-11/+0
| | | | | | It's breaking internal test. llvm-svn: 245592
* [CUDA] Add appropriate host/device attribute to builtins.Artem Belevich2015-08-191-0/+11
| | | | | | Differential Revision: http://reviews.llvm.org/D12122 llvm-svn: 245496
* [modules] When parsing the base specifiers of a parse-merged class, the currentRichard Smith2015-08-171-1/+3
| | | | | | | | 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). llvm-svn: 245236
* [CONCEPTS] Add diagnostic; invalid tag when concept specifiedNathan Wilson2015-08-141-1/+9
| | | | | | | | | | | | 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 llvm-svn: 245123
* [Sema] main can't be declared as global variable, in C++.Davide Italiano2015-08-141-0/+16
| | | | | | | | | | | 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 llvm-svn: 245051
* Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren2015-08-131-1/+0
| | | | | | | | | | 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. llvm-svn: 244928
* Rename the non-coding style conformant functions in namespace BuiltinsEric Christopher2015-08-061-6/+4
| | | | | | to match the rest of their brethren and reformat the bits that need it. llvm-svn: 244186
* [AST] ArrayRefize template param list info setters. No functionality change ↵Benjamin Kramer2015-08-051-13/+5
| | | | | | intended. llvm-svn: 244028
* [CONCEPTS] Add concept to VarDecl and diagnostic for uninitialized variable ↵Nathan Wilson2015-08-031-0/+12
| | | | | | | | | | | | | | 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 llvm-svn: 243876
* test commit; wrap ellipses in comment with bracketsNathan Wilson2015-07-311-1/+1
| | | | llvm-svn: 243776
* [Concepts] Add diagnostic: non template declarationHubert Tong2015-07-301-0/+6
| | | | | | | | | | | | | | | | 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! llvm-svn: 243690
* Use llvm::reverse to make a bunch of loops use foreach. NFC.Pete Cooper2015-07-301-3/+2
| | | | | | | | | | | | | | | | 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. llvm-svn: 243663
* [AST] Turn the callbacks of lookupInBases and forallBases into a function_refBenjamin Kramer2015-07-251-41/+36
| | | | | | | | | 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. llvm-svn: 243217
* Downgrade error about adding 'dllimport' to used free function to warning ↵Hans Wennborg2015-07-221-3/+9
| | | | | | | | (PR24215) The code will still work as it can reference the function via its thunk. llvm-svn: 242973
* [CONCEPTS] Add diagnostics: non-defining function; non-namespace scopeHubert Tong2015-07-221-0/+26
| | | | | | | | | | | | | | | | | | | | | 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! llvm-svn: 242899
* [modules] In C++, stop serializing and deserializing a list of declarations inRichard Smith2015-07-211-38/+7
| | | | | | | | | 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. llvm-svn: 242855
OpenPOWER on IntegriCloud