[clang] [CIR] Add support for delete cleanup after new operators (PR #184707)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 06:50:19 PST 2026


================
@@ -193,6 +192,25 @@ bool EHScopeStack::requiresCatchOrCleanup() const {
   return false;
 }
 
+/// Deactive a cleanup that was created in an active state.
+void CIRGenFunction::deactivateCleanupBlock(EHScopeStack::stable_iterator c,
+                                            mlir::Operation *dominatingIP) {
+  assert(c != ehStack.stable_end() && "deactivating bottom of stack?");
+  EHCleanupScope &scope = cast<EHCleanupScope>(*ehStack.find(c));
----------------
erichkeane wrote:

So this line (doing a `find` on an `iterator`) was pretty jarring!  Perhaps its the name that is particularly jarring (both being `stable_iterator`, then doing a `find` on it), but the interface here is pretty odd seeming.

Not sure what there is to do about it here (or if you just inherited this from classic-codegen), but something to keep in mind: this is particularly awkward compared to the STL definition of stack and find.

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


More information about the cfe-commits mailing list