summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/__try.c
Commit message (Collapse)AuthorAgeFilesLines
* [SEH] Defer checking filter expression types until instantiatonReid Kleckner2019-11-071-1/+1
| | | | | | | | | | | While here, wordsmith the error a bit. Now clang says: error: filter expression has non-integral type 'Foo' Fixes PR43779 Reviewers: amccarth Differential Revision: https://reviews.llvm.org/D69969
* Fix Sema tests using __try by adding tripleReid Kleckner2015-04-281-2/+2
| | | | llvm-svn: 236057
* Correct typos in SEH filter expressionsReid Kleckner2015-04-021-0/+6
| | | | | | Otherwise we assert due to uncorrected delayed typos. llvm-svn: 233980
* Warn when jumping out of a __finally block via continue, break, return, __leave.Nico Weber2015-03-091-2/+76
| | | | | | | | | | | | | | | 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
* Implement IRGen for SEH __finally and AbnormalTerminationReid Kleckner2015-02-041-1/+1
| | | | | | | | | | | Previously we would simply double-emit the body of the __finally block, but that doesn't work when it contains any kind of Decl, which we can't double emit. This fixes that by emitting the block once and branching into a shared code region and then branching back out. llvm-svn: 228222
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-221-9/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add an AST node for __leave statements, hook it up.Nico Weber2014-07-071-7/+4
| | | | | | | 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-8/+5
| | | | | | | | | 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/+25
| | | | llvm-svn: 212421
* Treat the Microsoft/Borland keyword "__except" as a context-sensitiveDouglas Gregor2011-10-211-2/+3
| | | | | | | keyword, because both libstdc++ and libc++ use "__except" as an identifier. Fixes <rdar://problem/10322555>. llvm-svn: 142636
* Parsing/AST support for Structured Exception HandlingJohn Wiegley2011-04-281-0/+171
Patch authored by Sohail Somani. Provide parsing and AST support for Windows structured exception handling. llvm-svn: 130366
OpenPOWER on IntegriCloud