[PATCH] D31692: [coroutines] Wrap the body of the coroutine in try-catch

Richard Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 12:00:25 PDT 2017


rsmith added inline comments.


================
Comment at: include/clang/AST/StmtCXX.h:128
+struct CXXTryStmt::OnStack : CXXTryStmt {
+  alignas(CXXTryStmt) Stmt *Stmts[2];
+  OnStack(SourceLocation tryLoc, Stmt *tryBlock, Stmt *handler)
----------------
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.


https://reviews.llvm.org/D31692





More information about the cfe-commits mailing list