[clang] [CIR] Support single level Cleanup scope (PR #180276)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 10 09:45:58 PST 2026


================
@@ -836,7 +826,8 @@ emitCallLikeOp(CIRGenFunction &cgf, mlir::Location callLoc,
     callOpWithExceptions =
         builder.createCallOp(callLoc, directFuncOp, cirCallArgs);
 
-    cgf.populateCatchHandlersIfRequired(tryOp);
+    if (tryOp)
+      cgf.populateCatchHandlersIfRequired(tryOp);
----------------
andykaylor wrote:

After experimenting with the changes from this PR a bit, I believe that we should significantly simplify the way try-catch is implemented. Currently, we're pushing catches on the EH stack and performing a complex dance, based mostly on vestigial artifacts from the classic codegen design, to generate their contents. Under the new design, I think we can simply emit the catch handlers based on the information in the AST and not even need to push catches to the EH stack. Unlike classic codegen, we'll resolve unwind destinations during CFG flattening, so we don't need to constantly track where we are.

@AmrDeveloper Please continue with this PR and try to resolve the remaining issues with non-exception cleanups. I'll try to put together a patch to simply the try-catch handling.

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


More information about the cfe-commits mailing list