@@ -602,7 +602,7 @@ static void discoverCrossImportOverlayFiles(
602
602
auto getModuleIDForImportIdentifier =
603
603
[](const std::string &importIdentifierStr,
604
604
const ModuleDependencyIDSet &directSwiftDepsSet,
605
- const ModuleDependencyIDSet &directClangDepsSet) -> ModuleDependencyID {
605
+ const ModuleDependencyIDSet &directClangDepsSet) -> std::optional< ModuleDependencyID> {
606
606
if (auto textualDepIt = directSwiftDepsSet.find (
607
607
{importIdentifierStr, ModuleDependencyKind::SwiftInterface});
608
608
textualDepIt != directSwiftDepsSet.end ())
@@ -615,8 +615,8 @@ static void discoverCrossImportOverlayFiles(
615
615
{importIdentifierStr, ModuleDependencyKind::Clang});
616
616
clangDepIt != directClangDepsSet.end ())
617
617
return *clangDepIt;
618
- llvm_unreachable (
619
- " Unresolved import during cross-import overlay resolution " ) ;
618
+ else
619
+ return std::nullopt ;
620
620
};
621
621
622
622
// Collect the set of directly-imported module dependencies
@@ -625,9 +625,10 @@ static void discoverCrossImportOverlayFiles(
625
625
auto importResolvedModuleID = getModuleIDForImportIdentifier (
626
626
import.importIdentifier , mainModuleDirectSwiftDepsSet,
627
627
mainModuleDirectClangDepsSet);
628
- for (const auto &importLocation : import.importLocations )
629
- perSourceFileDependencies[importLocation.bufferIdentifier ].insert (
630
- importResolvedModuleID);
628
+ if (importResolvedModuleID)
629
+ for (const auto &importLocation : import.importLocations )
630
+ perSourceFileDependencies[importLocation.bufferIdentifier ].insert (
631
+ *importResolvedModuleID);
631
632
}
632
633
633
634
// For each source-file, build a set of module dependencies of the
@@ -658,9 +659,10 @@ static void discoverCrossImportOverlayFiles(
658
659
auto importResolvedDepID = getModuleIDForImportIdentifier (
659
660
import.importIdentifier , directSwiftDepsSet,
660
661
directClangDepsSet);
661
- if (!perSourceFileDependencies[bufferIdentifier].count (
662
- importResolvedDepID))
663
- worklist.push_back (importResolvedDepID);
662
+ if (importResolvedDepID &&
663
+ !perSourceFileDependencies[bufferIdentifier].count (
664
+ *importResolvedDepID))
665
+ worklist.push_back (*importResolvedDepID);
664
666
}
665
667
}
666
668
}
0 commit comments