mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Have the scanner cache answer queries relevant to current search paths only.
The dependency scanner's cache persists across different queries and answering a subsequent query's module lookup with a module not in the query's search path is not correct. For example, suppose we are looking for a Swift module `Foo` with a set of search paths `SP`. And dependency scanner cache already contains a module `Foo`, for which we found an interface file at location `L`. If `L`∉`SP`, then we cannot re-use the cached entry because we’d be resolving the scanning query to a filesystem location that the current scanning context is not aware of. Resolves rdar://81175942
This commit is contained in:
@@ -165,15 +165,19 @@ ErrorOr<ModuleDependencies> ModuleDependencyScanner::scanInterfaceFile(
|
||||
Optional<ModuleDependencies> SerializedModuleLoaderBase::getModuleDependencies(
|
||||
StringRef moduleName, ModuleDependenciesCache &cache,
|
||||
InterfaceSubContextDelegate &delegate) {
|
||||
auto currentSearchPathSet = Ctx.getAllModuleSearchPathsSet();
|
||||
// Check whether we've cached this result.
|
||||
if (auto found = cache.findDependencies(
|
||||
moduleName, ModuleDependenciesKind::SwiftTextual))
|
||||
moduleName,
|
||||
{ModuleDependenciesKind::SwiftTextual, currentSearchPathSet}))
|
||||
return found;
|
||||
if (auto found = cache.findDependencies(
|
||||
moduleName, ModuleDependenciesKind::SwiftBinary))
|
||||
moduleName,
|
||||
{ModuleDependenciesKind::SwiftBinary, currentSearchPathSet}))
|
||||
return found;
|
||||
if (auto found = cache.findDependencies(
|
||||
moduleName, ModuleDependenciesKind::SwiftPlaceholder))
|
||||
moduleName,
|
||||
{ModuleDependenciesKind::SwiftPlaceholder, currentSearchPathSet}))
|
||||
return found;
|
||||
|
||||
auto moduleId = Ctx.getIdentifier(moduleName);
|
||||
|
||||
Reference in New Issue
Block a user