summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/JumpDiagnostics.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-8/+8
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-2/+2
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [ObjC] Allow declaring __strong pointer fields in structs in Objective-CAkira Hatanaka2018-02-281-0/+8
| | | | | | | | | | | | | | | | | | | | | ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-1/+1
| | | | llvm-svn: 321115
* [Sema][ObjC] Disallow jumping into ObjC fast enumeration loops.Akira Hatanaka2017-04-191-0/+9
| | | | | | | | rdar://problem/31635406 Differential Revision: https://reviews.llvm.org/D32187 llvm-svn: 300722
* [Sema] Handle CaseStmt and DefaultStmt as SwitchCaseVitaly Buka2016-10-261-4/+2
| | | | | | | | Summary: rsmith Differential Revision: https://reviews.llvm.org/D25665 llvm-svn: 285159
* [ObjC] Warn on unguarded use of partial declarationErik Pilkington2016-08-161-10/+7
| | | | | | | | | | | | | | This commit adds a traversal of the AST after Sema of a function that diagnoses unguarded references to declarations that are partially available (based on availability attributes). This traversal is only done when we would otherwise emit -Wpartial-availability. This commit is part of a feature I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential revision: https://reviews.llvm.org/D23003 llvm-svn: 278826
* P0305R0: Semantic analysis and code generation for C++17 init-statement for ↵Richard Smith2016-07-141-8/+12
| | | | | | | | | | 'if' and 'switch': if (stmt; condition) { ... } Patch by Anton Bikineev! Some minor formatting and comment tweets by me. llvm-svn: 275350
* Implement p0292r2 (constexpr if), a likely C++1z feature.Richard Smith2016-06-231-0/+31
| | | | llvm-svn: 273602
* Refactor scope building in JumpDiagnostics for simplicity. This fixes aRichard Smith2016-06-211-132/+151
| | | | | | | | | | | | (currently theoretical) bug where recursive calls to BuildScopeInformation would do the wrong thing if the type of the statement is one of the kinds with special handling, but this is not currently observable because the relevant recursive calls happen to all be for CompoundStmts. (This becomes visible with the C++17 'constexpr if' feature, where we get a protected scope for the 'then' / 'else' cases of some 'if's, and don't necessarily have a corresponding compound statement.) llvm-svn: 273309
* Some minor ARC diagnostic improvements.John McCall2015-10-211-2/+5
| | | | llvm-svn: 250917
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-2/+1
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* Test commit access.Hubert Tong2015-06-041-17/+17
| | | | | | Fixes trailing whitespace in lib/Sema/JumpDiagnostics.cpp. llvm-svn: 239112
* Warn when jumping out of a __finally block via goto.Nico Weber2015-03-091-0/+12
| | | | | | | | | | | | | | This only warns on direct gotos and indirect gotos with a unique label (`goto *&&label;`). Jumping out ith a true indirect goto is already an error. This isn't O(1), but goto statements are less common than continue, break, and return. Also, the GetDeepestCommonScope() call in the same function does the same amount of work, so this isn't worse than what's there in a complexity sense, and it should be pretty fast in practice. This is the last piece that was missing in r231623. llvm-svn: 231628
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-031-5/+8
| | | | llvm-svn: 228063
* Implement jump scope SEHmantic analysis.Nico Weber2015-02-031-3/+29
| | | | | | | | | | | | | | | | | | | Thou shall not jump into SEH blocks. Jumping out of SEH __try and __excepts is A-ok. Jumping out of __finally blocks is B-ok (msvc doesn't error about it, but warns that it has undefined behavior). I've checked that clang's behavior with this patch matches msvc's behavior. We don't have the warning on jumping out of a __finally yet, see the FIXME in the test. clang also currently crashes on codegen for a jump out of a __finally block, see PR22414 comment 7. I also added a few tests for the interaction of indirect jumps and SEH blocks. MSVC doesn't support indirect jumps, so there's no way to know if clang behave the same way as msvc here. clang's behavior with this patch does make sense to me, but maybe it could be argued that it should be more permissive (see FIXME in the indirect jump tests -- shout if you have an opinion on this). llvm-svn: 227982
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lowering looks a lot like normal EH lowering, with the exception that the exceptions are caught by executing filter expression code instead of matching typeinfo globals. The filter expressions are outlined into functions which are used in landingpad clauses where typeinfo would normally go. Major aspects that still need work: - Non-call exceptions in __try bodies won't work yet. The plan is to outline the __try block in the frontend to keep things simple. - Filter expressions cannot use local variables until capturing is implemented. - __finally blocks will not run after exceptions. Fixing this requires work in the LLVM SEH preparation pass. The IR lowering looks like this: // C code: bool safe_div(int n, int d, int *r) { __try { *r = normal_div(n, d); } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) { return false; } return true; } ; LLVM IR: define i32 @filter(i8* %e, i8* %fp) { %ehptrs = bitcast i8* %e to i32** %ehrec = load i32** %ehptrs %code = load i32* %ehrec %matches = icmp eq i32 %code, i32 u0xC0000094 %matches.i32 = zext i1 %matches to i32 ret i32 %matches.i32 } define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) { %rr = invoke i32 @normal_div(i32 %n, i32 %d) to label %normal unwind to label %lpad normal: store i32 %rr, i32* %r ret i1 1 lpad: %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*) %ehptr = extractvalue {i8*, i32} %ehvals, i32 0 %sel = extractvalue {i8*, i32} %ehvals, i32 1 %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*)) %matches = icmp eq i32 %sel, %filter_sel br i1 %matches, label %eh.except, label %eh.resume eh.except: ret i1 false eh.resume: resume } Reviewers: rjmccall, rsmith, majnemer Differential Revision: http://reviews.llvm.org/D5607 llvm-svn: 226760
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-221-4/+18
| | | | | | | | | | | | | | | | 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
* PR20356: Fix all Sema warnings with mismatched ext_/warn_ versusRichard Smith2014-07-191-2/+2
| | | | | | | | ExtWarn/Warnings. Mostly the name of the warning was changed to match the semantics, but in the PR20356 cases, the warning was about valid code, so the diagnostic was changed from ExtWarn to Warning instead. llvm-svn: 213443
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-1/+1
| | | | llvm-svn: 209613
* Add support for partial jump scope checkingAlp Toker2014-05-091-11/+22
| | | | | | | | | | This lets us diagnose and perform more complete semantic analysis when faced with errors in the function body or declaration. By recovering here we provide more consistent diagnostics, particularly during interactive editing. llvm-svn: 208394
* [C++11] Replacing BlockDecl iterators capture_begin() and capture_end() with ↵Aaron Ballman2014-03-141-3/+2
| | | | | | iterator_range captures(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203958
* [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with ↵Aaron Ballman2014-03-141-3/+2
| | | | | | iterator_range decls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203947
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* PR18217: Rewrite JumpDiagnostics' handling of temporaries, to correctly handleRichard Smith2013-12-121-64/+54
| | | | | | | | | declarations that might lifetime-extend multiple temporaries. In passing, fix a crasher (PR18217) if an initializer was dependent and exactly the wrong shape, and remove a bogus function (Expr::findMaterializedTemporary) now its last use is gone. llvm-svn: 197103
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Fix a couple of bugs where jump diagnostics would not notice that a variableRichard Smith2013-06-031-6/+6
| | | | | | has an initializer. llvm-svn: 183092
* Fix handling of pointers-to-members and comma expressions whenRichard Smith2013-06-031-2/+7
| | | | | | lifetime-extending temporaries in reference bindings. llvm-svn: 183089
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-1/+1
| | | | llvm-svn: 171367
* Fix for PR12222.Erik Verbruggen2012-12-251-2/+8
| | | | | | | | Changed getLocStart() and getLocEnd() to be required for Stmts, and make getSourceRange() optional. The default implementation for getSourceRange() is build the range by calling getLocStart() and getLocEnd(). llvm-svn: 171067
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-1/+1
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Correctly reject gotos in function-level try blocks. PR14225.Eli Friedman2012-10-311-24/+23
| | | | llvm-svn: 167184
* Fix invalid jump scopes again. This time without trying to find out if anRafael Espindola2012-10-281-35/+45
| | | | | | incomplete type has a destructor or not. llvm-svn: 166895
* Revert 166876 while I debug a bootstrap problem.Rafael Espindola2012-10-271-45/+35
| | | | llvm-svn: 166878
* Reapply 166855 with an early exit on null QualTypes.Rafael Espindola2012-10-271-35/+45
| | | | llvm-svn: 166876
* Revert r166855. I can reproduce the bootstrap failure and have a testcaseRafael Espindola2012-10-271-41/+35
| | | | | | to reduce. llvm-svn: 166863
* Fix cases where we were not producing an error when a computed goto couldRafael Espindola2012-10-271-35/+41
| | | | | | | jump over destructor calls. Fixes pr13812. llvm-svn: 166855
* During jump-scope checking, build an ExprWithCleanups immediatelyJohn McCall2012-09-251-3/+8
| | | | | | | | | | | | into the enclosing scope; this is a more accurate model but is (I believe) unnecessary in my test case due to other flaws. However, one of those flaws is now intentional: blocks which appear in return statements can be trivially observed to not extend in lifetime past the return, and so we can allow a jump past them. Do the necessary magic in IR-generation to make this work. llvm-svn: 164589
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-4/+4
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* ArrayRef-icize the function arguments.Bill Wendling2012-02-221-3/+2
| | | | llvm-svn: 151151
* Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-PODRichard Smith2011-10-201-35/+84
| | | | | | | | but trivially constructible and destructible variables in C++11 mode. Also incidentally improve the precision of the wording for jump diagnostics in C++98 mode. llvm-svn: 142619
* Move the "jump bypasses variable initialization" error -> warning downgrade ↵Francois Pichet2011-09-181-1/+1
| | | | | | from -fms-extensions to -fms-compatibility. llvm-svn: 140008
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-1/+1
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* In Microsoft mode, warn if an indirect goto jump over a variable initialization.Francois Pichet2011-09-161-2/+3
| | | | | | Also add a test case for the non Microsoft case because such test didn't exist. llvm-svn: 139971
* In Microsoft mode, downgrade "goto into protected scope" from error to ↵Francois Pichet2011-09-131-18/+40
| | | | | | | | warning if we are jumping over a variable initialization via a goto. This fixes a few errors when parsing MFC code with clang. llvm-svn: 139595
* Update comment because JumpDiagnostics.cpp is not just about VLA scope.Francois Pichet2011-09-091-2/+2
| | | | llvm-svn: 139364
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-9/+9
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* objc-arc: Diagnose when captured variable in block literalsFariborz Jahanian2011-07-111-13/+74
| | | | | | | | require destruction and there is possibility of that without construction. Thanks Johnm for review and suggestions offline. // rdar://9535237. llvm-svn: 134906
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-2/+2
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Automatic Reference Counting.John McCall2011-06-151-56/+88
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
OpenPOWER on IntegriCloud