Skip to content

Commit 06f9c01

Browse files
authored
Merge pull request #70411 from apple/egorzhdan/libcxx-requires-cplusplus
[cxx-interop] Adjust detection of C++ modules after changes in libc++
2 parents 295b6ac + 24b0d6e commit 06f9c01

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
@@ -7626,6 +7626,11 @@ bool importer::requiresCPlusPlus(const clang::Module *module) {
76267626
// The libc++ modulemap doesn't currently declare the requirement.
76277627
if (module->getTopLevelModuleName() == "std")
76287628
return true;
7629+
// In recent libc++ versions the module is split into multiple top-level
7630+
// modules (std_vector, std_utility, etc).
7631+
if (module->getTopLevelModule()->IsSystem &&
7632+
module->getTopLevelModuleName().starts_with("std_"))
7633+
return true;
76297634

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

lib/ClangImporter/ImportDecl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3389,7 +3389,10 @@ namespace {
33893389
->getTopLevelModule()
33903390
->getFullModuleName() == n;
33913391
};
3392-
if (topLevelModuleEq(decl, "std")) {
3392+
if (topLevelModuleEq(decl, "std") ||
3393+
(decl->getOwningModule() && decl->getOwningModule()->IsSystem &&
3394+
StringRef(decl->getOwningModule()->getTopLevelModule()->Name)
3395+
.starts_with("std_"))) {
33933396
if (isAlternativeCStdlibFunctionFromTextualHeader(decl)) {
33943397
return nullptr;
33953398
}

0 commit comments

Comments
 (0)