Skip to content

Commit 96f23d8

Browse files
committed
[cxx-interop] Adjust detection of C++ modules after changes in libc++
libc++ recently split the `std` module into many top-level modules: llvm/llvm-project@571178a This prevented the conformances to `CxxSet`, `CxxVector`, etc. from being synthesized with a fresh libc++ version. rdar://119270491 (cherry picked from commit 24b0d6e)
1 parent 482c0d2 commit 96f23d8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7466,6 +7466,11 @@ bool importer::requiresCPlusPlus(const clang::Module *module) {
74667466
// The libc++ modulemap doesn't currently declare the requirement.
74677467
if (module->getTopLevelModuleName() == "std")
74687468
return true;
7469+
// In recent libc++ versions the module is split into multiple top-level
7470+
// modules (std_vector, std_utility, etc).
7471+
if (module->getTopLevelModule()->IsSystem &&
7472+
module->getTopLevelModuleName().starts_with("std_"))
7473+
return true;
74697474

74707475
// Modulemaps often declare the requirement for the top-level module only.
74717476
if (auto parent = module->Parent) {

lib/ClangImporter/ImportDecl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3267,7 +3267,10 @@ namespace {
32673267
->getTopLevelModule()
32683268
->getFullModuleName() == n;
32693269
};
3270-
if (topLevelModuleEq(decl, "std")) {
3270+
if (topLevelModuleEq(decl, "std") ||
3271+
(decl->getOwningModule() && decl->getOwningModule()->IsSystem &&
3272+
StringRef(decl->getOwningModule()->getTopLevelModule()->Name)
3273+
.starts_with("std_"))) {
32713274
if (isAlternativeCStdlibFunctionFromTextualHeader(decl)) {
32723275
return nullptr;
32733276
}

0 commit comments

Comments
 (0)