@@ -153,7 +153,8 @@ static void findAllImportedClangModules(ASTContext &ctx, StringRef moduleName,
153153static std::vector<ModuleDependencyID>
154154resolveDirectDependencies (CompilerInstance &instance, ModuleDependencyID module ,
155155 ModuleDependenciesCache &cache,
156- InterfaceSubContextDelegate &ASTDelegate) {
156+ InterfaceSubContextDelegate &ASTDelegate,
157+ bool cacheOnly = false ) {
157158 auto &ctx = instance.getASTContext ();
158159 auto knownDependencies = *cache.findDependencies (module .first , module .second );
159160 auto isSwiftInterface = knownDependencies.isSwiftTextualModule ();
@@ -164,10 +165,8 @@ resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module,
164165 for (auto dependsOn : knownDependencies.getModuleDependencies ()) {
165166 // Figure out what kind of module we need.
166167 bool onlyClangModule = !isSwift || module .first == dependsOn;
167-
168- // Retrieve the dependencies for this module.
169168 if (auto found = ctx.getModuleDependencies (dependsOn, onlyClangModule,
170- cache, ASTDelegate)) {
169+ cache, ASTDelegate, cacheOnly )) {
171170 result.insert ({dependsOn, found->getKind ()});
172171 }
173172 }
@@ -210,7 +209,7 @@ resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module,
210209 // directly depends on these.
211210 for (const auto &clangDep : allClangModules) {
212211 if (auto found = ctx.getModuleDependencies (
213- clangDep, /* onlyClangModule=*/ false , cache, ASTDelegate)) {
212+ clangDep, /* onlyClangModule=*/ false , cache, ASTDelegate, cacheOnly )) {
214213 // ASTContext::getModuleDependencies returns dependencies for a module
215214 // with a given name. This Clang module may have the same name as the
216215 // Swift module we are resolving, so we need to make sure we don't add a
@@ -762,7 +761,7 @@ generateFullDependencyGraph(CompilerInstance &instance,
762761 // DirectDependencies
763762 auto directDependencies = resolveDirectDependencies (
764763 instance, ModuleDependencyID (module .first , module .second ), cache,
765- ASTDelegate);
764+ ASTDelegate, /* cacheOnly */ true );
766765
767766 // Generate a swiftscan_clang_details_t object based on the dependency kind
768767 auto getModuleDetails = [&]() -> swiftscan_module_details_t {
@@ -872,7 +871,7 @@ static bool diagnoseCycle(CompilerInstance &instance,
872871 auto &lastOpen = openSet.back ();
873872 auto beforeSize = openSet.size ();
874873 for (auto dep :
875- resolveDirectDependencies (instance, lastOpen, cache, astDelegate)) {
874+ resolveDirectDependencies (instance, lastOpen, cache, astDelegate, /* cacheOnly */ true )) {
876875 if (closeSet.count (dep))
877876 continue ;
878877 if (openSet.insert (dep)) {
0 commit comments