Skip to content

Commit 172ea3a

Browse files
committed
Upstream LexicalScope: review feedback
Change `curr` to `cur` in names. Fix typo in comment.
1 parent ef54cec commit 172ea3a

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void CIRGenFunction::declare(mlir::Value addrVal, const Decl *var, QualType ty,
158158

159159
void CIRGenFunction::LexicalScope::cleanup() {
160160
CIRGenBuilderTy &builder = cgf.builder;
161-
LexicalScope *localScope = cgf.currLexScope;
161+
LexicalScope *localScope = cgf.curLexScope;
162162

163163
if (returnBlock != nullptr) {
164164
// Write out the return block, which loads the value from `__retval` and
@@ -168,16 +168,16 @@ void CIRGenFunction::LexicalScope::cleanup() {
168168
(void)emitReturn(*returnLoc);
169169
}
170170

171-
mlir::Block *currBlock = builder.getBlock();
172-
if (isGlobalInit() && !currBlock)
171+
mlir::Block *curBlock = builder.getBlock();
172+
if (isGlobalInit() && !curBlock)
173173
return;
174-
if (currBlock->mightHaveTerminator() && currBlock->getTerminator())
174+
if (curBlock->mightHaveTerminator() && curBlock->getTerminator())
175175
return;
176176

177177
// Get rid of any empty block at the end of the scope.
178178
bool entryBlock = builder.getInsertionBlock()->isEntryBlock();
179-
if (!entryBlock && currBlock->empty()) {
180-
currBlock->erase();
179+
if (!entryBlock && curBlock->empty()) {
180+
curBlock->erase();
181181
if (returnBlock != nullptr && returnBlock->getUses().empty())
182182
returnBlock->erase();
183183
return;
@@ -186,7 +186,7 @@ void CIRGenFunction::LexicalScope::cleanup() {
186186
// Reached the end of the scope.
187187
{
188188
mlir::OpBuilder::InsertionGuard guard(builder);
189-
builder.setInsertionPointToEnd(currBlock);
189+
builder.setInsertionPointToEnd(curBlock);
190190

191191
if (localScope->depth == 0) {
192192
// Reached the end of the function.
@@ -203,7 +203,7 @@ void CIRGenFunction::LexicalScope::cleanup() {
203203
}
204204
// Reached the end of a non-function scope. Some scopes, such as those
205205
// used with the ?: operator, can return a value.
206-
if (!localScope->isTernary() && !currBlock->mightHaveTerminator()) {
206+
if (!localScope->isTernary() && !curBlock->mightHaveTerminator()) {
207207
!retVal ? builder.create<cir::YieldOp>(localScope->endLoc)
208208
: builder.create<cir::YieldOp>(localScope->endLoc, retVal);
209209
}
@@ -223,7 +223,7 @@ cir::ReturnOp CIRGenFunction::LexicalScope::emitReturn(mlir::Location loc) {
223223
return builder.create<cir::ReturnOp>(loc);
224224
}
225225

226-
// This is copyied from CodeGenModule::MayDropFunctionReturn. This is a
226+
// This is copied from CodeGenModule::MayDropFunctionReturn. This is a
227227
// candidate for sharing between CIRGen and CodeGen.
228228
static bool mayDropFunctionReturn(const ASTContext &astContext,
229229
QualType returnType) {
@@ -239,7 +239,7 @@ static bool mayDropFunctionReturn(const ASTContext &astContext,
239239

240240
void CIRGenFunction::LexicalScope::emitImplicitReturn() {
241241
CIRGenBuilderTy &builder = cgf.getBuilder();
242-
LexicalScope *localScope = cgf.currLexScope;
242+
LexicalScope *localScope = cgf.curLexScope;
243243

244244
const auto *fd = cast<clang::FunctionDecl>(cgf.curGD.getDecl());
245245

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,11 @@ class CIRGenFunction : public CIRGenTypeCache {
378378
unsigned depth = 0;
379379

380380
LexicalScope(CIRGenFunction &cgf, mlir::Location loc, mlir::Block *eb)
381-
: cgf(cgf), entryBlock(eb), parentScope(cgf.currLexScope),
382-
beginLoc(loc), endLoc(loc) {
381+
: cgf(cgf), entryBlock(eb), parentScope(cgf.curLexScope), beginLoc(loc),
382+
endLoc(loc) {
383383

384384
assert(entryBlock && "LexicalScope requires an entry block");
385-
cgf.currLexScope = this;
385+
cgf.curLexScope = this;
386386
if (parentScope)
387387
++depth;
388388

@@ -396,7 +396,7 @@ class CIRGenFunction : public CIRGenTypeCache {
396396
void setRetVal(mlir::Value v) { retVal = v; }
397397

398398
void cleanup();
399-
void restore() { cgf.currLexScope = parentScope; }
399+
void restore() { cgf.curLexScope = parentScope; }
400400

401401
~LexicalScope() {
402402
assert(!cir::MissingFeatures::generateDebugInfo());
@@ -465,7 +465,7 @@ class CIRGenFunction : public CIRGenTypeCache {
465465
mlir::Block *getEntryBlock() { return entryBlock; }
466466
};
467467

468-
LexicalScope *currLexScope = nullptr;
468+
LexicalScope *curLexScope = nullptr;
469469

470470
Address createTempAlloca(mlir::Type ty, CharUnits align, mlir::Location loc,
471471
const Twine &name = "tmp");

clang/lib/CIR/CodeGen/CIRGenStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const ReturnStmt &s) {
274274
}
275275
}
276276

277-
auto *retBlock = currLexScope->getOrCreateRetBlock(*this, loc);
277+
auto *retBlock = curLexScope->getOrCreateRetBlock(*this, loc);
278278
builder.create<cir::BrOp>(loc, retBlock);
279279
builder.createBlock(builder.getBlock()->getParent());
280280

0 commit comments

Comments
 (0)