[clang] [CIR] Upstream Exception CXXTryStmt (PR #162528)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 17 16:43:48 PDT 2025


================
@@ -67,6 +81,72 @@ class EHScope {
   EHScope(Kind kind) { commonBits.kind = kind; }
 
   Kind getKind() const { return static_cast<Kind>(commonBits.kind); }
+
+  bool hasEHBranches() const {
+    // Traditional LLVM codegen also checks for `!block->use_empty()`, but
+    // in CIRGen the block content is not important, just used as a way to
+    // signal `hasEHBranches`.
+    assert(!cir::MissingFeatures::ehstackBranches());
+    return false;
+  }
+};
+
+/// A scope which attempts to handle some, possibly all, types of
+/// exceptions.
+///
+/// Objective C \@finally blocks are represented using a cleanup scope
+/// after the catch scope.
+
+class EHCatchScope : public EHScope {
+  // In effect, we have a flexible array member
+  //   Handler Handlers[0];
+  // But that's only standard in C99, not C++, so we have to do
+  // annoying pointer arithmetic instead.
+
+public:
+  struct Handler {
+    /// A type info value, or null (C++ null, not an LLVM null pointer)
+    /// for a catch-all.
+    CatchTypeInfo type;
+
+    /// The catch handler for this type.
+    mlir::Block *block;
----------------
andykaylor wrote:

I haven't looked at all the uses of this in the incubator, but it seems like an `mlir::Region` would be more natural here.

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


More information about the cfe-commits mailing list