summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Sema: Don't crash when an inject class name has a nested redefinitionDavid Majnemer2014-12-281-3/+2
| | | | | | | | | We expected the type of a TagDecl to be a TagType, not an InjectedClassNameType. Introduced a helper method, Type::getAsTagDecl, to abstract away the difference; redefine Type::getAsCXXRecordDecl to be in terms of it. llvm-svn: 224898
* Try typo correction on all initialization arguments and be lessKaelyn Takata2014-12-161-7/+5
| | | | | | | | | pessimistic about when to do so. This also fixes PR21905 as the initialization argument was no longer viewed as being type dependent due to the TypoExpr being type-cast. llvm-svn: 224386
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-1/+1
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
* Warn when attribute 'optnone' conflicts with attributes on aPaul Robinson2014-12-151-0/+6
| | | | | | different declaration of the same function. llvm-svn: 224256
* Create a new 'flag_enum' attribute.Alexis Hunt2014-11-281-8/+78
| | | | | | | | | | | This attribute serves as a hint to improve warnings about the ranges of enumerators used as flag types. It currently has no working C++ implementation due to different semantics for enums in C++. For more explanation, see the docs and testcases. Reviewed by Aaron Ballman. llvm-svn: 222906
* When checking for uninitialized values, do not confuse "std::move" with everyRichard Trieu2014-11-271-1/+2
| | | | | | other function named "move". llvm-svn: 222863
* Properly correct initializer expressions based on whether they would be valid.Kaelyn Takata2014-11-211-0/+17
| | | | llvm-svn: 222550
* Fix missing diagnostic for unsupported TLS for some thread_local variables.Bob Wilson2014-11-211-16/+14
| | | | | | | | | Clang r181627 moved a check for block-scope variables into this code for handling thread storage class specifiers, but in the process, it broke the logic for checking if the target supports TLS. Fix this with some simple restructuring of the code. rdar://problem/18796883 llvm-svn: 222512
* Fix an assertion when ending a function definition.John McCall2014-11-181-1/+2
| | | | | | | | | | | | | | | | | | | | The bug is that ExprCleanupObjects isn't always empty in a fresh evaluation context. New evaluation contexts just track the current depth of the stack. The assertion will misfire whenever we finish processing a function body inside an expression that contained an earlier block literal with non-trivial captures. That's actually a lot less likely than you'd think, though, because it has to be a real function declaration, not just another block. Mixed block/lambda code would work, as would a template instantiation or a local class definition. The code works correctly if the assertion is disabled. rdar://16356628 llvm-svn: 222194
* Remove some redundant virtual specifiers on overriden functions.David Blaikie2014-11-141-1/+1
| | | | llvm-svn: 222024
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-0/+1
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* Move the no-prototype calling conv check after decl mergingReid Kleckner2014-11-031-13/+14
| | | | | | | | | | | Now we don't warn on this code: void __stdcall f(void); void __stdcall f(); My previous commit regressed this functionality because I didn't update the relevant test case which used a definition. llvm-svn: 221188
* Don't diagnose no-prototype callee-cleanup function definitionsReid Kleckner2014-11-031-15/+15
| | | | | | | | | | | | We already have a warning on the call sites of code like this: void f() { } void g() { f(1, 2, 3); } t.c:2:21: warning: too many arguments in call to 'f' We can limit ourselves to diagnosing unprototyped forward declarations of f to cut down on noise. llvm-svn: 221184
* Don't dllimport inline functions when targeting MinGW (PR21366)Hans Wennborg2014-11-031-0/+8
| | | | | | | | | | | | It turns out that MinGW never dllimports of exports inline functions. This means that code compiled with Clang would fail to link with MinGW-compiled libraries since we might try to import functions that are not imported. To fix this, make Clang never dllimport inline functions when targeting MinGW. llvm-svn: 221154
* Have -Wuninitialized catch uninitalized use in overloaded operator arguments.Richard Trieu2014-10-311-4/+7
| | | | llvm-svn: 221000
* Remove StorageClass typedefs from VarDecl and FunctionDecl since ↵Craig Topper2014-10-311-14/+11
| | | | | | StorageClass is in the clang namespace. llvm-svn: 220956
* Follow-up to r216619: use isCXXCLassMember() instead of trying toHans Wennborg2014-10-291-1/+1
| | | | | | | check the context ourselves when selectively allowing late-added dll attributes on unused free functions and variables (PR20746) llvm-svn: 220874
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-29/+28
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* Add frontend support for __vectorcallReid Kleckner2014-10-241-2/+2
| | | | | | | | | | | | | Wire it through everywhere we have support for fastcall, essentially. This allows us to parse the MSVC "14" CTP headers, but we will miscompile them because LLVM doesn't support __vectorcall yet. Reviewed By: Aaron Ballman Differential Revision: http://reviews.llvm.org/D5808 llvm-svn: 220573
* Add RestrictQualifierLoc to DeclaratorChunk::FunctionTypeInfoHal Finkel2014-10-201-0/+1
| | | | | | | | | | | | | | Clang supports __restrict__ as a function qualifier, but DeclaratorChunk::FunctionTypeInfo lacked a field to track the qualifier's source location (as we do with volatile, etc.). This was the subject of a FIXME in GetFullTypeForDeclarator (in SemaType.cpp). This should also prove useful as we add more warnings regarding questionable uses of the restrict qualifier. There is no significant functional change (except for an improved source range associated with the err_invalid_qualified_function_type diagnostic fixit generated by GetFullTypeForDeclarator). llvm-svn: 220215
* Sema: handle additional case of qualified typesSaleem Abdulrasool2014-10-161-2/+1
| | | | | | | | | | | | | | | A second instance of attributed types escaped the previous change, identified thanks to Richard Smith! When deducing the void case, we would also assume that the type would not be attributed. Furthermore, properly handle multiple attributes being applied to a single TypeLoc. Properly handle this case and future-proof a bit by ignoring parenthesis further. The test cases do use the additional parenthesis to ensure that this case remains properly handled. Addresses post-commit review comments from Richard Smith to SVN r219851. llvm-svn: 219974
* MS Compat: mark globals emitted in read-only sections constHans Wennborg2014-10-161-4/+6
| | | | | | | | | | | | | | | | | | | | They cannot be written to, so marking them const makes sense and may improve optimisation. As a side-effect, SectionInfos has to be moved from Sema to ASTContext. It also fixes this problem, that occurs when compiling ATL: warning LNK4254: section 'ATL' (C0000040) merged into '.rdata' (40000040) with different attributes The ATL headers are putting variables in a special section that's marked read-only. However, Clang currently can't model that read-onlyness in the IR. But, by making the variables const, the section does become read-only, and the linker warning is avoided. Differential Revision: http://reviews.llvm.org/D5812 llvm-svn: 219960
* Adding attributes to the IndirectFieldDecl that we generate for anonymous ↵Aaron Ballman2014-10-151-4/+6
| | | | | | struct/union fields. This fixes PR20930. llvm-svn: 219807
* -ms-extensions: Allow __super in return stements.Nikola Smiljanic2014-10-041-5/+1
| | | | llvm-svn: 219050
* MS ABI: Disallow dllimported/exported variables from having TLSDavid Majnemer2014-10-041-1/+12
| | | | | | | | | | | | | | | | | | | Windows TLS relies on indexing through a tls_index in order to get at the DLL's thread local variables. However, this index is not exported along with the variable: it is assumed that all accesses to thread local variables are inside the same module which created the variable in the first place. While there are several implementation techniques we could adopt to fix this (notably, the Itanium ABI gets this for free), it is not worth the heroics. Instead, let's just ban this combination. We could revisit this in the future if we need to. This fixes PR21111. llvm-svn: 219049
* Sema: Simplify checkAttributesAfterMergingDavid Majnemer2014-10-041-8/+1
| | | | | | Use getDLLAttr to factor out some common dllimport/dllexport code. llvm-svn: 219048
* Update -Wuninitialized to be stricter on CK_NoOp casts.Richard Trieu2014-09-301-5/+10
| | | | llvm-svn: 218715
* Add back checking for condition of conditional operator for -WuninitializedRichard Trieu2014-09-261-0/+1
| | | | llvm-svn: 218556
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+8
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Add increment/decrement operators and compound assignment operators to theRichard Trieu2014-09-251-0/+16
| | | | | | uninitialized checkers that did not have them before. llvm-svn: 218435
* Sema: Inherit the flexible array property from struct fieldsDavid Majnemer2014-09-241-9/+6
| | | | | | | | A record which contains a flexible array member is itself a flexible array member. A struct which contains such a record should also consider itself to be a flexible array member. llvm-svn: 218378
* Fix an edge case with BinaryOperator's in -Wuninitialized. Add testcases forRichard Trieu2014-09-241-2/+4
| | | | | | the other visitors as well. llvm-svn: 218366
* Improve -Wuninitialized to take into account field ordering with initializerRichard Trieu2014-09-231-1/+87
| | | | | | | lists. Since the fields are inititalized one at a time, using a field with lower index to initialize a higher indexed field should not be warned on. llvm-svn: 218339
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-221-2/+8
| | | | | | | | | | | | | | | | Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
* Follow-up to r214408: Warn on other callee-cleanup functions without ↵Nico Weber2014-09-191-5/+9
| | | | | | | | | | | | | | | | | | prototype too. According to lore, we used to verifier-fail on: void __thiscall f(); int main() { f(1); } So that's fixed now. System headers use prototype-less __stdcall functions, so make that a warning that's DefaultError -- then it fires on regular code but is suppressed in system headers. Since it's used in system headers, we have codegen tests for this; massage them slightly so that they still compile. llvm-svn: 218166
* Sema: Diagnose undefined structs used as Microsoft anonymous structsDavid Majnemer2014-09-181-5/+11
| | | | | | | | | | | | | | | Previously, we would not mark structs containing anonymous structs as invalid. Later, horrific things would occur when trying to determine the size of the parent record. Instead, require the struct to be a complete type when used as an anonymous struct. Mark both the anonymous field for the struct and the parent context as invalid (this is similar to what we do when a struct contains a field with an incomplete type.) This fixes PR11847. llvm-svn: 218006
* Allow empty statements in naked functions in addition to ASM statementsEhsan Akhgari2014-09-091-1/+1
| | | | | | | | | | | | Summary: This fixes PR20883. Test Plan: The patch includes an automated test. Reviewers: hansw Differential Revision: http://reviews.llvm.org/D5256 llvm-svn: 217413
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Stop double visiting some expressions during self reference checking.Richard Trieu2014-09-041-5/+17
| | | | | | | | Originally, self reference checking made a double pass over some expressions to handle reference type checking. Now, allow HandleValue to also check reference types, and fallback to Visit for unhandled expressions. llvm-svn: 217203
* Don't allow non-ASM statements in naked functionsHans Wennborg2014-09-041-0/+11
| | | | | | | | | | Naked functions don't have prologues or epilogues, so doing codegen for anything other than inline assembly would be completely hit or miss. Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217199
* Don't load invalid enum value in Sema::LazilyCreateBuiltin.Alexey Samsonov2014-08-281-10/+8
| | | | | | This bug was reported by UBSan. llvm-svn: 216696
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-0/+4
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* More -Wuninitialized updatesRichard Trieu2014-08-271-4/+19
| | | | | | | | | | | Fix r216438 to catch more complicated self-initialized in std::move. For instance, "Foo f = std::move(cond ? OtherFoo : (UNUSED_VALUE, f));" Make sure that BinaryConditionalOperator, ConditionalOperator, BinaryOperator with comma operator, and OpaqueValueExpr perform the correct usage forwarding across the three uninitialized value checkers. llvm-svn: 216627
* Allow adding dll attributes on certain redecls with a warning if the decl ↵Hans Wennborg2014-08-271-6/+23
| | | | | | | | | | | | hasn't been used yet (PR20746) This shouldn't really be allowed, but it comes up in real code (see PR). As long as the decl hasn't been used there's no technical difficulty in supporting it, so downgrade the error to a warning. Differential Revision: http://reviews.llvm.org/D5087 llvm-svn: 216619
* Clarify comment so this doesn't appear to be a C11-only rule.Richard Smith2014-08-261-0/+3
| | | | llvm-svn: 216490
* revert patch r216469.Fariborz Jahanian2014-08-261-1/+1
| | | | llvm-svn: 216485
* c11- Check for c11 language option as documentation saysFariborz Jahanian2014-08-261-1/+1
| | | | | | | | feature is c11 about nested struct declarations must have struct-declarator-list. Without this change, code which was meant for c99 breaks. rdar://18125536 llvm-svn: 216469
* Passing a variable to std::move now counts as a use for -WuninitializedRichard Trieu2014-08-261-0/+15
| | | | llvm-svn: 216438
* PR20716 - Crash when recovering from type in known dependent base.Nikola Smiljanic2014-08-241-1/+4
| | | | llvm-svn: 216352
* Fix PR20705, crash on invalid.Richard Trieu2014-08-221-1/+1
| | | | | | dyn_cast -> dyn_cast_or_null to handle a null pointer. llvm-svn: 216254
OpenPOWER on IntegriCloud