[clang] [CodeGen][ObjC] Try/Catch support for WebAssembly (PR #171038)

Heejin Ahn via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 17 18:24:26 PST 2025


================
@@ -207,36 +215,59 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF,
         // Push a cleanup for __finally blocks.
         CGF.pushSEHCleanup(NormalAndEHCleanup, FinallyFunc);
     }
+  }
 
 
   // Emit the try body.
   CGF.EmitStmt(S.getTryBody());
 
   // Leave the try.
+  llvm::BasicBlock* dispatchBlock{};
   if (S.getNumCatchStmts())
-    CGF.popCatchScope();
+    dispatchBlock = CGF.popCatchScope();
 
   // Remember where we were.
   CGBuilderTy::InsertPoint SavedIP = CGF.Builder.saveAndClearIP();
 
+  // Wasm uses Windows-style EH instructions, but merges all catch clauses into
----------------
aheejin wrote:

+1 on finding a way to reuse the same code in `CGException.cpp`. I'm not familiar with his `CGObjRuntime.cpp`, but can't ObjC (at least partly) use functions in `CGException.cpp`? What's the reason ObjC maintains separate EH handling routines?

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


More information about the cfe-commits mailing list