If unhandled_exception member function is present in the coroutine promise,
wrap the body of the coroutine in:
try { body } catch(...) { promise.unhandled_exception(); }
Paths
| Differential D31692
[coroutines] Wrap the body of the coroutine in try-catch ClosedPublic Authored by GorNishanov on Apr 4 2017, 5:45 PM. Tokens "Mountain of Wealth" token, awarded by GorNishanov.
Details Summary If unhandled_exception member function is present in the coroutine promise, try { body } catch(...) { promise.unhandled_exception(); }
Diff Detail Event Timeline
This revision is now accepted and ready to land.May 22 2017, 3:08 PM Closed by commit rL303583: [coroutines] Wrap the body of the coroutine in try-catch (authored by GorNishanov). · Explain WhyMay 22 2017, 3:33 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 94148 include/clang/AST/StmtCXX.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/StmtCXX.cpp
lib/CodeGen/CGCoroutine.cpp
lib/Sema/SemaCoroutine.cpp
test/CodeGenCoroutines/coro-cleanup.cpp
test/SemaCXX/coroutine-seh.cpp
|
This makes more assumptions about record layout and the ability to reach derived-class members through pointer arithmetic than I'd prefer. We're only going to have at most one of these per coroutine for which we emit an IR definition, so it seems fine for CodeGen to just go ahead and allocate one in the normal way.
Alternatively, it looks like it'd be straightforward to refactor CodeGen's EnterCXXTryStmt / ExitCXXTryStmt to take an ArrayRef<CXXTryStmt> instead of a CXXTryStmt, which would let you avoid this machinery entirely.