Skip to content

[cxx-interop] Correctly generate the list of transitive dependencies for CxxStdlib overlay #71813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4232,9 +4232,22 @@ void ClangModuleUnit::getImportedModulesForLookup(
for (auto importMod : topLevelImported) {
auto wrapper = owner.getWrapperForModule(importMod);

auto actualMod = wrapper->getOverlayModule();
if (!actualMod || actualMod == topLevelOverlay)
ModuleDecl *actualMod = nullptr;
if (owner.SwiftContext.LangOpts.EnableCXXInterop && topLevel &&
isCxxStdModule(topLevel) && wrapper->clangModule &&
isCxxStdModule(wrapper->clangModule)) {
// The CxxStdlib overlay re-exports the clang module std, which in recent
// libc++ versions re-exports top-level modules for different std headers
// (std_string, std_vector, etc). The overlay module for each of the std
// modules is the CxxStdlib module itself. Make sure we return the actual
// clang modules (std_xyz) as transitive dependencies instead of just
// CxxStdlib itself.
actualMod = wrapper->getParentModule();
} else {
actualMod = wrapper->getOverlayModule();
if (!actualMod || actualMod == topLevelOverlay)
actualMod = wrapper->getParentModule();
}

assert(actualMod && "Missing imported overlay");
imports.push_back({ImportPath::Access(), actualMod});
Expand Down