mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanner] Do not re-use prior source dependencies in successive scans
If a scanner instance is used for multiple scans, the `SwiftDependencyScanningService` will have collected prior scans' main source modules' dependency info. Suppose the scanner first scans a source module `A` and records its dependencies. If a successive scan of some source module `B` finds that it depends on `A`, it would get a cache hit on the source module from a prior scan and re-use dependency information. This change no longer allows such re-use of the prior source module scan dependencies. Said prior scan may have had an entirely different context and therefore different set of dependencies on `A` than may be visible otherwise. Instead, all scanning actions must rely on such modules being re-discovered on the filesystem.
This commit is contained in:
@@ -422,7 +422,19 @@ ModuleDependenciesCache::ModuleDependenciesCache(
|
||||
Optional<const ModuleDependencyInfo*>
|
||||
ModuleDependenciesCache::findDependency(
|
||||
StringRef moduleName, Optional<ModuleDependencyKind> kind) const {
|
||||
return globalScanningService.findDependency(moduleName, kind);
|
||||
auto optionalDep = globalScanningService.findDependency(moduleName, kind);
|
||||
// During a scan, only produce the cached source module info for the current module
|
||||
// under scan.
|
||||
if (optionalDep.hasValue()) {
|
||||
auto dep = optionalDep.getValue();
|
||||
if (dep->getAsSwiftSourceModule() &&
|
||||
moduleName != mainScanModuleName &&
|
||||
moduleName != "DummyMainModuleForResolvingCrossImportOverlays") {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
return optionalDep;
|
||||
}
|
||||
|
||||
bool ModuleDependenciesCache::hasDependency(
|
||||
|
||||
Reference in New Issue
Block a user