summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "r222906 - Create a new 'flag_enum' attribute."Hans Wennborg2015-01-201-78/+69
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_36@226593 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFCAlexey Bataev2015-01-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225624 91177308-0d34-0410-b5e6-96231b3b80d8
* DR1048: drop top-level cv-qualifiers when deducing the return type of aRichard Smith2014-12-191-1/+5
| | | | | | | lambda-expression in C++11, to match the C++14 rules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224620 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224329 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Don't leave switch stack inconsistent when recoveringDavid Majnemer2014-12-151-1/+2
| | | | | | | | | We would exit Sema::ActOnFinishSwitchStmt early if we didn't have a body. This would leave an extra SwitchStmt on the SwitchStack. This fixes PR21841. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224237 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Constexpr functions must have return statements which have an exprDavid Majnemer2014-12-131-4/+16
| | | | | | | | | | | | | | | clang lets programmers be pretty cavalier when it comes to void return statements in functions which have non-void return types. However, we cannot be so forgiving in constexpr functions: evaluation will go off the rails very quickly. Instead, keep the return statement in the AST but mark the function as invalid. Doing so gives us nice diagnostics while making constexpr evaluation halt. This fixes PR21859. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224189 91177308-0d34-0410-b5e6-96231b3b80d8
* Create a new 'flag_enum' attribute.Sean Hunt2014-11-281-69/+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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222906 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable ActOnIdExpression to use delayed typo correction for non-C++ codeKaelyn Takata2014-11-211-1/+6
| | | | | | when calling DiagnoseEmptyLookup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222551 91177308-0d34-0410-b5e6-96231b3b80d8
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-1/+18
| | | | | | | | | Sema::ActOnIdExpression to use the new functionality. Among other things, this allows recovery in several cases where it wasn't possible before (e.g. correcting a mistyped static_cast<>). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222464 91177308-0d34-0410-b5e6-96231b3b80d8
* PR21531: fix crash on invalid with unexpanded pack in case value.Richard Smith2014-11-201-8/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222400 91177308-0d34-0410-b5e6-96231b3b80d8
* Improved capturing variable-length array types in CapturedStmt.Alexey Bataev2014-10-291-0/+6
| | | | | | | | | An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas. This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP. Differential Revision: http://reviews.llvm.org/D5099 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220850 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: address post-commit review commentSaleem Abdulrasool2014-10-171-2/+2
| | | | | | | Hoist the IgnoreParens so that we ignore it around attributes as well in order to future-proof the code. Addresses Richard's comments for SVN r219974. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220053 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: handle additional case of qualified typesSaleem Abdulrasool2014-10-161-5/+8
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219974 91177308-0d34-0410-b5e6-96231b3b80d8
* No longer emit diagnostics about unused results (comparisons, etc) from ↵Aaron Ballman2014-10-161-0/+6
| | | | | | unevaluated contexts. Fixes PR18571. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219954 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: handle AttributedTypeLocs in C++14 auto deductionSaleem Abdulrasool2014-10-151-2/+5
| | | | | | | | | | | | | | When performing a type deduction from the return type, the FunctionDecl may be attributed with a calling convention. In such a case, the retrieved type location may be an AttributedTypeLoc. Performing a castAs<FunctionProtoTypeLoc> on such a type loc would result in an assertion as they are not derived types. Ensure that we correctly handle the attributed type location by looking through it to the modified type loc. Fixes an assertion triggered in C++14 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219851 91177308-0d34-0410-b5e6-96231b3b80d8
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-221-1/+5
| | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218230 91177308-0d34-0410-b5e6-96231b3b80d8
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217298 91177308-0d34-0410-b5e6-96231b3b80d8
* C++1y is now C++14!Aaron Ballman2014-08-191-1/+1
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215982 91177308-0d34-0410-b5e6-96231b3b80d8
* Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid ↵Craig Topper2014-08-171-8/+8
| | | | | | needing to mention the size. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215869 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow @synchronized to contextually convert a C++ object to an ObjC object ↵Jordan Rose2014-08-121-3/+18
| | | | | | | | pointer. Patch by Grant Paul! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215453 91177308-0d34-0410-b5e6-96231b3b80d8
* PR11778: Fix the rejects-valid half of this bug. We still produce the sameRichard Smith2014-08-041-63/+46
| | | | | | | | poorly-worded warning for a case value that is not a possible value of the switched-on expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214678 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r213437Warren Hunt2014-07-251-5/+6
| | | | | | | | | We no longer plan to use __except_hander3 and rather use custom personality functions per __try block. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213971 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Assign SEH handler indices to __try blocksWarren Hunt2014-07-191-6/+5
| | | | | | | | | | | Assigns indices to try blocks. These indices will used in constructing tables that the mscrt function __except_handler3 reads during SEH. Testing will occur once we actually emit the tables, in a subsequent patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213437 91177308-0d34-0410-b5e6-96231b3b80d8
* Objective-C. Patch to warn if the result of calling a property getter Fariborz Jahanian2014-07-181-3/+9
| | | | | | | | | is unused (this is match behavior when property-dot syntax is used to use same getter). rdar://17514245 Patch by Anders Carlsson with minor refactoring by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213423 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an AST node for __leave statements, hook it up.Nico Weber2014-07-071-1/+1
| | | | | | | | Codegen is still missing (and I won't work on that), but __leave is now as implemented as __try and friends. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212425 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Check that __leave is contained in a __try block.Nico Weber2014-07-061-0/+6
| | | | | | | | | | Give scope a SEHTryScope bit, set that in ParseSEHTry(), and let Sema walk the scope chain to find the SEHTry parent on __leave statements. (They are rare enough that it seems better to do the walk instead of giving Scope a SEHTryParent pointer -- this is similar to AtCatchScope.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212422 91177308-0d34-0410-b5e6-96231b3b80d8
* Add parser support for __leave (sema and onward still missing).Nico Weber2014-07-061-0/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212421 91177308-0d34-0410-b5e6-96231b3b80d8
* Import MutableArrayRef into clang namespace.Craig Topper2014-06-281-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211988 91177308-0d34-0410-b5e6-96231b3b80d8
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-9/+5
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211005 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Loop canonical form analysis (Sema)Alexander Musman2014-06-031-0/+6
| | | | | | | | | | | This patch implements semantic analysis to make sure that the loop is in OpenMP canonical form. This is the form required for 'omp simd', 'omp for' and other loop pragmas. Differential revision: http://reviews.llvm.org/D3778 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210095 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-59/+50
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209812 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-42/+42
| | | | | | takeAs to getAs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209800 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-32/+33
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209613 91177308-0d34-0410-b5e6-96231b3b80d8
* Improved recovery of switch statementSerge Pavlov2014-05-211-2/+4
| | | | | | | | | | Make better diagnostic produced by erroneous switch statement. It fixes PR19022. Differential Revision: http://reviews.llvm.org/D3137 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209302 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Fix warning in Release builds.Alexey Bataev2014-05-141-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208768 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Initial codegen for '#pragma omp parallel'Alexey Bataev2014-05-061-15/+57
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208077 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite NRVO determination. Track NRVO candidates on the parser Scope and ↵Nick Lewycky2014-05-031-40/+67
| | | | | | | | | apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal. Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207890 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement [over.match.oper]p3 properly, by filtering the non-candidates outRichard Smith2014-04-171-1/+2
| | | | | | | | when building the candidate set, rather than trying to contort name lookup into handling this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206436 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with ↵Aaron Ballman2014-03-141-5/+4
| | | | | | iterator_range decls(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203947 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-14/+14
| | | | | | class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203640 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the warning about unused relational comparison from -Wunused-value toRichard Trieu2014-03-111-7/+20
| | | | | | | | -Wunused-comparison. Also, newly warn on unused result from overloaded relational comparisons, now also in -Wunused-comparison. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203535 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverting llvm::distance changes to use std::distance with iterators ↵Aaron Ballman2014-03-101-2/+1
| | | | | | | | instead, per post-commit review feedback. Replacing llvm::copy changes with SmallVector range-based construction which is a considerably cleaner approach. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203461 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-081-3/+1
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203355 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing EnumDecl iterators enumerator_begin() and enumerator_end() ↵Aaron Ballman2014-03-081-6/+4
| | | | | | with iterator_range enumerators(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203353 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename getResultLoc() tooAlp Toker2014-01-251-1/+1
| | | | | | | | Follow up to r200082. Spotted by Dmitri git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200105 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-6/+6
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
* Combine the checks for returns_nonnull and for operator new returning null, ↵Artyom Skrobov2014-01-241-23/+2
| | | | | | in Sema::CheckReturnValExpr. Add the missing handling of value-dependent expressions for returns_nonnull. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199989 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix to PR8880 (clang dies processing a for loop)Serge Pavlov2014-01-231-12/+44
| | | | | | | | | | | | | | | | | | | | | | | | Due to statement expressions supported as GCC extension, it is possible to put 'break' or 'continue' into a loop/switch statement but outside its body, for example: for ( ; ({ if (first) { first = 0; continue; } 0; }); ) This code is rejected by GCC if compiled in C mode but is accepted in C++ code. GCC bug 44715 tracks this discrepancy. Clang used code generation that differs from GCC in both modes: only statement of the third expression of 'for' behaves as if it was inside loop body. This change makes code generation more close to GCC, considering 'break' or 'continue' statement in condition and increment expressions of a loop as it was inside the loop body. It also adds error for the cases when 'break'/'continue' appear outside loop due to this syntax. If code generation differ from GCC, warning is issued. Differential Revision: http://llvm-reviews.chandlerc.com/D2518 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199897 91177308-0d34-0410-b5e6-96231b3b80d8
* Add basic checking for returning null from functions/methods marked ↵Ted Kremenek2014-01-221-2/+10
| | | | | | | | | | 'returns_nonnull'. This involved making CheckReturnStackAddr into a static function, which is now called by a top-level return value checking routine called CheckReturnValExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199790 91177308-0d34-0410-b5e6-96231b3b80d8
* Issue a warning if a throwing operator new or operator new[] returns a nullRichard Smith2014-01-171-0/+22
| | | | | | | | | pointer, since this invokes undefined behavior. Based on a patch by Artyom Skrobov! Handling of dependent exception specifications and some additional testcases by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199452 91177308-0d34-0410-b5e6-96231b3b80d8