@@ -1703,66 +1703,68 @@ static llvm::ErrorOr<ModuleDependencyInfo> identifyMainModuleDependencies(
17031703 rootID = root->getID ().toString ();
17041704 }
17051705
1706- auto mainDependencies =
1706+ auto mainModuleDependencyInfo =
17071707 ModuleDependencyInfo::forSwiftSourceModule (rootID, {}, {}, ExtraPCMArgs);
17081708
1709+ llvm::StringSet<> alreadyAddedModules;
17091710 // Compute Implicit dependencies of the main module
17101711 {
1711- llvm::StringSet<> alreadyAddedModules;
1712- for (auto fileUnit : mainModule->getFiles ()) {
1713- auto sf = dyn_cast<SourceFile>(fileUnit);
1714- if (!sf)
1715- continue ;
1716-
1717- mainDependencies.addModuleImport (*sf, alreadyAddedModules);
1718- }
1719-
17201712 const auto &importInfo = mainModule->getImplicitImportInfo ();
1721-
17221713 // Swift standard library.
17231714 switch (importInfo.StdlibKind ) {
17241715 case ImplicitStdlibKind::None:
17251716 case ImplicitStdlibKind::Builtin:
17261717 break ;
17271718
17281719 case ImplicitStdlibKind::Stdlib:
1729- mainDependencies .addModuleImport (" Swift" , &alreadyAddedModules);
1720+ mainModuleDependencyInfo .addModuleImport (" Swift" , &alreadyAddedModules);
17301721 break ;
17311722 }
17321723
17331724 // Add any implicit module names.
17341725 for (const auto &import : importInfo.AdditionalUnloadedImports ) {
1735- mainDependencies .addModuleImport (import .module .getModulePath (),
1736- &alreadyAddedModules);
1726+ mainModuleDependencyInfo .addModuleImport (import .module .getModulePath (),
1727+ &alreadyAddedModules);
17371728 }
17381729
17391730 // Already-loaded, implicitly imported module names.
17401731 for (const auto &import : importInfo.AdditionalImports ) {
1741- mainDependencies .addModuleImport (
1732+ mainModuleDependencyInfo .addModuleImport (
17421733 import .module .importedModule ->getNameStr (), &alreadyAddedModules);
17431734 }
17441735
17451736 // Add the bridging header.
17461737 if (!importInfo.BridgingHeaderPath .empty ()) {
1747- mainDependencies .addBridgingHeader (importInfo.BridgingHeaderPath );
1738+ mainModuleDependencyInfo .addBridgingHeader (importInfo.BridgingHeaderPath );
17481739 }
17491740
17501741 // If we are to import the underlying Clang module of the same name,
17511742 // add a dependency with the same name to trigger the search.
17521743 if (importInfo.ShouldImportUnderlyingModule ) {
1753- mainDependencies .addModuleImport (mainModule->getName ().str (),
1754- &alreadyAddedModules);
1744+ mainModuleDependencyInfo .addModuleImport (mainModule->getName ().str (),
1745+ &alreadyAddedModules);
17551746 }
17561747
17571748 // All modules specified with `-embed-tbd-for-module` are treated as implicit
17581749 // dependnecies for this compilation since they are not guaranteed to be impored
17591750 // in the source.
17601751 for (const auto &tbdSymbolModule : instance.getInvocation ().getTBDGenOptions ().embedSymbolsFromModules ) {
1761- mainDependencies.addModuleImport (tbdSymbolModule, &alreadyAddedModules);
1752+ mainModuleDependencyInfo.addModuleImport (tbdSymbolModule, &alreadyAddedModules);
1753+ }
1754+ }
1755+
1756+ // Add user-specified `import` dependencies
1757+ {
1758+ for (auto fileUnit : mainModule->getFiles ()) {
1759+ auto sf = dyn_cast<SourceFile>(fileUnit);
1760+ if (!sf)
1761+ continue ;
1762+
1763+ mainModuleDependencyInfo.addModuleImport (*sf, alreadyAddedModules);
17621764 }
17631765 }
17641766
1765- return mainDependencies ;
1767+ return mainModuleDependencyInfo ;
17661768}
17671769
17681770} // namespace
0 commit comments