@@ -1408,39 +1408,41 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
14081408 recordResult (clangDep);
14091409
14101410 // C++ Interop requires additional handling
1411- if ( ScanCompilerInvocation.getLangOptions ().EnableCXXInterop &&
1412- moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
1411+ bool lookupCxxStdLibOverlay = ScanCompilerInvocation.getLangOptions ().EnableCXXInterop ;
1412+ if (lookupCxxStdLibOverlay && moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
14131413 const auto &moduleInfo = cache.findKnownDependency (moduleID);
14141414 const auto commandLine = moduleInfo.getCommandline ();
1415-
14161415 // If the textual interface was built without C++ interop, do not query
14171416 // the C++ Standard Library Swift overlay for its compilation.
14181417 //
14191418 // FIXME: We always declare the 'Darwin' module as formally having been built
14201419 // without C++Interop, for compatibility with prior versions. Once we are certain
14211420 // that we are only building against modules built with support of
14221421 // '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
1423- if (moduleID.ModuleName != " Darwin" &&
1424- llvm::find (commandLine, " -formal-cxx-interoperability-mode=off" ) ==
1425- commandLine.end ()) {
1426- for (const auto &clangDepName : allClangDependencies) {
1427- // If this Clang module is a part of the C++ stdlib, and we haven't
1428- // loaded the overlay for it so far, it is a split libc++ module (e.g.
1429- // std_vector). Load the CxxStdlib overlay explicitly.
1430- const auto &clangDepInfo =
1431- cache.findDependency (clangDepName, ModuleDependencyKind::Clang)
1432- .value ()
1433- ->getAsClangModule ();
1434- if (importer::isCxxStdModule (clangDepName, clangDepInfo->IsSystem ) &&
1435- !swiftOverlayDependencies.contains (
1436- {clangDepName, ModuleDependencyKind::SwiftInterface}) &&
1437- !swiftOverlayDependencies.contains (
1438- {clangDepName, ModuleDependencyKind::SwiftBinary})) {
1439- scanForSwiftDependency (
1440- getModuleImportIdentifier (ScanASTContext.Id_CxxStdlib .str ()));
1441- recordResult (ScanASTContext.Id_CxxStdlib .str ().str ());
1442- break ;
1443- }
1422+ if (moduleID.ModuleName == " Darwin" ||
1423+ llvm::find (commandLine, " -formal-cxx-interoperability-mode=off" ) !=
1424+ commandLine.end ())
1425+ lookupCxxStdLibOverlay = false ;
1426+ }
1427+
1428+ if (lookupCxxStdLibOverlay) {
1429+ for (const auto &clangDepName : allClangDependencies) {
1430+ // If this Clang module is a part of the C++ stdlib, and we haven't
1431+ // loaded the overlay for it so far, it is a split libc++ module (e.g.
1432+ // std_vector). Load the CxxStdlib overlay explicitly.
1433+ const auto &clangDepInfo =
1434+ cache.findDependency (clangDepName, ModuleDependencyKind::Clang)
1435+ .value ()
1436+ ->getAsClangModule ();
1437+ if (importer::isCxxStdModule (clangDepName, clangDepInfo->IsSystem ) &&
1438+ !swiftOverlayDependencies.contains (
1439+ {clangDepName, ModuleDependencyKind::SwiftInterface}) &&
1440+ !swiftOverlayDependencies.contains (
1441+ {clangDepName, ModuleDependencyKind::SwiftBinary})) {
1442+ scanForSwiftDependency (
1443+ getModuleImportIdentifier (ScanASTContext.Id_CxxStdlib .str ()));
1444+ recordResult (ScanASTContext.Id_CxxStdlib .str ().str ());
1445+ break ;
14441446 }
14451447 }
14461448 }
0 commit comments