This is an archive of the discontinued LLVM Phabricator instance.

[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,
wrap the body of the coroutine in:

try { 
  body 
} catch(...) { promise.unhandled_exception(); }

Diff Detail

Repository
rL LLVM

Event Timeline

GorNishanov created this revision.Apr 4 2017, 5:45 PM
GorNishanov awarded a token.
GorNishanov added inline comments.Apr 11 2017, 1:15 PM
lib/Sema/SemaCoroutine.cpp
977 ↗(On Diff #94148)

s/incompativle/incompatible

rsmith added inline comments.May 22 2017, 12:00 PM
include/clang/AST/StmtCXX.h
128 ↗(On Diff #94148)

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.

  1. Heap allocate CxxTryStmt in CGCoroutine.
  2. Merge with trunk

Fix misspelling in a comment.
@rsmith, Looks good now?

rsmith accepted this revision.May 22 2017, 3:08 PM

LGTM

This revision is now accepted and ready to land.May 22 2017, 3:08 PM
This revision was automatically updated to reflect the committed changes.