[clang] [CIR] Simplify try-catch handling (PR #180857)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 11 09:12:32 PST 2026


================
@@ -514,192 +383,13 @@ void CIRGenFunction::exitCXXTryStmt(const CXXTryStmt &s, bool isFnTryBlock) {
     //   reaches the end of a handler of the function-try-block of a
     //   constructor or destructor.
 
-    // 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) {
-      cgm.errorNYI("exitCXXTryStmt: doImplicitRethrow");
-      return;
-    }
+    // TODO(cir): Handle implicit rethrow?
----------------
andykaylor wrote:

The reason it's not errorNYI here is that I have no means to even check for the condition. The old code was setting `doImplicitRethrow` based on the `isFnTryBlock` but the functions (`enter/exitCXXTryStmt`) were never being called with that parameter set, either in the incubator or in upstream CIR. Classic codegen calls them that way from `EmitConstructorBody` and `EmitDestructorBody`, but that's not what we're going to want to do in CIR.

Basically, we may never need to do this here, but we'll need to do something. This is just a reminder to do that "something" when we figure out what it should be. There are errorNYI calls in the ctor/dtor emit functions that will trigger when the condition is encountered.

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


More information about the cfe-commits mailing list