diff --git a/libcxx/test/libcxx/module_std.gen.py b/libcxx/test/libcxx/module_std.gen.py --- a/libcxx/test/libcxx/module_std.gen.py +++ b/libcxx/test/libcxx/module_std.gen.py @@ -225,3 +225,10 @@ # Compare the sum of the parts with the main module. print(f"// RUN{BLOCKLIT}: diff -u %t.all_partitions %t.module") + +# Basic smoke test. Import a module and try to compile when using all +# exported names. This validates the clang-tidy script does not accidentally +# add named declarations to the list that are not available. +print(f"// RUN{BLOCKLIT}: echo 'import std;' > %t.compile.pass.cpp") +print(f"// RUN{BLOCKLIT}: cat %t.all_partitions >> %t.compile.pass.cpp") +print(f"// RUN{BLOCKLIT}: %{{cxx}} %{{flags}} %{{compile_flags}} -fsyntax-only %t.compile.pass.cpp") diff --git a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp --- a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp +++ b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp @@ -228,6 +228,11 @@ if (clang::Module* M = decl->getOwningModule(); M && M->Kind != clang::Module::ModulePartitionInterface) return; + // For module partitions only take exported declarations. + if (file_type_ == FileType::ModulePartition) + if (decl->getModuleOwnershipKind() != clang::Decl::ModuleOwnershipKind::VisibleWhenImported) + return; + if (decls_.contains(name)) { // For modules avoid exporting the same named declaration twice. For // header files this is common and valid.