[clang] [CIR] Implement ctor-try-body rethrow (PR #229436)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 14:58:03 PDT 2026


================
@@ -736,8 +741,13 @@ CIRGenFunction::emitCXXTryStmt(const CXXTryStmt &s,
     //   The currently handled exception is rethrown if control
     //   reaches the end of a handler of the function-try-block of a
     //   constructor or destructor.
-
-    // TODO(cir): Handle implicit rethrow?
+    //
+    // It is important that we only do this on fallthrough and not on
+    // return.  Note that it's illegal to put a return in a
+    // constructor function-try-block's catch handler (p14), so this
+    // really only applies to destructors.
+    if (doImplicitRethrow && haveInsertPoint())
----------------
erichkeane wrote:

That seems reasonable to me.  I've included that as-is and am using it. I wonder if `hasInsertPoint` should be removed at one point from CIRGen...

https://github.com/llvm/llvm-project/pull/229436


More information about the cfe-commits mailing list