summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [modules] Suport for merging a parsed enum definition into an existing ↵Richard Smith2015-05-071-11/+33
| | | | | | imported but not visible definition. llvm-svn: 236690
* Allow TransformTypos to ignore corrections to a specified VarDecl.Kaelyn Takata2015-05-051-4/+5
| | | | | | | | | | | | | This is needed to prevent a TypoExpr from being corrected to a variable when the TypoExpr is a subexpression of that variable's initializer. Also exclude more keywords from the correction candidate pool when the subsequent token is .* or ->* since keywords like "new" or "return" aren't valid on the left side of those operators. Fixes PR23140. llvm-svn: 236519
* [modules] Start moving the module visibility information off the Module itself.Richard Smith2015-05-011-4/+2
| | | | | | | It has no place there; it's not a property of the Module, and it makes restoring the visibility set when we leave a submodule more difficult. llvm-svn: 236300
* [cuda] Preserve TLS storage class of host variable even if it's aArtem Belevich2015-04-281-2/+6
| | | | | | device-side compilation. llvm-svn: 236029
* PR23334: Perform semantic checking of lambda capture initialization in the ↵Richard Smith2015-04-271-0/+17
| | | | | | | | | | | | | | | | | | right context. Previously we'd try to perform checks on the captures from the middle of parsing the lambda's body, at the point where we detected that a variable needed to be captured. This was wrong in a number of subtle ways. In PR23334, we couldn't correctly handle the list of potential odr-uses resulting from the capture, and our attempt to recover from that resulted in a use-after-free. We now defer building the initialization expression until we leave the lambda body and return to the enclosing context, where the initialization does the right thing. This patch only covers lambda-expressions, but we should apply the same change to blocks and captured statements too. llvm-svn: 235921
* [cuda] Ignore "TLS unsupported by target" errors for host variables during ↵Artem Belevich2015-04-271-4/+14
| | | | | | | | | | | | | | | | device compilation. During device-side CUDA compilation clang currently complains about all TLS variables, regardless of whether they are __host__ or __device__. This patch suppresses "TLS unsupported" errors for host variables during device compilation and for device variables during host compilation. Differential Revision: http://reviews.llvm.org/D9269 llvm-svn: 235907
* [Sema] Don't allow unverified bitfields in FieldDeclsDavid Majnemer2015-04-261-1/+3
| | | | | | | | VerifyBitField must be called if we are to form a bitfield FieldDecl. We will not verify the bitfield if the decl is known to be malformed in other ways; pretend that we don't have a bitfield if this happens. llvm-svn: 235816
* [Sema] Check if a builtin is FunctionPrototype().Davide Italiano2015-04-251-1/+1
| | | | | | | | | | | Don't assume it's always is. This prevents a crash in Sema while trying to merge return type for a builtin w/out function prototype. PR: 23086 Differential Revision: http://reviews.llvm.org/D9235 Reviewed by: rsmith llvm-svn: 235806
* Diagnose variadic main() as an extension; addresses PR17905.Aaron Ballman2015-04-231-0/+6
| | | | llvm-svn: 235605
* Wrap to 80 columns, fix typo in comment. No behavior change.Nico Weber2015-04-221-2/+3
| | | | llvm-svn: 235470
* [Sema] Don't crash if array bound calculation overflowed constexpr arrayDavid Majnemer2015-04-181-0/+2
| | | | | | | | | We didn't correctly expect a QualifiedTypeLoc when faced with fixing a variable array type into a constant array type. Differential Revision: http://reviews.llvm.org/D8958 llvm-svn: 235251
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-091-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation would copy the attribute from the class to functions that have the class as their return type when the functions are first declared. This proved to have two flaws: 1) if the class is forward-declared without the attribute and a function or method with the class as a its return type is declared, and afterward the class is defined with warn_unused_result, the function or method would never inherit the attribute, and 2) the check simply failed for functions and methods that are part of a template instantiation, regardless of whether the class with warn_unused_result is part of a specific instantiation or part of the template itself (presumably because those function/method declaration does not hit the same code path as a non-template one and so never inherits the attribute). The new approach is to instead modify the two places where a function or method call is checked for the warn_unused_result attribute on the decl by extending the checks to also look for the attribute on the decl's return type. Additionally, the check for return types that have the warn_unused_result now excludes pointers and references to such types, as such return types do not necessarily imply a transfer of ownership for the underlying object being referred to by the return value. This does not change the behavior of functions that are directly given the warn_unused_result attribute. llvm-svn: 234526
* [modules] Allow a function template definition if we have a pre-existing but ↵Richard Smith2015-03-271-3/+6
| | | | | | not visible definition of the same template. llvm-svn: 233430
* [modules] Allow a function to be redefined if the old definition is not visible.Richard Smith2015-03-271-0/+9
| | | | llvm-svn: 233407
* [modules] Handle defining a tag with a typedef name for linkage purposes on ↵Richard Smith2015-03-271-2/+31
| | | | | | top of an existing imported-but-not-visible definition. llvm-svn: 233345
* [modules] Handle defining a class template on top of an existing ↵Richard Smith2015-03-271-4/+6
| | | | | | imported-but-not-visible definition. llvm-svn: 233341
* [modules] If we reach a definition of a class for which we already have aRichard Smith2015-03-261-5/+21
| | | | | | | | non-visible definition, skip the new definition and make the old one visible instead of trying to parse it again and failing horribly. C++'s ODR allows us to assume that the two definitions are identical. llvm-svn: 233250
* MS ABI: Implement the MSVC 2015 scheme for scope disambiguationDavid Majnemer2015-03-191-11/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | consider C++ that looks like: inline int &f(bool b) { if (b) { static int i; return i; } static int i; return i; } Both 'i' variables must have distinct (and stable) names for linkage purposes. The MSVC 2013 ABI would number the variables using a count of the number of scopes that have been created. However, the final 'i' returns to a scope that has already been created leading to a mangling collision. MSVC 2015 fixes this by giving the second 'i' the name it would have if it were declared before the 'if'. However, this results in ABI breakage because the mangled name, in cases where there was no ambiguity, would now be different. We implement the new behavior and only enable it if we are targeting the MSVC 2015 ABI, otherwise the old behavior will be used. This fixes PR18131. llvm-svn: 232766
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-1/+1
| | | | | | | | | | | | | | | Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
* Fix a crash when the size of an 'auto' is needed and its initalizerKaelyn Takata2015-03-171-0/+14
| | | | | | | | contained a typo correction (the auto decl was being marked as dependent unnecessarily, which triggered an assertion in cases where the size of the type is needed). llvm-svn: 232568
* MS ABI: Delay default constructor closure checking until the outermost class ↵Reid Kleckner2015-03-171-27/+1
| | | | | | | | | | | | | | | | | scope ends Previously, we would error out on this code because the default argument wasn't parsed until the end of Outer: struct __declspec(dllexport) Outer { struct __declspec(dllexport) Inner { Inner(void *p = 0); }; }; Now we do the checking on the closing brace of Outer instead of Inner. llvm-svn: 232519
* Comment parsing: move a diagnostic to the correct group.Dmitri Gribenko2015-03-171-2/+5
| | | | | | Based on a patch by LE GARREC Vincent. llvm-svn: 232511
* MS ABI: Generate default constructor closuresDavid Majnemer2015-03-131-1/+27
| | | | | | | | | | | | | | | | | | | | The MS ABI utilizes a compiler generated function called the "vector constructor iterator" to construct arrays of objects with non-trivial constructors/destructors. For this to work, the constructor must follow a specific calling convention. A thunk must be created if the default constructor has default arguments, is variadic or is otherwise incompatible. This thunk is called the default constructor closure. N.B. Default constructor closures are only generated if the default constructor is exported because clang itself does not utilize vector constructor iterators. Failing to export the default constructor closure will result in link/load failure if a translation unit compiled with MSVC is on the import side. Differential Revision: http://reviews.llvm.org/D8331 llvm-svn: 232229
* Sema: Don't emit a missing prototype warning for deleted functions.Benjamin Kramer2015-03-121-26/+30
| | | | | | | | | | | | | This is a bit more involved than I anticipated, so here's a breakdown of the changes: 1. Call ActOnFinishFunctionBody _after_ we parsed =default and =delete specifiers. Saying that we finished the body before parsing =default is just wrong. Changing this allows us to use isDefaulted and isDeleted on a decl in ActOnFinishFunctionBody. 2. Check for -Wmissing-prototypes after we parsed the function body. 3. Disable -Wmissing-prototypes when the Decl isDeleted. llvm-svn: 232040
* Sema: Properly track mangling number/name for linkage for using declsDavid Majnemer2015-03-111-46/+52
| | | | | | | | | | | | Using declarations which are aliases to struct types have their name used as the struct type's name for linkage purposes. Otherwise, make sure to give an anonymous struct defined inside a using declaration a mangling number to disambiguate it from other anonymous structs in the same context. This fixes PR22809. llvm-svn: 231909
* Wrap to 80 columns. No behavior change.Nico Weber2015-03-091-3/+3
| | | | llvm-svn: 231621
* Wrap to 80 columns. No behavior change.Nico Weber2015-03-071-3/+5
| | | | llvm-svn: 231573
* Replace Sema's map of locally-scoped extern "C" declarations with a DeclContextRichard Smith2015-03-071-18/+4
| | | | | | | | | | of extern "C" declarations. This is simpler and vastly more efficient for modules builds (we no longer need to load *all* extern "C" declarations to determine if we have a redeclaration). No functionality change intended. llvm-svn: 231538
* Implement section pragma feedback on r205810Reid Kleckner2015-03-041-8/+11
| | | | | | | Mostly short-circuits some conditionals. Adds target validation of sections passed to these pragmas. llvm-svn: 231317
* Make -Wuninitialized warn on pointer-to-member and comma operators.Manuel Klimek2015-03-031-1/+6
| | | | | | | | | | | `isTrackedVar` has been updated to also track records. `DeclRefExpr`s appearing on the left side of a comma operator are ignored, while those appearing on the right side are classified as `Use`. Patch by Enrico Pertoso. llvm-svn: 231068
* Rework our handling of key functions. We used to track a complete list of allRichard Smith2015-02-281-23/+27
| | | | | | | | | | | | | | dynamic classes in the translation unit and check whether each one's key function is defined when we got to the end of the TU (and when we got to the end of each module). This is really terrible for modules performance, since it causes unnecessary deserialization of every dynamic class in every compilation. We now use a much simpler (and, in a modules build, vastly more efficient) system: when we see an out-of-line definition of a virtual function, we check whether that function was in fact its class's key function. (If so, we need to emit the vtable.) llvm-svn: 230830
* [MSVC] Improved lookup into dependent/non-dependent bases of dependent classAlexey Bataev2015-02-191-32/+72
| | | | | | | | Patch improves lookup into dependendt bases of dependent class and adds lookup into non-dependent bases. Differential Revision: http://reviews.llvm.org/D7173 llvm-svn: 229817
* Sema: Allow 'constexpr' variables in range loopsMeador Inge2015-02-181-2/+0
| | | | | | | | This fixes PR22492, which is in response to CWG issue #1204. Per the CWG issue 'contexpr' variables are now allowed in for range loops. llvm-svn: 229716
* Port r163224 to C++.Nico Weber2015-02-181-1/+4
| | | | | | | | | | | | | | | | | | | | The motivation is to fix a crash on struct S {} s; Foo S::~S() { s.~S(); } What was happening here was that S::~S() was marked as invalid since its return type is invalid, and as a consequence CheckFunctionDeclaration() wasn't called and S::~S() didn't get merged into S's implicit destructor. This way, the class ended up with two destructors, which confused the overload printer when it suddenly had to print two possible destructors for `s.~S()`. In addition to fixing the crash, this change also seems to improve diagnostics in a few other places, see test changes. Crash found by SLi's bot. llvm-svn: 229639
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-181-2/+4
| | | | llvm-svn: 229637
* Revert r229543.Meador Inge2015-02-171-0/+2
| | | | | | Reverting this while build bot failures are investigated. llvm-svn: 229550
* Sema: Allow 'constexpr' variables in range loopsMeador Inge2015-02-171-2/+0
| | | | | | | | This fixes PR22492, which is in response to CWG issue #1204. Per the CWG issue 'contexpr' variables are now allowed in for range loops. llvm-svn: 229543
* Prefer SmallVector::append/insert over push_back loops. Clang edition.Benjamin Kramer2015-02-171-2/+1
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229508
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-151-1/+2
| | | | llvm-svn: 229282
* Make a reference const. No behavior change.Nico Weber2015-02-141-1/+1
| | | | llvm-svn: 229242
* Add a warning for direct-list-initialization of a variable with a deduced typeRichard Smith2015-02-111-0/+8
| | | | | | | | (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
* Sema: Don't give attribute alias vars with struct type an init exprDavid Majnemer2015-02-081-0/+2
| | | | | | | | | | We'd give the VarDecl a CXXConstructExpr even though it is annotated with an alias attribute. This would make us trip over sanity checking asserts. This fixes PR22493. llvm-svn: 228523
* [MSVC2012] Allow 'mutable' referencesAlexey Bataev2015-02-041-3/+6
| | | | | | | | 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
* Weaken an assertion that isn't true for invalid input.Nico Weber2015-01-301-2/+3
| | | | llvm-svn: 227540
* Revert "Sema: err_after_alias is unreachable, remove it"David Majnemer2015-01-211-1/+5
| | | | | | This reverts commit r226626. err_after_alias is, in fact, reachable. llvm-svn: 226633
* Sema: err_after_alias is unreachable, remove itDavid Majnemer2015-01-211-5/+1
| | | | | | | Examples this would have catched are now handled by the attribute verification code. llvm-svn: 226626
* Correct all typos in the initialization arguments, even if one could notKaelyn Takata2015-01-211-3/+4
| | | | | | | | | | be corrected. This fixes PR22250, which exposed the bug where if there's more than one TypoExpr in the arguments, once one failed to be corrected none of the TypoExprs after it would be handled at all thanks to an early return. llvm-svn: 226624
* Fix crashes on missing @interface for categoryBen Langmuir2015-01-201-1/+4
| | | | | | | In a few places we didn't check that Category->getClassInterface() was not null before using it. llvm-svn: 226605
* Add back a check removed in r226436David Majnemer2015-01-191-2/+12
| | | | | | | It shouldn't have been removed, the code which replaced it didn't cover this case. llvm-svn: 226442
* Sema: Variable definitions cannot be __attribute__((alias))David Majnemer2015-01-191-24/+14
| | | | | | | | | | | | | | | | | | | | Things that are OK: extern int var1 __attribute((alias("v1"))); static int var2 __attribute((alias("v2"))); Things that are not OK: int var3 __attribute((alias("v3"))); extern int var4 __attribute((alias("v4"))) = 4; We choose to accpet: struct S { static int var5 __attribute((alias("v5"))); }; This code causes assertion failues in GCC 4.8 and ICC 13.0.1, we have no reason to reject it. This partially fixes PR22217. llvm-svn: 226436
OpenPOWER on IntegriCloud