[clang] [CIR] Upstream Exception CXXTryStmt (PR #162528)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 18 02:27: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;
----------------
AmrDeveloper wrote:
> but it seems like an mlir::Region would be more natural here.
Yes, I think it was Block because all uses are blocks too, not regions, I tested it in the incubator with Region and updated some small codes to access the first Block from region in users, and all tests passed
https://github.com/llvm/llvm-project/pull/162528
More information about the cfe-commits
mailing list