[clang] [CIR] Upstream EHScopeStack memory allocator (PR #152215)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 7 00:08:13 PDT 2025


================
@@ -42,7 +42,47 @@ enum CleanupKind : unsigned {
 /// A stack of scopes which respond to exceptions, including cleanups
 /// and catch blocks.
 class EHScopeStack {
+  friend class CIRGenFunction;
+
 public:
+  // TODO(ogcg): Switch to alignof(uint64_t) instead of 8
+  enum { ScopeStackAlignment = 8 };
+
+  /// A saved depth on the scope stack.  This is necessary because
+  /// pushing scopes onto the stack invalidates iterators.
+  class stable_iterator {
+    friend class EHScopeStack;
+
+    /// Offset from startOfData to endOfBuffer.
+    ptrdiff_t size;
+
+    stable_iterator(ptrdiff_t size) : size(size) {}
+
+  public:
+    static stable_iterator invalid() { return stable_iterator(-1); }
+    stable_iterator() : size(-1) {}
----------------
xlauko wrote:

```suggestion
    stable_iterator() = default;
```

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


More information about the cfe-commits mailing list