mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #35356 from artemcm/DependencyScannerUseCacheWhenAppropriate
[Dependency Scanning] Optionally, resolve direct dependencies of a module using only the `ModuleDependenciesCache`.
This commit is contained in:
@@ -1528,15 +1528,35 @@ void ASTContext::addModuleInterfaceChecker(
|
||||
|
||||
Optional<ModuleDependencies> ASTContext::getModuleDependencies(
|
||||
StringRef moduleName, bool isUnderlyingClangModule,
|
||||
ModuleDependenciesCache &cache, InterfaceSubContextDelegate &delegate) {
|
||||
for (auto &loader : getImpl().ModuleLoaders) {
|
||||
if (isUnderlyingClangModule &&
|
||||
loader.get() != getImpl().TheClangModuleLoader)
|
||||
continue;
|
||||
ModuleDependenciesCache &cache, InterfaceSubContextDelegate &delegate,
|
||||
bool cacheOnly) {
|
||||
// Retrieve the dependencies for this module.
|
||||
if (cacheOnly) {
|
||||
// Check whether we've cached this result.
|
||||
if (!isUnderlyingClangModule) {
|
||||
if (auto found = cache.findDependencies(moduleName,
|
||||
ModuleDependenciesKind::SwiftTextual))
|
||||
return found;
|
||||
if (auto found = cache.findDependencies(moduleName,
|
||||
ModuleDependenciesKind::SwiftTextual))
|
||||
return found;
|
||||
if (auto found = cache.findDependencies(moduleName,
|
||||
ModuleDependenciesKind::SwiftPlaceholder))
|
||||
return found;
|
||||
}
|
||||
if (auto found = cache.findDependencies(moduleName,
|
||||
ModuleDependenciesKind::Clang))
|
||||
return found;
|
||||
} else {
|
||||
for (auto &loader : getImpl().ModuleLoaders) {
|
||||
if (isUnderlyingClangModule &&
|
||||
loader.get() != getImpl().TheClangModuleLoader)
|
||||
continue;
|
||||
|
||||
if (auto dependencies = loader->getModuleDependencies(moduleName, cache,
|
||||
delegate))
|
||||
return dependencies;
|
||||
if (auto dependencies = loader->getModuleDependencies(moduleName, cache,
|
||||
delegate))
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user