Skip to content

Commit 66a9cac

Browse files
committed
void return from addGeneric…
1 parent 3641e35 commit 66a9cac

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,7 @@ class UnqualifiedLookupFactory {
322322

323323
bool isOutsideBodyOfFunction(const AbstractFunctionDecl *const AFD) const;
324324

325-
/// Check the generic parameters of our context.
326-
/// Return true if done with lookup
327-
bool addGenericParametersHereAndInEnclosingScopes(DeclContext *dc);
325+
void addGenericParametersHereAndInEnclosingScopes(DeclContext *dc);
328326

329327
/// Consume generic parameters
330328
void addGenericParametersForFunction(AbstractFunctionDecl *AFD);
@@ -335,7 +333,7 @@ class UnqualifiedLookupFactory {
335333
bool addLocalVariableResults(DeclContext *dc);
336334

337335
/// Return true if finished with lookup
338-
bool setAsideUnavailableResults(const size_t startIndexOfInnerResults);
336+
bool setAsideUnavailableResults(size_t firstPossiblyUnavailableResult);
339337

340338
void recordDependencyOnTopLevelName(DeclContext *topLevelContext,
341339
DeclName name, bool isCascadingUse);
@@ -683,16 +681,18 @@ void UnqualifiedLookupFactory::finishLookingInContext(
683681
lookupContextForThisContext,
684682
placesToSearch, isCascadingUse});
685683
#endif
686-
if (addGenericParameters == AddGenericParameters::Yes &&
687-
addGenericParametersHereAndInEnclosingScopes(lookupContextForThisContext))
688-
return;
684+
if (addGenericParameters == AddGenericParameters::Yes) {
685+
addGenericParametersHereAndInEnclosingScopes(lookupContextForThisContext);
686+
if (isFirstResultEnough())
687+
return;
688+
}
689689

690690
if (placesToSearch.hasValue() && !placesToSearch.getValue().empty()) {
691-
auto startIndexOfInnerResults = Results.size();
691+
auto firstPossiblyUnavailableResult = Results.size();
692692
placesToSearch.getValue().addToResults(
693693
Name, isCascadingUse.getValue(), baseNLOptions,
694694
lookupContextForThisContext, Results);
695-
if (setAsideUnavailableResults(startIndexOfInnerResults))
695+
if (setAsideUnavailableResults(firstPossiblyUnavailableResult))
696696
return;
697697
}
698698

@@ -919,7 +919,7 @@ UnqualifiedLookupFactory::getGenericParams(const DeclContext *const dc) {
919919
return nullptr;
920920
}
921921

922-
bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
922+
void UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
923923
DeclContext *dc) {
924924
for (GenericParamList *dcGenericParams = getGenericParams(dc);
925925
dcGenericParams;
@@ -929,9 +929,8 @@ bool UnqualifiedLookupFactory::addGenericParametersHereAndInEnclosingScopes(
929929

930930
recordCompletionOfAScope();
931931
if (isFirstResultEnough())
932-
return true;
932+
break;
933933
}
934-
return false;
935934
}
936935

937936
void UnqualifiedLookupFactory::addGenericParametersForFunction(
@@ -978,10 +977,10 @@ void UnqualifiedLookupFactory::PlacesToSearch::addToResults(
978977
}
979978

980979
bool UnqualifiedLookupFactory::setAsideUnavailableResults(
981-
const size_t startIndexOfInnerResults) {
980+
const size_t firstPossiblyUnavailableResult) {
982981
// An optimization:
983-
assert(Results.size() >= startIndexOfInnerResults);
984-
if (Results.size() == startIndexOfInnerResults)
982+
assert(Results.size() >= firstPossiblyUnavailableResult);
983+
if (Results.size() == firstPossiblyUnavailableResult)
985984
return false;
986985
// Predicate that determines whether a lookup result should
987986
// be unavailable except as a last-ditch effort.
@@ -992,7 +991,7 @@ bool UnqualifiedLookupFactory::setAsideUnavailableResults(
992991
};
993992

994993
// If all of the results we found are unavailable, keep looking.
995-
auto begin = Results.begin() + startIndexOfInnerResults;
994+
auto begin = Results.begin() + firstPossiblyUnavailableResult;
996995
if (std::all_of(begin, Results.end(), unavailableLookupResult)) {
997996
UnavailableInnerResults.append(begin, Results.end());
998997
Results.erase(begin, Results.end());

0 commit comments

Comments
 (0)