[PATCH] D146758: Fix codegen for coroutine with function-try-block

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 23 19:38:41 PDT 2023


ChuanqiXu requested changes to this revision.
ChuanqiXu added a comment.
This revision now requires changes to proceed.

Thanks for finding this! We didn't notice this before.



================
Comment at: clang/lib/CodeGen/CGCoroutine.cpp:724-730
+      Stmt *BodyStmt = S.getBody();
+      CompoundStmt *Body = dyn_cast<CompoundStmt>(BodyStmt);
+      if (Body == nullptr) {
+        Body =
+            CompoundStmt::Create(getContext(), {BodyStmt}, FPOptionsOverride(),
+                                 SourceLocation(), SourceLocation());
+      }
----------------
Can we try to move the logic to `CoroutineStmtBuilder`? That makes me feel better. And it will be helpful to add a comment to tell that we're handling the case the function body is function-try-block.


================
Comment at: clang/lib/CodeGen/CGCoroutine.cpp:726
+      CompoundStmt *Body = dyn_cast<CompoundStmt>(BodyStmt);
+      if (Body == nullptr) {
+        Body =
----------------
It reads better to specify the potential type for Body.


================
Comment at: clang/test/CodeGenCoroutines/coro-function-try-block.cpp:21-23
+// CHECK-LABEL: define{{.*}} void @_Z1fv(
+// CHECK: call void @_ZNSt13suspend_never13await_suspendESt16coroutine_handleIvE(
+// CHECK: call void @_ZN4task12promise_type11return_voidEv(
----------------
I expect to see the nested try statements in the case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146758/new/

https://reviews.llvm.org/D146758



More information about the cfe-commits mailing list