[clang] [CIR] Represent Cleanups with Cleanup scopes (PR #180276)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 11:13:03 PST 2026
================
@@ -269,10 +269,12 @@ void CIRGenFunction::LexicalScope::cleanup() {
// Leverage and defers to RunCleanupsScope's dtor and scope handling.
applyCleanup();
+ mlir::Block *currentBlock = builder.getBlock();
+
// If we now have one after `applyCleanup`, hook it up properly.
if (!cleanupBlock && localScope->getCleanupBlock(builder)) {
cleanupBlock = localScope->getCleanupBlock(builder);
- cir::BrOp::create(builder, insPt->back().getLoc(), cleanupBlock);
+ cir::BrOp::create(builder, currentBlock->back().getLoc(), cleanupBlock);
----------------
andykaylor wrote:
Are we hitting this code? I don't see a branch op in any of the tests in this PR, and I would hope there won't be any. We want the control flow to be structured at this point. If we're branching to a cleanup handler, that will need to be fixed.
https://github.com/llvm/llvm-project/pull/180276
More information about the cfe-commits
mailing list