[libcxx-commits] [PATCH] D156594: [libc++][modules] Improves export validation.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 30 03:48:46 PDT 2023
Mordante created this revision.
Herald added a project: All.
Mordante published this revision for review.
Mordante added a reviewer: ChuanqiXu.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Adds tests to guard against the issue solved in D156592 <https://reviews.llvm.org/D156592>.
Depends on D156592 <https://reviews.llvm.org/D156592>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156594
Files:
libcxx/test/libcxx/module_std.gen.py
libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
Index: libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
===================================================================
--- libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
+++ 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.
Index: libcxx/test/libcxx/module_std.gen.py
===================================================================
--- libcxx/test/libcxx/module_std.gen.py
+++ 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")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156594.545363.patch
Type: text/x-patch
Size: 1634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230730/8f5ababa/attachment.bin>
More information about the libcxx-commits
mailing list