[clang] [CodeGen][ObjC] Initial WebAssembly Support for GNUstep v2 (PR #183753)

Hendrik Hübner via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 02:19:06 PDT 2026


================
@@ -148,12 +151,24 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF,
     Cont = CGF.getJumpDestInCurrentScope("eh.cont");
 
   bool useFunclets = EHPersonality::get(CGF).usesFuncletPads();
+  bool IsWasm = EHPersonality::get(CGF).isWasmPersonality();
+  bool IsMSVC = EHPersonality::get(CGF).isMSVCPersonality();
 
   CodeGenFunction::FinallyInfo FinallyInfo;
-  if (!useFunclets)
-    if (const ObjCAtFinallyStmt *Finally = S.getFinallyStmt())
-      FinallyInfo.enter(CGF, Finally->getFinallyBody(),
-                        beginCatchFn, endCatchFn, exceptionRethrowFn);
+  if (const ObjCAtFinallyStmt *Finally = S.getFinallyStmt()) {
+    if (!useFunclets) {
+      // The finally statement is executed as a cleanup for the normal and
+      // exceptional control flow out of a try-catch block. This is all
+      // implemented in FinallyInfo. Here we enter a new EHCatchScope.
+      FinallyInfo.enter(CGF, Finally->getFinallyBody(), beginCatchFn,
+                        endCatchFn, exceptionRethrowFn);
+    } else if (IsWasm) {
+      // dispatchBlock is finally.catchall
+      // emitWasmCatchPadBlock()
+      // CurrentFuncletPad = ...
+      llvm_unreachable("@finally not implemented for WASM");
+    }
----------------
HendrikHuebner wrote:

We should also assert that the else branch isn't reached. You could leave the `if (IsWasm)` condition out and later add an assertion that the target is indeed wasm.

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


More information about the cfe-commits mailing list