Skip to content

Commit d02d117

Browse files
committed
---
yaml --- r: 278461 b: refs/heads/swift-5.1-old-llvm-branch c: 6982e66 h: refs/heads/master i: 278459: 7de0555
1 parent ac6a9a3 commit d02d117

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a: b6f62823aa5010b2ae53f15f72a57
12411241
refs/heads/marcrasi-astverifier-disable: 3fac766a23a77ebd0640296bfd7fc116ea60a4e0
12421242
refs/heads/revert-22227-a-tall-white-fountain-played: adfce60b2eaa54903ea189bed8a783bca609fa53
12431243
refs/heads/revert-22300-revert-22227-a-tall-white-fountain-played: 5f92040224df7dd4e618fdfb367349df64d8acad
1244-
refs/heads/swift-5.1-old-llvm-branch: 2f099186f9c0a4094d16c83a0eb950b1ca104081
1244+
refs/heads/swift-5.1-old-llvm-branch: 6982e66ddf033762d860e0c5043869df297653b4
12451245
refs/heads/swift-5.1-branch: 8060872acb4105d9655e020fe047e1ebcd77d0fb
12461246
refs/tags/swift-4.2.2-RELEASE: e429d1f1aaf59e69d38207a96e56265c7f6fccec
12471247
refs/tags/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-02-02-a: 3e5a03d32ff3b1e9af90d6c1198c14f938379a6e

branches/swift-5.1-old-llvm-branch/include/swift/AST/NameLookup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ void forAllVisibleModules(const DeclContext *DC, const Fn &fn) {
372372
bool finishLookup(const DeclContext *dc, NLOptions options,
373373
SmallVectorImpl<ValueDecl *> &decls);
374374

375+
/// Do nothing if debugClient is null.
375376
template <typename Result>
376377
void filterForDiscriminator(SmallVectorImpl<Result> &results,
377378
DebuggerClient *debugClient);

branches/swift-5.1-old-llvm-branch/lib/AST/NameLookup.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ matchDiscriminator(Identifier discriminator,
514514
template <typename Result>
515515
void namelookup::filterForDiscriminator(SmallVectorImpl<Result> &results,
516516
DebuggerClient *debugClient) {
517+
if (debugClient == nullptr)
518+
return;
517519
Identifier discriminator = debugClient->getPreferredPrivateDiscriminator();
518520
if (discriminator.empty())
519521
return;
@@ -1362,8 +1364,7 @@ bool namelookup::finishLookup(const DeclContext *dc, NLOptions options,
13621364
if (options & NL_RemoveNonVisible)
13631365
removeShadowedDecls(decls, M);
13641366

1365-
if (auto *debugClient = M->getDebugClient())
1366-
filterForDiscriminator(decls, debugClient);
1367+
filterForDiscriminator(decls, M->getDebugClient());
13671368

13681369
// We're done. Report success/failure.
13691370
return !decls.empty();

branches/swift-5.1-old-llvm-branch/lib/AST/UnqualifiedLookup.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,20 @@ void UnqualifiedLookupFactory::fillInLookup() {
393393
const Optional<bool> isCascadingUseInitial =
394394
options.contains(Flags::KnownPrivate) ? Optional<bool>(false) : None;
395395
// Never perform local lookup for operators.
396-
auto dcAndIsCascadingUse =
397-
shouldUseASTScopeLookup()
398-
? astScopeBasedLookup(DC, isCascadingUseInitial)
399-
: Name.isOperator()
400-
? operatorLookup(DC, isCascadingUseInitial)
401-
: nonASTScopeBasedLookup(DC, isCascadingUseInitial);
402-
403-
if (!dcAndIsCascadingUse.hasValue())
404-
return;
396+
Optional<DCAndResolvedIsCascadingUse> dcAndIsCascadingUse;
397+
if (shouldUseASTScopeLookup()) {
398+
dcAndIsCascadingUse = astScopeBasedLookup(DC, isCascadingUseInitial);
399+
if (!dcAndIsCascadingUse.hasValue())
400+
return;
401+
} else {
402+
dcAndIsCascadingUse =
403+
Name.isOperator() ? operatorLookup(DC, isCascadingUseInitial)
404+
: nonASTScopeBasedLookup(DC, isCascadingUseInitial);
405+
if (!dcAndIsCascadingUse.hasValue())
406+
return;
407+
if (addLocalVariableResults(dcAndIsCascadingUse.getValue().DC))
408+
return;
409+
}
405410

406411
DeclContext *const DC = dcAndIsCascadingUse.getValue().DC;
407412
const bool isCascadingUse = dcAndIsCascadingUse.getValue().isCascadingUse;
@@ -424,7 +429,7 @@ void UnqualifiedLookupFactory::fillInLookup() {
424429
if (lookForAModuleWithTheGivenName(DC))
425430
return;
426431
// Make sure we've recorded the inner-result-boundary.
427-
setIndexOfFirstOuterResultIfNotSetAlready();
432+
setIndexOfFirstOuterResultIfNotSetAlready(); // DMU elim?
428433
}
429434

430435
bool UnqualifiedLookupFactory::shouldUseASTScopeLookup() const {
@@ -634,8 +639,7 @@ UnqualifiedLookupFactory::lookIntoDeclarationContextForASTScopeLookup(
634639
UnavailableInnerResults.append(begin, Results.end());
635640
Results.erase(begin, Results.end());
636641
} else {
637-
if (DebugClient)
638-
filterForDiscriminator(Results, DebugClient);
642+
filterForDiscriminator(Results, DebugClient);
639643

640644
setIndexOfFirstOuterResultIfNotSetAlready();
641645
if (isLookupDoneWithoutIncludingOuterResults())
@@ -657,9 +661,8 @@ UnqualifiedLookupFactory::operatorLookup(DeclContext *dc,
657661
Optional<bool> isCascadingUse) {
658662
auto *msc = dc->getModuleScopeContext();
659663
return DCAndResolvedIsCascadingUse{
660-
addLocalVariableResults(msc) ? nullptr : msc,
661-
resolveIsCascadingUse(dc, isCascadingUse,
662-
/*onlyCareAboutFunctionBody*/ true)};
664+
msc, resolveIsCascadingUse(dc, isCascadingUse,
665+
/*onlyCareAboutFunctionBody*/ true)};
663666
}
664667

665668
// TODO: Unify with LookupVisibleDecls.cpp::lookupVisibleDeclsImpl
@@ -673,7 +676,7 @@ UnqualifiedLookupFactory::nonASTScopeBasedLookup(
673676
DCAndUnresolvedIsCascadingUse{dcArg, isCascadingUseArg});
674677
while (r.hasValue() && !r.getValue().whereToLook->isModuleScopeContext())
675678
r = lookupInOneDeclContext(r.getValue());
676-
if (!r.hasValue() || addLocalVariableResults(r.getValue().whereToLook))
679+
if (!r.hasValue())
677680
return None;
678681
return r.getValue().resolve(true);
679682
}
@@ -955,7 +958,7 @@ void UnqualifiedLookupFactory::addGenericParametersForFunction(
955958
}
956959
}
957960

958-
// TODO enum instead of bool?
961+
// TODO enum instead of bool for return type?
959962
bool UnqualifiedLookupFactory::addLocalVariableResults(DeclContext *dc) {
960963
if (auto SF = dyn_cast<SourceFile>(dc)) {
961964
if (Loc.isValid()) {
@@ -1007,8 +1010,7 @@ bool UnqualifiedLookupFactory::handleUnavailableInnerResults(
10071010
Results.erase(begin, Results.end());
10081011
return false;
10091012
}
1010-
if (DebugClient)
1011-
filterForDiscriminator(Results, DebugClient);
1013+
filterForDiscriminator(Results, DebugClient);
10121014

10131015
setIndexOfFirstOuterResultIfNotSetAlready();
10141016
return isLookupDoneWithoutIncludingOuterResults();
@@ -1043,8 +1045,7 @@ void UnqualifiedLookupFactory::addPrivateImports(DeclContext *const dc) {
10431045
for (auto VD : CurModuleResults)
10441046
Results.push_back(LookupResultEntry(VD));
10451047

1046-
if (DebugClient)
1047-
filterForDiscriminator(Results, DebugClient);
1048+
filterForDiscriminator(Results, DebugClient);
10481049
}
10491050

10501051
bool UnqualifiedLookupFactory::addNamesKnownToDebugClient(DeclContext *dc) {
@@ -1345,8 +1346,7 @@ LegacyUnqualifiedLookup::LegacyUnqualifiedLookup(DeclName Name, DeclContext *DC,
13451346
UnavailableInnerResults.append(begin, Results.end());
13461347
Results.erase(begin, Results.end());
13471348
} else {
1348-
if (DebugClient)
1349-
filterForDiscriminator(Results, DebugClient);
1349+
filterForDiscriminator(Results, DebugClient);
13501350

13511351
if (shouldReturnBasedOnResults())
13521352
return;
@@ -1575,8 +1575,7 @@ LegacyUnqualifiedLookup::LegacyUnqualifiedLookup(DeclName Name, DeclContext *DC,
15751575
UnavailableInnerResults.append(begin, Results.end());
15761576
Results.erase(begin, Results.end());
15771577
} else {
1578-
if (DebugClient)
1579-
filterForDiscriminator(Results, DebugClient);
1578+
filterForDiscriminator(Results, DebugClient);
15801579

15811580
if (shouldReturnBasedOnResults())
15821581
return;
@@ -1634,7 +1633,6 @@ LegacyUnqualifiedLookup::LegacyUnqualifiedLookup(DeclName Name, DeclContext *DC,
16341633
for (auto VD : CurModuleResults)
16351634
Results.push_back(LookupResultEntry(VD));
16361635

1637-
if (DebugClient)
16381636
filterForDiscriminator(Results, DebugClient);
16391637

16401638
// Now add any names the DebugClient knows about to the lookup.

0 commit comments

Comments
 (0)