[libcxx-commits] [libcxx] c62e88e - [libc++][modules] Avoids duplicated exports.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jul 8 04:19:48 PDT 2023
Author: Mark de Wever
Date: 2023-07-08T13:19:43+02:00
New Revision: c62e88eeef2d391084ea7ce351558daad1aca003
URL: https://github.com/llvm/llvm-project/commit/c62e88eeef2d391084ea7ce351558daad1aca003
DIFF: https://github.com/llvm/llvm-project/commit/c62e88eeef2d391084ea7ce351558daad1aca003.diff
LOG: [libc++][modules] Avoids duplicated exports.
The first issue was found by @ldionne, upon further investigation there
were more duplicates. This removes the duplicates and updates the
clang-tidy test to detect duplicates.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D154723
Added:
Modified:
libcxx/modules/std/cmath.cppm
libcxx/modules/std/filesystem.cppm
libcxx/modules/std/iterator.cppm
libcxx/modules/std/memory.cppm
libcxx/modules/std/numbers.cppm
libcxx/modules/std/stack.cppm
libcxx/modules/std/tuple.cppm
libcxx/modules/std/utility.cppm
libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
Removed:
################################################################################
diff --git a/libcxx/modules/std/cmath.cppm b/libcxx/modules/std/cmath.cppm
index d3a26046fb448e..26f6ed99ce456d 100644
--- a/libcxx/modules/std/cmath.cppm
+++ b/libcxx/modules/std/cmath.cppm
@@ -140,7 +140,6 @@ export namespace std {
using std::hypotl;
// [c.math.hypot3], three-dimensional hypotenuse
- using std::hypot;
using std::pow;
using std::powf;
diff --git a/libcxx/modules/std/filesystem.cppm b/libcxx/modules/std/filesystem.cppm
index 670ab465b0aff5..ea8136b4ef9fcf 100644
--- a/libcxx/modules/std/filesystem.cppm
+++ b/libcxx/modules/std/filesystem.cppm
@@ -36,8 +36,6 @@ export namespace std::filesystem {
using std::filesystem::recursive_directory_iterator;
// [fs.rec.dir.itr.nonmembers], range access for recursive directory iterators
- using std::filesystem::begin;
- using std::filesystem::end;
// [fs.class.file.status], file status
using std::filesystem::file_status;
diff --git a/libcxx/modules/std/iterator.cppm b/libcxx/modules/std/iterator.cppm
index e78719a039f77e..65fa363181eaa5 100644
--- a/libcxx/modules/std/iterator.cppm
+++ b/libcxx/modules/std/iterator.cppm
@@ -101,8 +101,6 @@ export namespace std {
// [projected], projected
using std::projected;
- using std::incrementable_traits;
-
// [alg.req], common algorithm requirements
// [alg.req.ind.move], concept indirectly_movable
using std::indirectly_movable;
@@ -210,8 +208,6 @@ export namespace std {
using std::common_iterator;
- using std::incrementable_traits;
-
// [default.sentinel], default sentinel
using std::default_sentinel;
using std::default_sentinel_t;
diff --git a/libcxx/modules/std/memory.cppm b/libcxx/modules/std/memory.cppm
index eb59cd4155daca..46a88cba018e84 100644
--- a/libcxx/modules/std/memory.cppm
+++ b/libcxx/modules/std/memory.cppm
@@ -129,8 +129,6 @@ export namespace std {
using std::make_unique;
using std::make_unique_for_overwrite;
- using std::swap;
-
using std::operator<;
using std::operator>;
using std::operator<=;
diff --git a/libcxx/modules/std/numbers.cppm b/libcxx/modules/std/numbers.cppm
index d9d1d6561cab82..6b9a62a7c7a924 100644
--- a/libcxx/modules/std/numbers.cppm
+++ b/libcxx/modules/std/numbers.cppm
@@ -26,20 +26,6 @@ export namespace std::numbers {
using std::numbers::sqrt2_v;
using std::numbers::sqrt3_v;
- using std::numbers::e_v;
- using std::numbers::egamma_v;
- using std::numbers::inv_pi_v;
- using std::numbers::inv_sqrt3_v;
- using std::numbers::inv_sqrtpi_v;
- using std::numbers::ln10_v;
- using std::numbers::ln2_v;
- using std::numbers::log10e_v;
- using std::numbers::log2e_v;
- using std::numbers::phi_v;
- using std::numbers::pi_v;
- using std::numbers::sqrt2_v;
- using std::numbers::sqrt3_v;
-
using std::numbers::e;
using std::numbers::egamma;
using std::numbers::inv_pi;
diff --git a/libcxx/modules/std/stack.cppm b/libcxx/modules/std/stack.cppm
index 74b04d1137dff5..91cec2dd189dc1 100644
--- a/libcxx/modules/std/stack.cppm
+++ b/libcxx/modules/std/stack.cppm
@@ -15,7 +15,6 @@ export namespace std {
// [stack], class template stack
using std::stack;
- using std::operator==;
using std::operator==;
using std::operator!=;
using std::operator<;
diff --git a/libcxx/modules/std/tuple.cppm b/libcxx/modules/std/tuple.cppm
index 7e6c30dca0cf2f..6c7dc5c7bf009f 100644
--- a/libcxx/modules/std/tuple.cppm
+++ b/libcxx/modules/std/tuple.cppm
@@ -38,8 +38,6 @@ export namespace std {
using std::tuple_element;
using std::tuple_size;
- using std::tuple_element_t;
-
// [tuple.elem], element access
using std::get;
using std::tuple_element_t;
diff --git a/libcxx/modules/std/utility.cppm b/libcxx/modules/std/utility.cppm
index eaa0ac94ca130d..b6aa2aea503022 100644
--- a/libcxx/modules/std/utility.cppm
+++ b/libcxx/modules/std/utility.cppm
@@ -70,9 +70,6 @@ export namespace std {
using std::tuple_element;
using std::tuple_size;
- using std::tuple_element;
- using std::tuple_size;
-
using std::get;
// [pair.piecewise], pair piecewise construction
diff --git a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
index b73d893c8dddb2..9f2a667c67b16a 100644
--- a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
+++ b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp
@@ -112,7 +112,6 @@ void header_exportable_declarations::registerMatchers(clang::ast_matchers::Match
switch (file_type_) {
case FileType::Header:
-
finder->addMatcher(
namedDecl(
// Looks at the common locations where headers store their data
@@ -229,8 +228,16 @@ void header_exportable_declarations::check(const clang::ast_matchers::MatchFinde
if (clang::Module* M = decl->getOwningModule(); M && M->Kind != clang::Module::ModulePartitionInterface)
return;
- if (decls_.contains(name))
- return;
+ if (decls_.contains(name)) {
+ // For modules avoid exporting the same named declaration twice. For
+ // header files this is common and valid.
+ if (file_type_ == FileType::ModulePartition)
+ // After the warning the script continues.
+ // The test will fail since modules have duplicated entries and headers not.
+ llvm::errs() << "Duplicated export of '" << name << "'.\n";
+ else
+ return;
+ }
std::cout << "using " << std::string{name} << ";\n";
decls_.insert(name);
More information about the libcxx-commits
mailing list