https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/165110
>From ffd07a7f7675e9c22d4048894bb2c9f01109d225 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Fri, 5 Dec 2025 21:27:34 +0100 Subject: [PATCH] [CIR] Add structured CatchParamOp --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 27 +++++++++++++++++ clang/test/CIR/IR/catch-param.cir | 32 ++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 clang/test/CIR/IR/catch-param.cir diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 80c184e4f478c..8d6aa5db20b06 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -5134,6 +5134,33 @@ def CIR_TryOp : CIR_Op<"try",[ let hasLLVMLowering = false; } +//===----------------------------------------------------------------------===// +// CatchParamOp +//===----------------------------------------------------------------------===// + +def CIR_CatchParamOp : CIR_Op<"catch_param", [HasParent<"cir::TryOp">]> { + let summary = "Represents catch clause formal parameter"; + let description = [{ + The `cir.catch_param` operate in the catch regions of `cir.try`. + + This operation is used only before the CFG flatterning pass. + + Example: + + ```mlir + %exception = cir.catch_param -> !cir.ptr<!void> + ``` + }]; + + let results = (outs Optional<CIR_AnyType>:$param); + let assemblyFormat = [{ + (`:` qualified(type($param))^)? + attr-dict + }]; + + let hasLLVMLowering = false; +} + //===----------------------------------------------------------------------===// // Exception related: EhInflightOp //===----------------------------------------------------------------------===// diff --git a/clang/test/CIR/IR/catch-param.cir b/clang/test/CIR/IR/catch-param.cir new file mode 100644 index 0000000000000..a16e8ec43c91b --- /dev/null +++ b/clang/test/CIR/IR/catch-param.cir @@ -0,0 +1,32 @@ +// RUN: cir-opt %s --verify-roundtrip | FileCheck %s + +!s32i = !cir.int<s, 32> +!void = !cir.void + +module { + +cir.func @catch_param_inside_catch() { + cir.scope { + cir.try { + cir.yield + } catch all { + cir.catch_param : !cir.ptr<!void> + cir.yield + } + } + cir.return +} + +// CHECK: cir.func @catch_param_inside_catch() { +// CHECK: cir.scope { +// CHECK: cir.try { +// CHECK: cir.yield +// CHECK: } catch all { +// CHECK: cir.catch_param : !cir.ptr<!void> +// CHECK: cir.yield +// CHECK: } +// CHECK: } +// CHECK: cir.return +// CHECK: } + +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
