Skip to content

Commit 65f1b52

Browse files
committed
Avoid goto
1 parent 2dc72c5 commit 65f1b52

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,24 @@ ASTSourceFileScope::ASTSourceFileScope(SourceFile *SF,
268268
scopeCreator(scopeCreator) {
269269
if (auto enclosingSF = SF->getEnclosingSourceFile()) {
270270
SourceLoc parentLoc;
271-
auto macroRole = SF->getFulfilledMacroRole();
272-
273-
// Determine the parent source location based on the macro role.
274-
AbstractFunctionDecl *bodyForDecl = nullptr;
275271

276272
if (SF->Kind == SourceFileKind::DefaultArgument) {
277273
auto genInfo = *SF->getASTContext().SourceMgr.getGeneratedSourceInfo(
278274
*SF->getBufferID());
279275
parentLoc = ASTNode::getFromOpaqueValue(genInfo.astNode).getStartLoc();
280-
goto setParent;
276+
if (auto parentScope =
277+
findStartingScopeForLookup(enclosingSF, parentLoc)) {
278+
parentAndWasExpanded.setPointer(
279+
const_cast<ASTScopeImpl *>(parentScope));
280+
}
281+
return;
281282
}
282283

284+
auto macroRole = SF->getFulfilledMacroRole();
285+
286+
// Determine the parent source location based on the macro role.
287+
AbstractFunctionDecl *bodyForDecl = nullptr;
288+
283289
switch (*macroRole) {
284290
case MacroRole::Expression:
285291
case MacroRole::Declaration:
@@ -309,7 +315,6 @@ ASTSourceFileScope::ASTSourceFileScope(SourceFile *SF,
309315
}
310316
}
311317

312-
setParent:
313318
if (auto parentScope = findStartingScopeForLookup(enclosingSF, parentLoc)) {
314319
if (bodyForDecl) {
315320
auto bodyScope = new (bodyForDecl->getASTContext()) FunctionBodyScope(bodyForDecl);

0 commit comments

Comments
 (0)