summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Sema] Minor formatting fixes. NFCCraig Topper2015-11-171-1/+1
| | | | llvm-svn: 253314
* Tweak how -Wunused-value interacts with macrosNico Weber2015-10-271-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Make the warning more strict in C mode. r172696 added code to suppress warnings from macro expansions in system headers, which checks `SourceMgr.isMacroBodyExpansion(E->IgnoreParens()->getExprLoc())`. Consider this snippet: #define FOO(x) (x) void f(int a) { FOO(a); } In C, the line `FOO(a)` is an `ImplicitCastExpr(ParenExpr(DeclRefExpr))`, while it's just a `ParenExpr(DeclRefExpr)` in C++. So in C++, `E->IgnoreParens()` returns the `DeclRefExpr` and the check tests the SourceLoc of `a`. In C, the `ImplicitCastExpr` has the effect of checking the SourceLoc of `FOO`, which is a macro body expansion, which causes the diagnostic to be skipped. It looks unintentional that clang does different things for C and C++ here, so use `IgnoreParenImpCasts` instead of `IgnoreParens` here. This has the effect of the warning firing more often than previously in C code – it now fires as often as it fires in C++ code. 2. Suppress the warning if it would warn on `UNREFERENCED_PARAMETER`. `UNREFERENCED_PARAMETER` is a commonly used macro on Windows and it happens to uselessly trigger -Wunused-value. As discussed in the thread "rfc: winnt.h's UNREFERENCED_PARAMETER() vs clang's -Wunused-value" on cfe-dev, fix this by special-casing this specific macro. (This costs a string comparison and some fast-path lexing per warning, but the warning is emitted rarely. It fires once in Windows.h itself, so this code runs at least once per TU including Windows.h, but it doesn't run hundreds of times.) http://reviews.llvm.org/D13969 llvm-svn: 251441
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-28/+55
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* [coroutines] Initial stub Sema functionality for handling coroutine await / ↵Richard Smith2015-10-221-6/+20
| | | | | | yield / return. llvm-svn: 250993
* Keep the IfStmt node even if the condition is invalidOlivier Goffart2015-10-111-17/+11
| | | | | | | This is important to keep the information in IDE or other tools even if the code contains a few errors llvm-svn: 249982
* Perform Objective-C lifetime adjustments before comparing deduced lambda ↵Douglas Gregor2015-10-011-2/+5
| | | | | | | | | | result types. Objective-C ARC lifetime qualifiers are dropped when canonicalizing function types. Perform the same adjustment before comparing the deduced result types of lambdas. Fixes rdar://problem/22344904. llvm-svn: 249065
* Simplify Sema::DeduceFunctionTypeFromReturnExpr and eliminae a redundant check.Douglas Gregor2015-10-011-7/+2
| | | | | | NFC llvm-svn: 249060
* Fix a potential APInt memory leak when using __attribute__((flag_enum)), andRichard Smith2015-09-041-3/+1
| | | | | | simplify the implementation a bit. llvm-svn: 246830
* fix typo; NFCSanjay Patel2015-08-281-1/+1
| | | | llvm-svn: 246303
* [AST] Turn the callbacks of lookupInBases and forallBases into a function_refBenjamin Kramer2015-07-251-9/+6
| | | | | | | | | 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
* Re-enable 32-bit SEH after the alignment fixReid Kleckner2015-07-101-0/+4
| | | | llvm-svn: 241878
* Disable 32-bit SEH, againReid Kleckner2015-07-081-4/+0
| | | | | | | | Move the diagnostic back to codegen so that we can compile ATL on the self-host bot. We don't actually end up emitting code for the __try, so the diagnostic won't be hit. llvm-svn: 241761
* Revert "Revert 241171, 241187, 241199 (32-bit SEH)."Reid Kleckner2015-07-071-0/+5
| | | | | | | | | | | This reverts commit r241244, but restricts SEH support to Win64. This way, Chromium builds will still fall back on TUs with SEH, and Clang developers can work on this incrementally upstream while patching this small predicate locally. It'll also make it easier to review small fixes. llvm-svn: 241533
* Revert 241171, 241187, 241199 (32-bit SEH).Nico Weber2015-07-021-5/+0
| | | | | | | It still doesn't produce quite the right code, test binaries built with this enabled fail some tests. llvm-svn: 241244
* [SEH] Add 32-bit lowering for SEH __tryReid Kleckner2015-07-011-0/+5
| | | | | | | | | | | | | | | | | | | This re-lands r236052 and adds support for __exception_code(). In 32-bit SEH, the exception code is not available in eax. It is only available in the filter function, and now we arrange to load it and store it into an escaped variable in the parent frame. As a consequence, we have to disable the "catch i8* null" optimization on 32-bit and always generate a filter function. We can re-enable the optimization if we detect an __except block that doesn't use the exception code, but this probably isn't worth optimizing. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D10852 llvm-svn: 241171
* [Parse] Allow 'constexpr' in condition declarationsMeador Inge2015-06-251-6/+7
| | | | | | | | | | | | | | | | | This patch implements the functionality specified by DR948. The changes are two fold. First, the parser was modified to allow 'constexpr's to appear in condition declarations (which was a hard error before). Second, Sema was modified to cleanup maybe odr-used declarations by way of a call to 'ActOnFinishFullExpr'. As 'constexpr's were not allowed in condition declarations before the cleanup wasn't necessary (such declarations were always odr-used). This fixes PR22491. Differential Revision: http://reviews.llvm.org/D8978 llvm-svn: 240707
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-6/+6
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-6/+6
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Fix "the the" in comments/documentation/etc.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240110
* Revert "Re-land r236052, "[SEH] Add 32-bit lowering code for __try""Reid Kleckner2015-06-091-5/+0
| | | | | | | This reverts commit r239415. This was committed accidentally, LLVM isn't ready for this. llvm-svn: 239417
* Re-land r236052, "[SEH] Add 32-bit lowering code for __try"Reid Kleckner2015-06-091-0/+5
| | | | | | | | This reverts r236167. LLVM should be ready for this now. llvm-svn: 239415
* When performing delayed typo correction in a for-range loop's variableKaelyn Takata2015-05-071-0/+9
| | | | | | | declaration, ensure the loop variable is properly marked as invalid when it is an "auto" variable. llvm-svn: 236682
* Make helper functions static. NFC.Benjamin Kramer2015-05-011-0/+2
| | | | llvm-svn: 236315
* 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
OpenPOWER on IntegriCloud