Skip to content

Commit dfdebfa

Browse files
committed
[NFC] Gate Cross-Module Dependency Sinks on Incremental Info
This has the net effect of only recording cross-module dependency information in the current module if the module under scrutiny can possibly provide dependency information of its own. For now, because none of this is turned on, this does not actually record additional dependencies from extant modules.
1 parent d2e7bdc commit dfdebfa

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

lib/AST/NameLookupRequests.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,15 @@ void DirectLookupRequest::writeDependencySink(
300300

301301
void LookupInModuleRequest::writeDependencySink(
302302
evaluator::DependencyCollector &reqTracker, QualifiedLookupResult l) const {
303-
auto *module = std::get<0>(getStorage());
303+
auto *DC = std::get<0>(getStorage());
304304
auto member = std::get<1>(getStorage());
305-
auto *DC = std::get<4>(getStorage());
306305

307-
// Decline to record lookups outside our module.
308-
if (!DC->getParentSourceFile() ||
309-
module->getParentModule() != DC->getParentModule()) {
310-
return;
306+
// Decline to record lookups if the module in question has no incremental
307+
// dependency information available.
308+
auto *module = DC->getParentModule();
309+
if (module->isMainModule() || module->hasIncrementalInfo()) {
310+
reqTracker.addTopLevelName(member.getBaseName());
311311
}
312-
reqTracker.addTopLevelName(member.getBaseName());
313312
}
314313

315314
//----------------------------------------------------------------------------//
@@ -343,16 +342,14 @@ swift::extractNearestSourceLoc(const LookupConformanceDescriptor &desc) {
343342

344343
void ModuleQualifiedLookupRequest::writeDependencySink(
345344
evaluator::DependencyCollector &reqTracker, QualifiedLookupResult l) const {
346-
auto *DC = std::get<0>(getStorage());
347345
auto *module = std::get<1>(getStorage());
348346
auto member = std::get<2>(getStorage());
349347

350-
// Decline to record lookups outside our module.
351-
if (!DC->getParentSourceFile() ||
352-
module != DC->getModuleScopeContext()->getParentModule()) {
353-
return;
348+
// Decline to record lookups if the module in question has no incremental
349+
// dependency information available.
350+
if (module->isMainModule() || module->hasIncrementalInfo()) {
351+
reqTracker.addTopLevelName(member.getBaseName());
354352
}
355-
reqTracker.addTopLevelName(member.getBaseName());
356353
}
357354

358355
//----------------------------------------------------------------------------//
@@ -370,16 +367,13 @@ void LookupConformanceInModuleRequest::writeDependencySink(
370367
if (!Adoptee)
371368
return;
372369

373-
auto source = reqTracker.getRecorder().getActiveDependencySourceOrNull();
374-
if (source.isNull())
375-
return;
376-
377-
// Decline to record conformances defined outside of the active module.
370+
// Decline to record lookups if the module in question has no incremental
371+
// dependency information available.
378372
auto *conformance = lookupResult.getConcrete();
379-
if (source.get()->getParentModule() !=
380-
conformance->getDeclContext()->getParentModule())
381-
return;
382-
reqTracker.addPotentialMember(Adoptee);
373+
auto *module = conformance->getDeclContext()->getParentModule();
374+
if (module->isMainModule() || module->hasIncrementalInfo()) {
375+
reqTracker.addPotentialMember(Adoptee);
376+
}
383377
}
384378

385379
//----------------------------------------------------------------------------//

0 commit comments

Comments
 (0)