summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert most of r236271, leaving only the datalayout change in ↵Reid Kleckner2015-04-301-5/+0
| | | | | | lib/Basic/Targets.cpp llvm-svn: 236274
* Use 4 byte preferred aggregate alignment in datalayout on x86 Win32Reid Kleckner2015-04-301-0/+5
| | | | llvm-svn: 236271
* Revert r236128, LLVM isn't falling back in the right wayReid Kleckner2015-04-291-5/+0
| | | | llvm-svn: 236167
* Re-land r236052, the linker errors were fixed by LLVM r236123Reid Kleckner2015-04-291-0/+5
| | | | | | | Basic __finally blocks don't cause linker errors anymore (although they are miscompiled). llvm-svn: 236128
* Revert r236052, it caused linker errors when building 32-bit applications.Nico Weber2015-04-291-5/+0
| | | | llvm-svn: 236082
* [SEH] Add 32-bit lowering code for __tryReid Kleckner2015-04-281-0/+5
| | | | | | | | | | | | | | | | | | | | This is just the clang-side of 32-bit SEH. LLVM still needs work, and it will determinstically fail to compile until it's feature complete. On x86, all outlined handlers have no parameters, but they do implicitly take the EBP value passed in and use it to address locals of the parent frame. We model this with llvm.frameaddress(1). This works (mostly), but __finally block inlining can break it. For now, we apply the 'noinline' attribute. If we really want to inline __finally blocks on 32-bit x86, we should teach the inliner how to untangle frameescape and framerecover. Promote the error diagnostic from codegen to sema. It now rejects SEH on non-Windows platforms. LLVM doesn't implement SEH on non-x86 Windows platforms, but there's nothing preventing it. llvm-svn: 236052
* Add new warning -Wrange-loop-analysis to warn on copies during loops.Richard Trieu2015-04-131-0/+152
| | | | | | | | | | | | -Wrange-loop-analysis is a subgroup of -Wloop-analysis and will warn when a range-based for-loop makes copies of the elements in the range. If possible, suggest the proper type to prevent copies, or the non-reference to help distinguish copy versus non-copy forms. Existing warnings in -Wloop-analysis are moved to -Wfor-loop-analysis, also a subgroup of -Wloop-analysis. Differential Revision: http://reviews.llvm.org/D4169 llvm-svn: 234804
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Appease build bots that cannot find a viable conversion through CanQualType.Aaron Ballman2015-04-081-1/+2
| | | | llvm-svn: 234376
* Generate a diagnostic when a catch handler cannot execute due to class ↵Aaron Ballman2015-04-081-57/+153
| | | | | | hierarchy inversion with regards to other catch handlers for the same block. llvm-svn: 234375
* [Sema] Factor diags with %plural. No functionality change intended.Benjamin Kramer2015-03-271-23/+9
| | | | llvm-svn: 233387
* Fix gcc ambiguity error (Visual C++ was OK with these).Yaron Keren2015-03-181-3/+3
| | | | llvm-svn: 232623
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-3/+3
| | | | | | | | | | | | | | | 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 theoretical bug when ParseCompoundStatement() returns StmtError.Nico Weber2015-03-091-0/+4
| | | | | | | | ParseCompoundStatement() currently never returns StmtError, but if it did, Sema would keep the __finally scope on its stack indefinitely. Explicitly add an error callback that clears it. llvm-svn: 231625
* Warn when jumping out of a __finally block via continue, break, return, __leave.Nico Weber2015-03-091-4/+20
| | | | | | | | | | | | | | | Since continue, break, return are much more common than __finally, this tries to keep the work for continue, break, return O(1). Sema keeps a stack of active __finally scopes (to do this, ActOnSEHFinally() is split into ActOnStartSEHFinally() and ActOnFinishSEHFinally()), and the various jump statements then check if the current __finally scope (if present) is deeper than then destination scope of the jump. The same warning for goto statements is still missing. This is the moral equivalent of MSVC's C4532. llvm-svn: 231623
* Fix typo in comment.Nico Weber2015-03-091-1/+1
| | | | llvm-svn: 231622
* [Objctive-C sema]. Do not do the unused-getter-return-valueFariborz Jahanian2015-02-161-4/+0
| | | | | | | warning when property getter is used in direct method call and return value of property is unused. rdar://19773512 llvm-svn: 229458
* Partial revert of r229336; this wasn't intended to go in.Aaron Ballman2015-02-151-126/+53
| | | | llvm-svn: 229338
* Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the ↵Aaron Ballman2015-02-151-53/+126
| | | | | | macro. NFC; Clang edition. llvm-svn: 229336
* Re-land r228258 and make clang-cl's /EHs- disable -fexceptions againReid Kleckner2015-02-051-9/+24
| | | | | | | | | | | After r228258, Clang started emitting C++ EH IR that LLVM wasn't ready to deal with, even when exceptions were disabled with /EHs-. This time, make /EHs- turn off -fexceptions while still emitting exceptional constructs in functions using __try. Since Sema rejects C++ exception handling constructs before CodeGen, landingpads should only appear in such functions as the result of a __try. llvm-svn: 228329
* Revert r228258.Nico Weber2015-02-051-24/+9
| | | | | | | | | It caused a chromium base unittest that tests throwing and catching SEH exceptions to fail (http://crbug.com/455488) and I suspect it might also be the cause of the chromium clang win 64-bit shared release builder timing out during compiles. So revert to see if that's true. llvm-svn: 228262
* SEH: Track users of __try so we can pick a per-func EH personalityReid Kleckner2015-02-031-9/+24
| | | | | | | | | | | | | | | | | | There are four major kinds of declarations that cause code generation: - FunctionDecl (includes CXXMethodDecl etc) - ObjCMethodDecl - BlockDecl - CapturedDecl This patch tracks __try usage on FunctionDecls and diagnoses __try usage in other decls. If someone wants to use __try from ObjC, they can use it from a free function, since the ObjC code will need an ObjC-style EH personality. Eventually we will want to look through CapturedDecls and track SEH usage on the parent FunctionDecl, if present. llvm-svn: 228058
* SEH: Diagnose use of C++ EH and SEH in the same functionReid Kleckner2015-02-021-8/+20
| | | | | | | | This check does not apply when Borland extensions are enabled, as they have a checked in test case indicating that mixed usage of SEH and C++ is supported. llvm-svn: 227876
* Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFCAlexey Bataev2015-01-121-1/+1
| | | | llvm-svn: 225624
* 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. llvm-svn: 224620
* 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
* 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. llvm-svn: 224237
* 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. llvm-svn: 224189
* Create a new 'flag_enum' attribute.Alexis 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. llvm-svn: 222906
* Enable ActOnIdExpression to use delayed typo correction for non-C++ codeKaelyn Takata2014-11-211-1/+6
| | | | | | when calling DiagnoseEmptyLookup. llvm-svn: 222551
* 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<>). llvm-svn: 222464
* PR21531: fix crash on invalid with unexpanded pack in case value.Richard Smith2014-11-201-8/+13
| | | | llvm-svn: 222400
* 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 llvm-svn: 220850
* 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. llvm-svn: 220053
* 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. llvm-svn: 219974
* No longer emit diagnostics about unused results (comparisons, etc) from ↵Aaron Ballman2014-10-161-0/+6
| | | | | | unevaluated contexts. Fixes PR18571. llvm-svn: 219954
* 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. llvm-svn: 219851
* 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 llvm-svn: 218230
* 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.) llvm-svn: 217298
* 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. llvm-svn: 215982
* Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid ↵Craig Topper2014-08-171-8/+8
| | | | | | needing to mention the size. llvm-svn: 215869
* Allow @synchronized to contextually convert a C++ object to an ObjC object ↵Jordan Rose2014-08-121-3/+18
| | | | | | | | pointer. Patch by Grant Paul! llvm-svn: 215453
* 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. llvm-svn: 214678
* Revert r213437Warren Hunt2014-07-251-5/+6
| | | | | | | We no longer plan to use __except_hander3 and rather use custom personality functions per __try block. llvm-svn: 213971
* [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. llvm-svn: 213437
* 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. llvm-svn: 213423
* 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. llvm-svn: 212425
* 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.) llvm-svn: 212422
* Add parser support for __leave (sema and onward still missing).Nico Weber2014-07-061-0/+5
| | | | llvm-svn: 212421
* Import MutableArrayRef into clang namespace.Craig Topper2014-06-281-2/+2
| | | | llvm-svn: 211988
OpenPOWER on IntegriCloud