|
21 | 21 | #include "swift/AST/TypeCheckRequests.h" |
22 | 22 | #include "swift/Basic/FileTypes.h" |
23 | 23 | #include "swift/Basic/PrettyStackTrace.h" |
| 24 | +#include "swift/ClangImporter/ClangImporter.h" |
24 | 25 | #include "swift/DependencyScan/ModuleDependencyScanner.h" |
25 | 26 | #include "swift/Frontend/ModuleInterfaceLoader.h" |
26 | 27 | #include "swift/Serialization/SerializedModuleLoader.h" |
@@ -774,24 +775,46 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependencies( |
774 | 775 | // FIXME: Once all clients know to fetch these dependencies from |
775 | 776 | // `swiftOverlayDependencies`, the goal is to no longer have them in |
776 | 777 | // `directDependencies` so the following will need to go away. |
777 | | - directDependencies.insert({moduleName, cachedInfo->getKind()}); |
| 778 | + directDependencies.insert({moduleName, cachedInfo->getKind()}); |
778 | 779 | } else { |
779 | 780 | // Cache discovered module dependencies. |
780 | 781 | cache.recordDependencies(lookupResult.value()); |
781 | 782 | if (!lookupResult.value().empty()) { |
782 | | - swiftOverlayDependencies.insert( |
783 | | - {moduleName, lookupResult.value()[0].first.Kind}); |
| 783 | + swiftOverlayDependencies.insert({moduleName, lookupResult.value()[0].first.Kind}); |
784 | 784 | // FIXME: Once all clients know to fetch these dependencies from |
785 | 785 | // `swiftOverlayDependencies`, the goal is to no longer have them in |
786 | 786 | // `directDependencies` so the following will need to go away. |
787 | | - directDependencies.insert( |
788 | | - {moduleName, lookupResult.value()[0].first.Kind}); |
789 | | - } |
| 787 | + directDependencies.insert({moduleName, lookupResult.value()[0].first.Kind}); |
| 788 | + } |
790 | 789 | } |
791 | 790 | } |
792 | 791 | }; |
793 | 792 | for (const auto &clangDep : clangDependencies) |
794 | 793 | recordResult(clangDep); |
| 794 | + |
| 795 | + // C++ Interop requires additional handling |
| 796 | + if (ScanCompilerInvocation.getLangOptions().EnableCXXInterop) { |
| 797 | + for (const auto &clangDepName : clangDependencies) { |
| 798 | + // If this Clang module is a part of the C++ stdlib, and we haven't loaded |
| 799 | + // the overlay for it so far, it is a split libc++ module (e.g. |
| 800 | + // std_vector). Load the CxxStdlib overlay explicitly. |
| 801 | + const auto &clangDepInfo = |
| 802 | + cache.findDependency(clangDepName, ModuleDependencyKind::Clang) |
| 803 | + .value() |
| 804 | + ->getAsClangModule(); |
| 805 | + if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) && |
| 806 | + !swiftOverlayDependencies.contains( |
| 807 | + {clangDepName, ModuleDependencyKind::SwiftInterface}) && |
| 808 | + !swiftOverlayDependencies.contains( |
| 809 | + {clangDepName, ModuleDependencyKind::SwiftBinary})) { |
| 810 | + ScanningThreadPool.async( |
| 811 | + scanForSwiftDependency, |
| 812 | + getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str())); |
| 813 | + ScanningThreadPool.wait(); |
| 814 | + recordResult(ScanASTContext.Id_CxxStdlib.str().str()); |
| 815 | + } |
| 816 | + } |
| 817 | + } |
795 | 818 | } |
796 | 819 |
|
797 | 820 | void ModuleDependencyScanner::discoverCrossImportOverlayDependencies( |
|
0 commit comments