[libcxx-commits] [libcxx] ec11388 - [libc++] Rename __tuple to __tuple_dir to avoid file collision

Michał Górny via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 21 10:21:11 PST 2022


Author: Michał Górny
Date: 2022-12-21T19:19:58+01:00
New Revision: ec11388b3342a2b22eae22fd13ff4997b103d155

URL: https://github.com/llvm/llvm-project/commit/ec11388b3342a2b22eae22fd13ff4997b103d155
DIFF: https://github.com/llvm/llvm-project/commit/ec11388b3342a2b22eae22fd13ff4997b103d155.diff

LOG: [libc++] Rename __tuple to __tuple_dir to avoid file collision

Rename the `__tuple` directory in libc++ headers to `__tuple_dir`
to avoid file collision when installing.  Historically, `__tuple` has
been a file and it has been replaced by a directory
in 2d52c6bfae801b016dd3627b8c0e7c4a99405549.  Replacing a regular file
with a directory (or more importantly, the other way around when
downgrading) is not universally supported.  Since this is an internal
header, its actual name should not matter, so just rename it to avoid
problems.

Differential Revision: https://reviews.llvm.org/D139270

Added: 
    libcxx/include/__tuple_dir/apply_cv.h
    libcxx/include/__tuple_dir/make_tuple_types.h
    libcxx/include/__tuple_dir/sfinae_helpers.h
    libcxx/include/__tuple_dir/tuple_element.h
    libcxx/include/__tuple_dir/tuple_indices.h
    libcxx/include/__tuple_dir/tuple_like.h
    libcxx/include/__tuple_dir/tuple_size.h
    libcxx/include/__tuple_dir/tuple_types.h

Modified: 
    libcxx/include/CMakeLists.txt
    libcxx/include/__functional/hash.h
    libcxx/include/__fwd/get.h
    libcxx/include/__memory/compressed_pair.h
    libcxx/include/__ranges/subrange.h
    libcxx/include/__utility/pair.h
    libcxx/include/array
    libcxx/include/libcxx.imp
    libcxx/include/module.modulemap.in
    libcxx/include/optional
    libcxx/include/ranges
    libcxx/include/utility
    libcxx/test/libcxx/private_headers.verify.cpp
    libcxx/utils/generate_iwyu_mapping.py

Removed: 
    libcxx/include/__tuple/apply_cv.h
    libcxx/include/__tuple/make_tuple_types.h
    libcxx/include/__tuple/sfinae_helpers.h
    libcxx/include/__tuple/tuple_element.h
    libcxx/include/__tuple/tuple_indices.h
    libcxx/include/__tuple/tuple_like.h
    libcxx/include/__tuple/tuple_size.h
    libcxx/include/__tuple/tuple_types.h


################################################################################
diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 62fa8d96d0600..ea1e23af1c9d7 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -540,14 +540,14 @@ set(files
   __thread/timed_backoff_policy.h
   __threading_support
   __tree
-  __tuple/apply_cv.h
-  __tuple/make_tuple_types.h
-  __tuple/sfinae_helpers.h
-  __tuple/tuple_element.h
-  __tuple/tuple_indices.h
-  __tuple/tuple_like.h
-  __tuple/tuple_size.h
-  __tuple/tuple_types.h
+  __tuple_dir/apply_cv.h
+  __tuple_dir/make_tuple_types.h
+  __tuple_dir/sfinae_helpers.h
+  __tuple_dir/tuple_element.h
+  __tuple_dir/tuple_indices.h
+  __tuple_dir/tuple_like.h
+  __tuple_dir/tuple_size.h
+  __tuple_dir/tuple_types.h
   __type_traits/add_const.h
   __type_traits/add_cv.h
   __type_traits/add_lvalue_reference.h

diff  --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index 041730dfb6b11..64412fc9f6a86 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -12,7 +12,7 @@
 #include <__config>
 #include <__functional/unary_function.h>
 #include <__fwd/hash.h>
-#include <__tuple/sfinae_helpers.h>
+#include <__tuple_dir/sfinae_helpers.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <__utility/pair.h>

diff  --git a/libcxx/include/__fwd/get.h b/libcxx/include/__fwd/get.h
index 81624038980e6..98758ebca0df2 100644
--- a/libcxx/include/__fwd/get.h
+++ b/libcxx/include/__fwd/get.h
@@ -13,7 +13,7 @@
 #include <__fwd/array.h>
 #include <__fwd/pair.h>
 #include <__fwd/tuple.h>
-#include <__tuple/tuple_element.h>
+#include <__tuple_dir/tuple_element.h>
 #include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

diff  --git a/libcxx/include/__memory/compressed_pair.h b/libcxx/include/__memory/compressed_pair.h
index 9dd42f8d6eb6c..6f747e78bfad2 100644
--- a/libcxx/include/__memory/compressed_pair.h
+++ b/libcxx/include/__memory/compressed_pair.h
@@ -13,7 +13,7 @@
 #include <__config>
 #include <__fwd/get.h>
 #include <__fwd/tuple.h>
-#include <__tuple/tuple_indices.h>
+#include <__tuple_dir/tuple_indices.h>
 #include <__type_traits/dependent_type.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>

diff  --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h
index 3efcd9602a204..55689fe42d536 100644
--- a/libcxx/include/__ranges/subrange.h
+++ b/libcxx/include/__ranges/subrange.h
@@ -28,8 +28,8 @@
 #include <__ranges/enable_borrowed_range.h>
 #include <__ranges/size.h>
 #include <__ranges/view_interface.h>
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_size.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
 #include <__utility/move.h>
 #include <type_traits>
 

diff  --git a/libcxx/include/__tuple/apply_cv.h b/libcxx/include/__tuple_dir/apply_cv.h
similarity index 100%
rename from libcxx/include/__tuple/apply_cv.h
rename to libcxx/include/__tuple_dir/apply_cv.h

diff  --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple_dir/make_tuple_types.h
similarity index 93%
rename from libcxx/include/__tuple/make_tuple_types.h
rename to libcxx/include/__tuple_dir/make_tuple_types.h
index 38e2547d13dcf..913ff9bbd60c5 100644
--- a/libcxx/include/__tuple/make_tuple_types.h
+++ b/libcxx/include/__tuple_dir/make_tuple_types.h
@@ -12,11 +12,11 @@
 #include <__config>
 #include <__fwd/array.h>
 #include <__fwd/tuple.h>
-#include <__tuple/apply_cv.h>
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_indices.h>
-#include <__tuple/tuple_size.h>
-#include <__tuple/tuple_types.h>
+#include <__tuple_dir/apply_cv.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_indices.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__tuple_dir/tuple_types.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_reference.h>
 #include <cstddef>

diff  --git a/libcxx/include/__tuple/sfinae_helpers.h b/libcxx/include/__tuple_dir/sfinae_helpers.h
similarity index 97%
rename from libcxx/include/__tuple/sfinae_helpers.h
rename to libcxx/include/__tuple_dir/sfinae_helpers.h
index ef3967015b80c..fde53419d07b9 100644
--- a/libcxx/include/__tuple/sfinae_helpers.h
+++ b/libcxx/include/__tuple_dir/sfinae_helpers.h
@@ -11,11 +11,11 @@
 
 #include <__config>
 #include <__fwd/tuple.h>
-#include <__tuple/make_tuple_types.h>
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_like.h>
-#include <__tuple/tuple_size.h>
-#include <__tuple/tuple_types.h>
+#include <__tuple_dir/make_tuple_types.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_like.h>
+#include <__tuple_dir/tuple_size.h>
+#include <__tuple_dir/tuple_types.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_assignable.h>

diff  --git a/libcxx/include/__tuple/tuple_element.h b/libcxx/include/__tuple_dir/tuple_element.h
similarity index 97%
rename from libcxx/include/__tuple/tuple_element.h
rename to libcxx/include/__tuple_dir/tuple_element.h
index d30b2c148dbfe..06f49bf500fb7 100644
--- a/libcxx/include/__tuple/tuple_element.h
+++ b/libcxx/include/__tuple_dir/tuple_element.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
 
 #include <__config>
-#include <__tuple/tuple_indices.h>
-#include <__tuple/tuple_types.h>
+#include <__tuple_dir/tuple_indices.h>
+#include <__tuple_dir/tuple_types.h>
 #include <__type_traits/add_const.h>
 #include <__type_traits/add_cv.h>
 #include <__type_traits/add_volatile.h>

diff  --git a/libcxx/include/__tuple/tuple_indices.h b/libcxx/include/__tuple_dir/tuple_indices.h
similarity index 100%
rename from libcxx/include/__tuple/tuple_indices.h
rename to libcxx/include/__tuple_dir/tuple_indices.h

diff  --git a/libcxx/include/__tuple/tuple_like.h b/libcxx/include/__tuple_dir/tuple_like.h
similarity index 97%
rename from libcxx/include/__tuple/tuple_like.h
rename to libcxx/include/__tuple_dir/tuple_like.h
index 3b596916a65e6..327287786e3b2 100644
--- a/libcxx/include/__tuple/tuple_like.h
+++ b/libcxx/include/__tuple_dir/tuple_like.h
@@ -13,7 +13,7 @@
 #include <__fwd/array.h>
 #include <__fwd/pair.h>
 #include <__fwd/tuple.h>
-#include <__tuple/tuple_types.h>
+#include <__tuple_dir/tuple_types.h>
 #include <__type_traits/integral_constant.h>
 #include <cstddef>
 

diff  --git a/libcxx/include/__tuple/tuple_size.h b/libcxx/include/__tuple_dir/tuple_size.h
similarity index 98%
rename from libcxx/include/__tuple/tuple_size.h
rename to libcxx/include/__tuple_dir/tuple_size.h
index 26f9d9725d316..d551b2258cbaf 100644
--- a/libcxx/include/__tuple/tuple_size.h
+++ b/libcxx/include/__tuple_dir/tuple_size.h
@@ -11,7 +11,7 @@
 
 #include <__config>
 #include <__fwd/tuple.h>
-#include <__tuple/tuple_types.h>
+#include <__tuple_dir/tuple_types.h>
 #include <__type_traits/is_const.h>
 #include <__type_traits/is_volatile.h>
 #include <cstddef>

diff  --git a/libcxx/include/__tuple/tuple_types.h b/libcxx/include/__tuple_dir/tuple_types.h
similarity index 100%
rename from libcxx/include/__tuple/tuple_types.h
rename to libcxx/include/__tuple_dir/tuple_types.h

diff  --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index d9286891189e6..e1832980b3895 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -15,10 +15,10 @@
 #include <__functional/unwrap_ref.h>
 #include <__fwd/get.h>
 #include <__fwd/tuple.h>
-#include <__tuple/sfinae_helpers.h>
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_indices.h>
-#include <__tuple/tuple_size.h>
+#include <__tuple_dir/sfinae_helpers.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_indices.h>
+#include <__tuple_dir/tuple_size.h>
 #include <__type_traits/is_implicitly_default_constructible.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>

diff  --git a/libcxx/include/array b/libcxx/include/array
index cb1a6d1202582..068a6bd4cc428 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -115,7 +115,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
 #include <__iterator/reverse_iterator.h>
-#include <__tuple/sfinae_helpers.h>
+#include <__tuple_dir/sfinae_helpers.h>
 #include <__utility/integer_sequence.h>
 #include <__utility/move.h>
 #include <__utility/unreachable.h>
@@ -137,8 +137,8 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
 #include <initializer_list>
 
 // [tuple.helper]
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_size.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp
index b2a018e30b2f9..2c591b71737b0 100644
--- a/libcxx/include/libcxx.imp
+++ b/libcxx/include/libcxx.imp
@@ -39,7 +39,7 @@
   { include: [ "@<__string/.*>", "private", "<string>", "public" ] },
   { include: [ "@<__support/.*>", "private", "<support>", "public" ] },
   { include: [ "@<__thread/.*>", "private", "<thread>", "public" ] },
-  { include: [ "@<__tuple/.*>", "private", "<tuple>", "public" ] },
+  { include: [ "@<__tuple_dir/.*>", "private", "<tuple>", "public" ] },
   { include: [ "@<__type_traits/.*>", "private", "<type_traits>", "public" ] },
   { include: [ "@<__utility/.*>", "private", "<utility>", "public" ] },
   { include: [ "@<__variant/.*>", "private", "<variant>", "public" ] },

diff  --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 2a2064c74aea3..c0473a4f3d2d9 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1342,16 +1342,16 @@ module std [system] {
     header "tuple"
     export *
 
-    module apply_cv         { private header "__tuple/apply_cv.h" }
+    module apply_cv         { private header "__tuple_dir/apply_cv.h" }
     module get_fwd          { private header "__fwd/get.h" }
-    module make_tuple_types { private header "__tuple/make_tuple_types.h" }
-    module sfinae_helpers   { private header "__tuple/sfinae_helpers.h" }
-    module tuple_element    { private header "__tuple/tuple_element.h" }
+    module make_tuple_types { private header "__tuple_dir/make_tuple_types.h" }
+    module sfinae_helpers   { private header "__tuple_dir/sfinae_helpers.h" }
+    module tuple_element    { private header "__tuple_dir/tuple_element.h" }
     module tuple_fwd        { private header "__fwd/tuple.h" }
-    module tuple_indices    { private header "__tuple/tuple_indices.h" }
-    module tuple_like       { private header "__tuple/tuple_like.h" }
-    module tuple_size       { private header "__tuple/tuple_size.h" }
-    module tuple_types      { private header "__tuple/tuple_types.h" }
+    module tuple_indices    { private header "__tuple_dir/tuple_indices.h" }
+    module tuple_like       { private header "__tuple_dir/tuple_like.h" }
+    module tuple_size       { private header "__tuple_dir/tuple_size.h" }
+    module tuple_types      { private header "__tuple_dir/tuple_types.h" }
   }
   module type_traits {
     header "type_traits"

diff  --git a/libcxx/include/optional b/libcxx/include/optional
index 1061a0f9c3789..a7a887a9cbdcc 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -166,7 +166,7 @@ template<class T>
 #include <__functional/invoke.h>
 #include <__functional/unary_function.h>
 #include <__memory/construct_at.h>
-#include <__tuple/sfinae_helpers.h>
+#include <__tuple_dir/sfinae_helpers.h>
 #include <__utility/forward.h>
 #include <__utility/in_place.h>
 #include <__utility/move.h>

diff  --git a/libcxx/include/ranges b/libcxx/include/ranges
index 643853e1d3abe..5928efa6027ec 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -352,8 +352,8 @@ namespace std {
 #include <iterator>
 
 // [tuple.helper]
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_size.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/utility b/libcxx/include/utility
index ac6c18b06abc1..3cc7ce5b30252 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -267,8 +267,8 @@ template <class T>
 #include <initializer_list>
 
 // [tuple.helper]
-#include <__tuple/tuple_element.h>
-#include <__tuple/tuple_size.h>
+#include <__tuple_dir/tuple_element.h>
+#include <__tuple_dir/tuple_size.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp
index 23186a9581971..6ecc220f50af1 100644
--- a/libcxx/test/libcxx/private_headers.verify.cpp
+++ b/libcxx/test/libcxx/private_headers.verify.cpp
@@ -553,14 +553,14 @@ END-SCRIPT
 #include <__string/extern_template_lists.h> // expected-error@*:* {{use of private header from outside its module: '__string/extern_template_lists.h'}}
 #include <__thread/poll_with_backoff.h> // expected-error@*:* {{use of private header from outside its module: '__thread/poll_with_backoff.h'}}
 #include <__thread/timed_backoff_policy.h> // expected-error@*:* {{use of private header from outside its module: '__thread/timed_backoff_policy.h'}}
-#include <__tuple/apply_cv.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/apply_cv.h'}}
-#include <__tuple/make_tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/make_tuple_types.h'}}
-#include <__tuple/sfinae_helpers.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/sfinae_helpers.h'}}
-#include <__tuple/tuple_element.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_element.h'}}
-#include <__tuple/tuple_indices.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_indices.h'}}
-#include <__tuple/tuple_like.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_like.h'}}
-#include <__tuple/tuple_size.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_size.h'}}
-#include <__tuple/tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/tuple_types.h'}}
+#include <__tuple_dir/apply_cv.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/apply_cv.h'}}
+#include <__tuple_dir/make_tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/make_tuple_types.h'}}
+#include <__tuple_dir/sfinae_helpers.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/sfinae_helpers.h'}}
+#include <__tuple_dir/tuple_element.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/tuple_element.h'}}
+#include <__tuple_dir/tuple_indices.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/tuple_indices.h'}}
+#include <__tuple_dir/tuple_like.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/tuple_like.h'}}
+#include <__tuple_dir/tuple_size.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/tuple_size.h'}}
+#include <__tuple_dir/tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple_dir/tuple_types.h'}}
 #include <__type_traits/add_const.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_const.h'}}
 #include <__type_traits/add_cv.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_cv.h'}}
 #include <__type_traits/add_lvalue_reference.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/add_lvalue_reference.h'}}

diff  --git a/libcxx/utils/generate_iwyu_mapping.py b/libcxx/utils/generate_iwyu_mapping.py
index 615c6e3e534a4..1e0242b954d36 100644
--- a/libcxx/utils/generate_iwyu_mapping.py
+++ b/libcxx/utils/generate_iwyu_mapping.py
@@ -30,8 +30,10 @@ def generate_map(include):
             c_headers.append(i.name)
 
     result = []
+    temporary_mappings = {'__tuple_dir': 'tuple'}
     for i in detail_directories:
-        result.append(f'{generate(f"@<{i}/.*>", i[2:])},')
+        public_header = temporary_mappings.get(i, i.lstrip('_'))
+        result.append(f'{generate(f"@<{i}/.*>", public_header)},')
 
     for i in detail_files:
         public = []


        


More information about the libcxx-commits mailing list