[clang] [CIR] Support Try catch with handler for specific type (PR #171042)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 14 11:33:17 PST 2025
================
@@ -344,21 +367,88 @@ CIRGenFunction::emitCXXTryStmtUnderScope(const CXXTryStmt &s) {
return mlir::success();
}
+/// Emit the structure of the dispatch block for the given catch scope.
+/// It is an invariant that the dispatch block already exists.
+static void emitCatchDispatchBlock(CIRGenFunction &cgf,
+ EHCatchScope &catchScope, cir::TryOp tryOp) {
+ if (EHPersonality::get(cgf).isWasmPersonality()) {
+ cgf.cgm.errorNYI("emitCatchDispatchBlock: WasmPersonality");
+ return;
+ }
+
+ if (EHPersonality::get(cgf).usesFuncletPads()) {
+ cgf.cgm.errorNYI("emitCatchDispatchBlock: usesFuncletPads");
+ return;
+ }
+
+ unsigned int numHandlers = catchScope.getNumHandlers();
+ if (numHandlers == 1 && catchScope.getHandler(0).isCatchAll()) {
+ return;
+ }
+
+ // In traditional LLVM codegen, the right handler is selected (with
+ // calls to eh_typeid_for) and the selector value is loaded. After that,
+ // blocks get connected for later codegen. In CIR, these are all
+ // implicit behaviors of cir.catch - not a lot of work to do.
+ //
+ // Test against each of the exception types we claim to catch.
+ for (unsigned i = 0;; ++i) {
----------------
AmrDeveloper wrote:
It's a lot cleaner now :D
https://github.com/llvm/llvm-project/pull/171042
More information about the cfe-commits
mailing list