Skip to content

Commit 6093a7f

Browse files
committed
Rename setIndexOfFIrstOuterResultIfNotSetAlready to recordCompilationOfAScope
1 parent 6982e66 commit 6093a7f

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ class UnqualifiedLookupFactory {
261261
/// results yet?
262262
bool isLookupDoneWithoutIncludingOuterResults() const;
263263

264-
void setIndexOfFirstOuterResultIfNotSetAlready();
264+
/// Every time lookup finishes searching a scope, call me
265+
/// to record the dividing line between results from first fruitful scope and
266+
/// the result.
267+
void recordCompletionOfAScope();
265268

266269
#pragma mark normal (non-ASTScope-based) lookup declarations
267270

@@ -414,10 +417,10 @@ void UnqualifiedLookupFactory::fillInLookup() {
414417
// TODO: Does the debugger client care about compound names?
415418
if (Name.isSimpleName() && DebugClient &&
416419
DebugClient->lookupOverrides(Name.getBaseName(), DC, Loc,
420+
recordDependencyOnTopLevelName(DC, Name, isCascadingUse);
417421
isOriginallyTypeLookup, Results))
418422
return;
419423

420-
recordDependencyOnTopLevelName(DC, Name, isCascadingUse);
421424
addPrivateImports(DC);
422425
if (addNamesKnownToDebugClient(DC))
423426
return;
@@ -429,7 +432,7 @@ void UnqualifiedLookupFactory::fillInLookup() {
429432
if (lookForAModuleWithTheGivenName(DC))
430433
return;
431434
// Make sure we've recorded the inner-result-boundary.
432-
setIndexOfFirstOuterResultIfNotSetAlready(); // DMU elim?
435+
recordCompletionOfAScope(); // DMU elim?
433436
}
434437

435438
bool UnqualifiedLookupFactory::shouldUseASTScopeLookup() const {
@@ -511,7 +514,7 @@ UnqualifiedLookupFactory::lookInScopeForASTScopeLookup(
511514
Consumer.foundDecl(local, getLocalDeclVisibilityKind(currentScope));
512515
}
513516

514-
setIndexOfFirstOuterResultIfNotSetAlready();
517+
recordCompletionOfAScope();
515518
// If we found anything, we're done.
516519
if (isLookupDoneWithoutIncludingOuterResults())
517520
return None;
@@ -641,7 +644,7 @@ UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
641644
} else {
642645
filterForDiscriminator(Results, DebugClient);
643646

644-
setIndexOfFirstOuterResultIfNotSetAlready();
647+
recordCompletionOfAScope();
645648
if (isLookupDoneWithoutIncludingOuterResults())
646649
return None;
647650
}
@@ -740,7 +743,7 @@ UnqualifiedLookupFactory::lookupInPatternBindingInitializer(
740743
// instance member lookup.
741744
if (auto *selfParam = PBI->getImplicitSelfDecl()) {
742745
Consumer.foundDecl(selfParam, DeclVisibilityKind::FunctionParameter);
743-
setIndexOfFirstOuterResultIfNotSetAlready();
746+
recordCompletionOfAScope();
744747
if (isLookupDoneWithoutIncludingOuterResults())
745748
return None;
746749
DeclContext *const parent = PBI->getParent();
@@ -789,15 +792,15 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
789792

790793
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
791794
localVal.visit(AFD->getBody());
792-
793-
setIndexOfFirstOuterResultIfNotSetAlready();
795+
796+
recordCompletionOfAScope();
794797
if (isLookupDoneWithoutIncludingOuterResults())
795798
return None;
796799

797800
if (auto *P = AFD->getImplicitSelfDecl())
798801
localVal.checkValueDecl(P, DeclVisibilityKind::FunctionParameter);
799802
localVal.checkParameterList(AFD->getParameters());
800-
setIndexOfFirstOuterResultIfNotSetAlready();
803+
recordCompletionOfAScope();
801804
if (isLookupDoneWithoutIncludingOuterResults())
802805
return None;
803806
}
@@ -811,7 +814,7 @@ UnqualifiedLookupFactory::lookupInFunctionDecl(AbstractFunctionDecl *AFD,
811814

812815
// Look in the generic parameters after checking our local declaration.
813816
addGenericParametersForFunction(AFD);
814-
setIndexOfFirstOuterResultIfNotSetAlready();
817+
recordCompletionOfAScope();
815818
if (isLookupDoneWithoutIncludingOuterResults())
816819
return None;
817820

@@ -849,12 +852,12 @@ UnqualifiedLookupFactory::lookupInClosure(AbstractClosureExpr *ACE,
849852
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
850853
if (auto body = CE->getBody())
851854
localVal.visit(body);
852-
setIndexOfFirstOuterResultIfNotSetAlready();
855+
recordCompletionOfAScope();
853856
if (isLookupDoneWithoutIncludingOuterResults())
854857
return None;
855858
if (auto params = CE->getParameters())
856859
localVal.checkParameterList(params);
857-
setIndexOfFirstOuterResultIfNotSetAlready();
860+
recordCompletionOfAScope();
858861
if (isLookupDoneWithoutIncludingOuterResults())
859862
return None;
860863
}
@@ -939,7 +942,7 @@ bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
939942
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
940943
localVal.checkGenericParams(dcGenericParams);
941944

942-
setIndexOfFirstOuterResultIfNotSetAlready();
945+
recordCompletionOfAScope();
943946
if (isLookupDoneWithoutIncludingOuterResults())
944947
return true;
945948
}
@@ -967,7 +970,7 @@ bool UnqualifiedLookupFactory::addLocalVariableResults(DeclContext *dc) {
967970
// local types.
968971
namelookup::FindLocalVal localVal(SM, Loc, Consumer);
969972
localVal.checkSourceFile(*SF);
970-
setIndexOfFirstOuterResultIfNotSetAlready();
973+
recordCompletionOfAScope();
971974
if (isLookupDoneWithoutIncludingOuterResults())
972975
return true;
973976
}
@@ -1012,7 +1015,7 @@ bool UnqualifiedLookupFactory::handleUnavailableInnerResults(
10121015
}
10131016
filterForDiscriminator(Results, DebugClient);
10141017

1015-
setIndexOfFirstOuterResultIfNotSetAlready();
1018+
recordCompletionOfAScope();
10161019
return isLookupDoneWithoutIncludingOuterResults();
10171020
}
10181021

@@ -1052,14 +1055,14 @@ bool UnqualifiedLookupFactory::addNamesKnownToDebugClient(DeclContext *dc) {
10521055
if (Name.isSimpleName() && DebugClient)
10531056
DebugClient->lookupAdditions(Name.getBaseName(), dc, Loc,
10541057
isOriginallyTypeLookup, Results);
1055-
setIndexOfFirstOuterResultIfNotSetAlready();
1058+
recordCompletionOfAScope();
10561059
// If we've found something, we're done.
10571060
return !Results.empty();
10581061
}
10591062

10601063
bool UnqualifiedLookupFactory::addUnavailableInnerResults() {
10611064
Results = std::move(UnavailableInnerResults);
1062-
setIndexOfFirstOuterResultIfNotSetAlready();
1065+
recordCompletionOfAScope();
10631066
return !Results.empty();
10641067
}
10651068

@@ -1072,7 +1075,7 @@ bool UnqualifiedLookupFactory::lookForAModuleWithTheGivenName(
10721075
// Look for a module with the given name.
10731076
if (Name.isSimpleName(M.getName())) {
10741077
Results.push_back(LookupResultEntry(&M));
1075-
setIndexOfFirstOuterResultIfNotSetAlready();
1078+
recordCompletionOfAScope();
10761079
return true;
10771080
}
10781081
ModuleDecl *desiredModule = Ctx.getLoadedModule(Name.getBaseIdentifier());
@@ -1110,7 +1113,7 @@ bool UnqualifiedLookupFactory::isLookupDoneWithoutIncludingOuterResults()
11101113
return !Results.empty() && !options.contains(Flags::IncludeOuterResults);
11111114
}
11121115

1113-
void UnqualifiedLookupFactory::setIndexOfFirstOuterResultIfNotSetAlready() {
1116+
void UnqualifiedLookupFactory::recordCompletionOfAScope() {
11141117
// OK to call (NOOP) if there are more inner results and Results is empty
11151118
if (IndexOfFirstOuterResult == 0)
11161119
IndexOfFirstOuterResult = Results.size();

0 commit comments

Comments
 (0)