[clang] [CIR] Support single level Cleanup scope (PR #180276)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 9 09:49:29 PST 2026
================
@@ -147,6 +149,21 @@ void *EHScopeStack::pushCleanup(CleanupKind kind, size_t size) {
assert(!cir::MissingFeatures::innermostEHScope());
+ CIRGenBuilderTy &builder = cgf->getBuilder();
+ mlir::Location loc = builder.getUnknownLoc();
+ auto cleanupScope = cir::CleanupScopeOp::create(
+ builder, loc, cir::CleanupKind::All,
----------------
andykaylor wrote:
The CleanupKind flag should be set something like this:
```
if (isEHCleanup && cgf->getLangOpts()->Exceptions) {
if (isNormalCleanup)
cleanupKind = cir::CleanupKind::All;
else
cleanupKind = cir::CleanupKind::EH;
} else {
if (isNormalCleanup)
cleanupKind = cir::CleanupKind::Normal;
else
skipCleanup = true;
}
```
I intend `skipCleanup` here as a placeholder for the fact that if this is an EH-only and exceptions are disabled, or if it's a lifetime marker cleanup we shouldn't create a cleanup scope operation. The above should be reworked as needed. It's just a rough outline to represent the logic.
https://github.com/llvm/llvm-project/pull/180276
More information about the cfe-commits
mailing list