@@ -153,7 +153,8 @@ static void findAllImportedClangModules(ASTContext &ctx, StringRef moduleName,
153
153
static std::vector<ModuleDependencyID>
154
154
resolveDirectDependencies (CompilerInstance &instance, ModuleDependencyID module ,
155
155
ModuleDependenciesCache &cache,
156
- InterfaceSubContextDelegate &ASTDelegate) {
156
+ InterfaceSubContextDelegate &ASTDelegate,
157
+ bool cacheOnly = false ) {
157
158
auto &ctx = instance.getASTContext ();
158
159
auto knownDependencies = *cache.findDependencies (module .first , module .second );
159
160
auto isSwiftInterface = knownDependencies.isSwiftTextualModule ();
@@ -164,10 +165,8 @@ resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module,
164
165
for (auto dependsOn : knownDependencies.getModuleDependencies ()) {
165
166
// Figure out what kind of module we need.
166
167
bool onlyClangModule = !isSwift || module .first == dependsOn;
167
-
168
- // Retrieve the dependencies for this module.
169
168
if (auto found = ctx.getModuleDependencies (dependsOn, onlyClangModule,
170
- cache, ASTDelegate)) {
169
+ cache, ASTDelegate, cacheOnly )) {
171
170
result.insert ({dependsOn, found->getKind ()});
172
171
}
173
172
}
@@ -210,7 +209,7 @@ resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module,
210
209
// directly depends on these.
211
210
for (const auto &clangDep : allClangModules) {
212
211
if (auto found = ctx.getModuleDependencies (
213
- clangDep, /* onlyClangModule=*/ false , cache, ASTDelegate)) {
212
+ clangDep, /* onlyClangModule=*/ false , cache, ASTDelegate, cacheOnly )) {
214
213
// ASTContext::getModuleDependencies returns dependencies for a module
215
214
// with a given name. This Clang module may have the same name as the
216
215
// Swift module we are resolving, so we need to make sure we don't add a
@@ -762,7 +761,7 @@ generateFullDependencyGraph(CompilerInstance &instance,
762
761
// DirectDependencies
763
762
auto directDependencies = resolveDirectDependencies (
764
763
instance, ModuleDependencyID (module .first , module .second ), cache,
765
- ASTDelegate);
764
+ ASTDelegate, /* cacheOnly */ true );
766
765
767
766
// Generate a swiftscan_clang_details_t object based on the dependency kind
768
767
auto getModuleDetails = [&]() -> swiftscan_module_details_t {
@@ -872,7 +871,7 @@ static bool diagnoseCycle(CompilerInstance &instance,
872
871
auto &lastOpen = openSet.back ();
873
872
auto beforeSize = openSet.size ();
874
873
for (auto dep :
875
- resolveDirectDependencies (instance, lastOpen, cache, astDelegate)) {
874
+ resolveDirectDependencies (instance, lastOpen, cache, astDelegate, /* cacheOnly */ true )) {
876
875
if (closeSet.count (dep))
877
876
continue ;
878
877
if (openSet.insert (dep)) {
0 commit comments