mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning][C++ Interop] Do not skip lookup of 'CxxStdlib' overlay for the source module
A prior change ensured that we forego this query when looking up Swift overlays for a textual interface which was built without C++ interop. This change introduced a bug where it also caused us to skip this lookup for the main source module. This commit resolves that by preserving the fix above but also ensuring we perform the lookup for the main source module under scan.
This commit is contained in:
@@ -1408,11 +1408,10 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
|
||||
recordResult(clangDep);
|
||||
|
||||
// C++ Interop requires additional handling
|
||||
if (ScanCompilerInvocation.getLangOptions().EnableCXXInterop &&
|
||||
moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
|
||||
bool lookupCxxStdLibOverlay = ScanCompilerInvocation.getLangOptions().EnableCXXInterop;
|
||||
if (lookupCxxStdLibOverlay && moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
|
||||
const auto &moduleInfo = cache.findKnownDependency(moduleID);
|
||||
const auto commandLine = moduleInfo.getCommandline();
|
||||
|
||||
// If the textual interface was built without C++ interop, do not query
|
||||
// the C++ Standard Library Swift overlay for its compilation.
|
||||
//
|
||||
@@ -1420,27 +1419,30 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
|
||||
// without C++Interop, for compatibility with prior versions. Once we are certain
|
||||
// that we are only building against modules built with support of
|
||||
// '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
|
||||
if (moduleID.ModuleName != "Darwin" &&
|
||||
llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") ==
|
||||
commandLine.end()) {
|
||||
for (const auto &clangDepName : allClangDependencies) {
|
||||
// If this Clang module is a part of the C++ stdlib, and we haven't
|
||||
// loaded the overlay for it so far, it is a split libc++ module (e.g.
|
||||
// std_vector). Load the CxxStdlib overlay explicitly.
|
||||
const auto &clangDepInfo =
|
||||
cache.findDependency(clangDepName, ModuleDependencyKind::Clang)
|
||||
.value()
|
||||
->getAsClangModule();
|
||||
if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) &&
|
||||
!swiftOverlayDependencies.contains(
|
||||
{clangDepName, ModuleDependencyKind::SwiftInterface}) &&
|
||||
!swiftOverlayDependencies.contains(
|
||||
{clangDepName, ModuleDependencyKind::SwiftBinary})) {
|
||||
scanForSwiftDependency(
|
||||
getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str()));
|
||||
recordResult(ScanASTContext.Id_CxxStdlib.str().str());
|
||||
break;
|
||||
}
|
||||
if (moduleID.ModuleName == "Darwin" ||
|
||||
llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") !=
|
||||
commandLine.end())
|
||||
lookupCxxStdLibOverlay = false;
|
||||
}
|
||||
|
||||
if (lookupCxxStdLibOverlay) {
|
||||
for (const auto &clangDepName : allClangDependencies) {
|
||||
// If this Clang module is a part of the C++ stdlib, and we haven't
|
||||
// loaded the overlay for it so far, it is a split libc++ module (e.g.
|
||||
// std_vector). Load the CxxStdlib overlay explicitly.
|
||||
const auto &clangDepInfo =
|
||||
cache.findDependency(clangDepName, ModuleDependencyKind::Clang)
|
||||
.value()
|
||||
->getAsClangModule();
|
||||
if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) &&
|
||||
!swiftOverlayDependencies.contains(
|
||||
{clangDepName, ModuleDependencyKind::SwiftInterface}) &&
|
||||
!swiftOverlayDependencies.contains(
|
||||
{clangDepName, ModuleDependencyKind::SwiftBinary})) {
|
||||
scanForSwiftDependency(
|
||||
getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str()));
|
||||
recordResult(ScanASTContext.Id_CxxStdlib.str().str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user