[clang] [CIR] Upstream a basic version of class LexicalScope (PR #131945)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 19 06:33:41 PDT 2025
================
@@ -149,14 +156,125 @@ void CIRGenFunction::declare(mlir::Value addrVal, const Decl *var, QualType ty,
allocaOp.setConstantAttr(mlir::UnitAttr::get(&getMLIRContext()));
}
+void CIRGenFunction::LexicalScope::cleanup() {
+ CIRGenBuilderTy &builder = cgf.builder;
+ LexicalScope *localScope = cgf.currLexScope;
+
+ if (returnBlock != nullptr) {
+ // Write out the return block, which loads the value from `__retval` and
+ // issues the `cir.return`.
+ mlir::OpBuilder::InsertionGuard guard(builder);
+ builder.setInsertionPointToEnd(returnBlock);
+ (void)emitReturn(*returnLoc);
+ }
+
+ mlir::Block *currBlock = builder.getBlock();
----------------
erichkeane wrote:
```suggestion
mlir::Block *curBlock = builder.getBlock();
```
I've never seen someone shorted 'current' to 'curr' before :D Typically throughout clang we use `Cur` instead of `Curr`.
https://github.com/llvm/llvm-project/pull/131945
More information about the cfe-commits
mailing list