Skip to content

Commit 6635f39

Browse files
committed
Break up confusing compound.
1 parent 64ff790 commit 6635f39

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ class UnqualifiedLookupFactory {
262262
DeclContext *selfDC,
263263
DeclContext *wasDC,
264264
Optional<bool> isCascadingUse);
265-
266-
/// Return true if done with lookup.
267-
bool isFinishedWithLookupNowThatIsAboutToLookForOuterResults();
265+
/// Can lookup stop searching for results, assuming hasn't looked for outer
266+
/// results yet?
267+
bool isLookupDoneWithoutIncludingOuterResults() const;
268268

269269
void setIndexOfFirstOuterResultIfNotSetAlready();
270270

@@ -456,10 +456,10 @@ UnqualifiedLookupFactory::astScopeBasedLookup(DeclContext *const startDC,
456456
currentIsCascadingUse);
457457
if (!r.hasValue())
458458
return None;
459-
const bool isDone = r.getValue().isDone;
460459
selfDC = r.getValue().selfDC;
461460
dc = r.getValue().dc;
462461
currentIsCascadingUse = r.getValue().isCascadingUse;
462+
const bool isDone = r.getValue().isDone;
463463
if (isDone)
464464
return DCAndIsCascadingUse{dc, currentIsCascadingUse.getValue()};
465465
}
@@ -508,8 +508,9 @@ UnqualifiedLookupFactory::lookInScopeForASTScopeLookup(
508508
Consumer.foundDecl(local, getLocalDeclVisibilityKind(currentScope));
509509
}
510510

511+
setIndexOfFirstOuterResultIfNotSetAlready();
511512
// If we found anything, we're done.
512-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
513+
if (isLookupDoneWithoutIncludingOuterResults())
513514
return None;
514515

515516
// When we are in the body of a method, get the 'self' declaration.
@@ -638,7 +639,8 @@ UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
638639
if (DebugClient)
639640
filterForDiscriminator(Results, DebugClient);
640641

641-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
642+
setIndexOfFirstOuterResultIfNotSetAlready();
643+
if (isLookupDoneWithoutIncludingOuterResults())
642644
return None;
643645
}
644646
}
@@ -747,7 +749,8 @@ UnqualifiedLookupFactory::lookupInPatternBindingInitializer(
747749
// instance member lookup.
748750
if (auto *selfParam = PBI->getImplicitSelfDecl()) {
749751
Consumer.foundDecl(selfParam, DeclVisibilityKind::FunctionParameter);
750-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
752+
setIndexOfFirstOuterResultIfNotSetAlready();
753+
if (isLookupDoneWithoutIncludingOuterResults())
751754
return None;
752755
DeclContext *const parent = PBI->getParent();
753756
// clang-format off
@@ -798,13 +801,15 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
798801

799802
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
800803
localVal.visit(AFD->getBody());
801-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
804+
setIndexOfFirstOuterResultIfNotSetAlready();
805+
if (isLookupDoneWithoutIncludingOuterResults())
802806
return None;
803807

804808
if (auto *P = AFD->getImplicitSelfDecl())
805809
localVal.checkValueDecl(P, DeclVisibilityKind::FunctionParameter);
806810
localVal.checkParameterList(AFD->getParameters());
807-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
811+
setIndexOfFirstOuterResultIfNotSetAlready();
812+
if (isLookupDoneWithoutIncludingOuterResults())
808813
return None;
809814
}
810815
const bool returnValueForIsCascadingUse =
@@ -818,7 +823,8 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
818823
DeclContext *fnDeclContext = AFD->getDeclContext();
819824
DeclContext *fnParent = AFD->getParent();
820825
addGenericParametersForFunction(AFD);
821-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
826+
setIndexOfFirstOuterResultIfNotSetAlready();
827+
if (isLookupDoneWithoutIncludingOuterResults())
822828
return None;
823829
// clang-format off
824830
return PerScopeLookupState{
@@ -838,7 +844,8 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
838844
}
839845
// Look in the generic parameters after checking our local declaration.
840846
addGenericParametersForFunction(AFD);
841-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
847+
setIndexOfFirstOuterResultIfNotSetAlready();
848+
if (isLookupDoneWithoutIncludingOuterResults())
842849
return None;
843850
// clang-format off
844851
return PerScopeLookupState{
@@ -859,11 +866,13 @@ UnqualifiedLookupFactory::lookupInClosure(AbstractClosureExpr *ACE,
859866
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
860867
if (auto body = CE->getBody())
861868
localVal.visit(body);
862-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
869+
setIndexOfFirstOuterResultIfNotSetAlready();
870+
if (isLookupDoneWithoutIncludingOuterResults())
863871
return None;
864872
if (auto params = CE->getParameters())
865873
localVal.checkParameterList(params);
866-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
874+
setIndexOfFirstOuterResultIfNotSetAlready();
875+
if (isLookupDoneWithoutIncludingOuterResults())
867876
return None;
868877
}
869878
}
@@ -950,7 +959,8 @@ bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
950959
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
951960
localVal.checkGenericParams(dcGenericParams);
952961

953-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
962+
setIndexOfFirstOuterResultIfNotSetAlready();
963+
if (isLookupDoneWithoutIncludingOuterResults())
954964
return true;
955965
}
956966
return false;
@@ -977,7 +987,8 @@ bool UnqualifiedLookupFactory::addLocalVariableResults(DeclContext *dc) {
977987
// local types.
978988
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
979989
localVal.checkSourceFile(*SF);
980-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults())
990+
setIndexOfFirstOuterResultIfNotSetAlready();
991+
if (isLookupDoneWithoutIncludingOuterResults())
981992
return true;
982993
}
983994
}
@@ -1022,7 +1033,8 @@ bool UnqualifiedLookupFactory::handleUnavailableInnerResults(
10221033
if (DebugClient)
10231034
filterForDiscriminator(Results, DebugClient);
10241035

1025-
return isFinishedWithLookupNowThatIsAboutToLookForOuterResults();
1036+
setIndexOfFirstOuterResultIfNotSetAlready();
1037+
return isLookupDoneWithoutIncludingOuterResults();
10261038
}
10271039

10281040
void UnqualifiedLookupFactory::recordDependencyOnTopLevelName(
@@ -1115,10 +1127,8 @@ NLOptions UnqualifiedLookupFactory::computeBaseNLOptions(
11151127
return baseNLOptions;
11161128
}
11171129

1118-
bool UnqualifiedLookupFactory::
1119-
isFinishedWithLookupNowThatIsAboutToLookForOuterResults() {
1120-
setIndexOfFirstOuterResultIfNotSetAlready();
1121-
1130+
bool UnqualifiedLookupFactory::isLookupDoneWithoutIncludingOuterResults()
1131+
const {
11221132
return !Results.empty() && !options.contains(Flags::IncludeOuterResults);
11231133
}
11241134

0 commit comments

Comments
 (0)