@@ -609,6 +609,25 @@ ModuleDependencyScanner::ModuleDependencyScanner(
609
609
DependencyTracker, CAS, ActionCache, PrefixMapper.get (), Diagnostics));
610
610
}
611
611
612
+ // / Find all of the imported Clang modules starting with the given module name.
613
+ static void findAllImportedClangModules (StringRef moduleName,
614
+ const ModuleDependenciesCache &cache,
615
+ std::vector<std::string> &allModules,
616
+ llvm::StringSet<> &knownModules) {
617
+ if (!knownModules.insert (moduleName).second )
618
+ return ;
619
+ allModules.push_back (moduleName.str ());
620
+ auto moduleID =
621
+ ModuleDependencyID{moduleName.str (), ModuleDependencyKind::Clang};
622
+ auto optionalDependencies = cache.findDependency (moduleID);
623
+ if (!optionalDependencies.has_value ())
624
+ return ;
625
+
626
+ for (const auto &dep : cache.getClangDependencies (moduleID))
627
+ findAllImportedClangModules (dep.ModuleName , cache, allModules,
628
+ knownModules);
629
+ }
630
+
612
631
static std::set<ModuleDependencyID>
613
632
collectBinarySwiftDeps (const ModuleDependenciesCache &cache) {
614
633
std::set<ModuleDependencyID> binarySwiftModuleDepIDs;
@@ -1462,7 +1481,14 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
1462
1481
ModuleDependencyIDSetVector &swiftOverlayDependencies) {
1463
1482
PrettyStackTraceStringAction trace (
1464
1483
" Resolving Swift Overlay dependencies of module" , moduleID.ModuleName );
1465
- auto visibleClangDependencies = cache.getVisibleClangModules (moduleID);
1484
+ std::vector<std::string> allClangDependencies;
1485
+ llvm::StringSet<> knownModules;
1486
+
1487
+ // Find all of the discovered Clang modules that this module depends on.
1488
+ for (const auto &dep : cache.getClangDependencies (moduleID))
1489
+ findAllImportedClangModules (dep.ModuleName , cache, allClangDependencies,
1490
+ knownModules);
1491
+
1466
1492
llvm::StringMap<SwiftModuleScannerQueryResult> swiftOverlayLookupResult;
1467
1493
std::mutex lookupResultLock;
1468
1494
@@ -1492,9 +1518,9 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
1492
1518
};
1493
1519
1494
1520
// Enque asynchronous lookup tasks
1495
- for (const auto &clangDep : visibleClangDependencies )
1521
+ for (const auto &clangDep : allClangDependencies )
1496
1522
ScanningThreadPool.async (scanForSwiftDependency,
1497
- getModuleImportIdentifier (clangDep. getKey () ));
1523
+ getModuleImportIdentifier (clangDep));
1498
1524
ScanningThreadPool.wait ();
1499
1525
1500
1526
// Aggregate both previously-cached and freshly-scanned module results
@@ -1521,8 +1547,8 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
1521
1547
lookupResult.incompatibleCandidates , cache, std::nullopt);
1522
1548
}
1523
1549
};
1524
- for (const auto &clangDep : visibleClangDependencies )
1525
- recordResult (clangDep. getKey (). str () );
1550
+ for (const auto &clangDep : allClangDependencies )
1551
+ recordResult (clangDep);
1526
1552
1527
1553
// C++ Interop requires additional handling
1528
1554
bool lookupCxxStdLibOverlay = ScanCompilerInvocation.getLangOptions ().EnableCXXInterop ;
@@ -1543,8 +1569,8 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
1543
1569
}
1544
1570
1545
1571
if (lookupCxxStdLibOverlay) {
1546
- for (const auto &clangDepNameEntry : visibleClangDependencies ) {
1547
- auto clangDepName = clangDepNameEntry. getKey (). str () ;
1572
+ for (const auto &clangDepNameEntry : allClangDependencies ) {
1573
+ auto clangDepName = clangDepNameEntry;
1548
1574
// If this Clang module is a part of the C++ stdlib, and we haven't
1549
1575
// loaded the overlay for it so far, it is a split libc++ module (e.g.
1550
1576
// std_vector). Load the CxxStdlib overlay explicitly.
0 commit comments