@@ -1703,66 +1703,68 @@ static llvm::ErrorOr<ModuleDependencyInfo> identifyMainModuleDependencies(
1703
1703
rootID = root->getID ().toString ();
1704
1704
}
1705
1705
1706
- auto mainDependencies =
1706
+ auto mainModuleDependencyInfo =
1707
1707
ModuleDependencyInfo::forSwiftSourceModule (rootID, {}, {}, ExtraPCMArgs);
1708
1708
1709
+ llvm::StringSet<> alreadyAddedModules;
1709
1710
// Compute Implicit dependencies of the main module
1710
1711
{
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
-
1720
1712
const auto &importInfo = mainModule->getImplicitImportInfo ();
1721
-
1722
1713
// Swift standard library.
1723
1714
switch (importInfo.StdlibKind ) {
1724
1715
case ImplicitStdlibKind::None:
1725
1716
case ImplicitStdlibKind::Builtin:
1726
1717
break ;
1727
1718
1728
1719
case ImplicitStdlibKind::Stdlib:
1729
- mainDependencies .addModuleImport (" Swift" , &alreadyAddedModules);
1720
+ mainModuleDependencyInfo .addModuleImport (" Swift" , &alreadyAddedModules);
1730
1721
break ;
1731
1722
}
1732
1723
1733
1724
// Add any implicit module names.
1734
1725
for (const auto &import : importInfo.AdditionalUnloadedImports ) {
1735
- mainDependencies .addModuleImport (import .module .getModulePath (),
1736
- &alreadyAddedModules);
1726
+ mainModuleDependencyInfo .addModuleImport (import .module .getModulePath (),
1727
+ &alreadyAddedModules);
1737
1728
}
1738
1729
1739
1730
// Already-loaded, implicitly imported module names.
1740
1731
for (const auto &import : importInfo.AdditionalImports ) {
1741
- mainDependencies .addModuleImport (
1732
+ mainModuleDependencyInfo .addModuleImport (
1742
1733
import .module .importedModule ->getNameStr (), &alreadyAddedModules);
1743
1734
}
1744
1735
1745
1736
// Add the bridging header.
1746
1737
if (!importInfo.BridgingHeaderPath .empty ()) {
1747
- mainDependencies .addBridgingHeader (importInfo.BridgingHeaderPath );
1738
+ mainModuleDependencyInfo .addBridgingHeader (importInfo.BridgingHeaderPath );
1748
1739
}
1749
1740
1750
1741
// If we are to import the underlying Clang module of the same name,
1751
1742
// add a dependency with the same name to trigger the search.
1752
1743
if (importInfo.ShouldImportUnderlyingModule ) {
1753
- mainDependencies .addModuleImport (mainModule->getName ().str (),
1754
- &alreadyAddedModules);
1744
+ mainModuleDependencyInfo .addModuleImport (mainModule->getName ().str (),
1745
+ &alreadyAddedModules);
1755
1746
}
1756
1747
1757
1748
// All modules specified with `-embed-tbd-for-module` are treated as implicit
1758
1749
// dependnecies for this compilation since they are not guaranteed to be impored
1759
1750
// in the source.
1760
1751
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);
1762
1764
}
1763
1765
}
1764
1766
1765
- return mainDependencies ;
1767
+ return mainModuleDependencyInfo ;
1766
1768
}
1767
1769
1768
1770
} // namespace
0 commit comments