[libcxx-commits] [libcxx] b793280 - [libc++] Moves unwrap_reference to type_traits.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 14 11:04:04 PDT 2023


Author: Mark de Wever
Date: 2023-05-14T20:03:55+02:00
New Revision: b7932803dede5f95eed3b1777dfd40ce94ef1676

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

LOG: [libc++] Moves unwrap_reference to type_traits.

This was discovered while working on modules.

Reviewed By: #libc, philnik

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

Added: 
    libcxx/include/__type_traits/unwrap_ref.h

Modified: 
    libcxx/include/CMakeLists.txt
    libcxx/include/__utility/pair.h
    libcxx/include/functional
    libcxx/include/module.modulemap.in
    libcxx/include/tuple
    libcxx/include/type_traits
    libcxx/test/libcxx/private_headers.verify.cpp
    libcxx/utils/data/ignore_format.txt

Removed: 
    libcxx/include/__functional/unwrap_ref.h


################################################################################
diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 83b920a79b814..4dd363de4d173 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -395,7 +395,6 @@ set(files
   __functional/reference_wrapper.h
   __functional/unary_function.h
   __functional/unary_negate.h
-  __functional/unwrap_ref.h
   __functional/weak_result_type.h
   __fwd/array.h
   __fwd/fstream.h
@@ -792,6 +791,7 @@ set(files
   __type_traits/type_identity.h
   __type_traits/type_list.h
   __type_traits/underlying_type.h
+  __type_traits/unwrap_ref.h
   __type_traits/void_t.h
   __undef_macros
   __utility/as_const.h

diff  --git a/libcxx/include/__functional/unwrap_ref.h b/libcxx/include/__type_traits/unwrap_ref.h
similarity index 89%
rename from libcxx/include/__functional/unwrap_ref.h
rename to libcxx/include/__type_traits/unwrap_ref.h
index 3abad73ac7f28..94cc8ea722edf 100644
--- a/libcxx/include/__functional/unwrap_ref.h
+++ b/libcxx/include/__type_traits/unwrap_ref.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
-#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
+#ifndef _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
+#define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
 
 #include <__config>
 #include <__type_traits/decay.h>
@@ -42,7 +42,7 @@ struct unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > { };
 
 template <class _Tp>
 using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
-#endif // > C++17
+#endif // _LIBCPP_STD_VER >= 20
 
 template <class _Tp>
 struct __unwrap_ref_decay
@@ -55,4 +55,4 @@ struct __unwrap_ref_decay
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
+#endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H

diff  --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index 65a4cc078023d..bb4b75ab82d7c 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -13,7 +13,6 @@
 #include <__compare/synth_three_way.h>
 #include <__concepts/
diff erent_from.h>
 #include <__config>
-#include <__functional/unwrap_ref.h>
 #include <__fwd/array.h>
 #include <__fwd/get.h>
 #include <__fwd/subrange.h>
@@ -45,6 +44,7 @@
 #include <__type_traits/is_swappable.h>
 #include <__type_traits/nat.h>
 #include <__type_traits/remove_cvref.h>
+#include <__type_traits/unwrap_ref.h>
 #include <__utility/declval.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>

diff  --git a/libcxx/include/functional b/libcxx/include/functional
index 05d42fcff232e..63af88750491f 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -541,7 +541,7 @@ POLICY:  For non-variadic implementations, the number of arguments is limited
 #include <__functional/reference_wrapper.h>
 #include <__functional/unary_function.h>
 #include <__functional/unary_negate.h>
-#include <__functional/unwrap_ref.h>
+#include <__type_traits/unwrap_ref.h>
 #include <__utility/forward.h>
 #include <memory> // TODO: find out why removing this breaks the modules build
 #include <typeinfo>

diff  --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index c4d680eda5936..fcf793f0e63fe 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -977,6 +977,8 @@ module std [system] {
   }
   module functional {
     header "functional"
+    // the contents of __type_traits/unwrap_ref.h should be available from functional too.
+    export type_traits.unwrap_ref
     export *
 
     module __functional {
@@ -1010,7 +1012,6 @@ module std [system] {
       module reference_wrapper          { private header "__functional/reference_wrapper.h" }
       module unary_function             { private header "__functional/unary_function.h" }
       module unary_negate               { private header "__functional/unary_negate.h" }
-      module unwrap_ref                 { private header "__functional/unwrap_ref.h" }
       module weak_result_type           { private header "__functional/weak_result_type.h" }
     }
   }
@@ -1521,7 +1522,6 @@ module std [system] {
   }
   module type_traits {
     header "type_traits"
-    export functional.__functional.unwrap_ref
     export *
 
     module add_const                                 { private header "__type_traits/add_const.h" }
@@ -1682,6 +1682,7 @@ module std [system] {
 
       export type_traits
     }
+    module unwrap_ref                                { private header "__type_traits/unwrap_ref.h" }
     module void_t                                    { private header "__type_traits/void_t.h" }
   }
   module typeindex {

diff  --git a/libcxx/include/tuple b/libcxx/include/tuple
index 3c9715f6f02fe..fe7432f443109 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -206,7 +206,6 @@ template <class... Types>
 #include <__compare/synth_three_way.h>
 #include <__config>
 #include <__functional/invoke.h>
-#include <__functional/unwrap_ref.h>
 #include <__fwd/array.h>
 #include <__fwd/tuple.h>
 #include <__memory/allocator_arg_t.h>
@@ -252,6 +251,7 @@ template <class... Types>
 #include <__type_traits/negation.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
+#include <__type_traits/unwrap_ref.h>
 #include <__utility/forward.h>
 #include <__utility/integer_sequence.h>
 #include <__utility/move.h>

diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 7646f5805980a..a157299481343 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -532,6 +532,7 @@ namespace std
 #include <__type_traits/result_of.h>
 #include <__type_traits/type_identity.h>
 #include <__type_traits/underlying_type.h>
+#include <__type_traits/unwrap_ref.h>
 #include <__type_traits/void_t.h>
 #include <__utility/declval.h>
 #include <cstddef>

diff  --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp
index 60d7081da09a5..33cc828b92182 100644
--- a/libcxx/test/libcxx/private_headers.verify.cpp
+++ b/libcxx/test/libcxx/private_headers.verify.cpp
@@ -431,7 +431,6 @@ END-SCRIPT
 #include <__functional/reference_wrapper.h> // expected-error@*:* {{use of private header from outside its module: '__functional/reference_wrapper.h'}}
 #include <__functional/unary_function.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unary_function.h'}}
 #include <__functional/unary_negate.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unary_negate.h'}}
-#include <__functional/unwrap_ref.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unwrap_ref.h'}}
 #include <__functional/weak_result_type.h> // expected-error@*:* {{use of private header from outside its module: '__functional/weak_result_type.h'}}
 #include <__fwd/array.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/array.h'}}
 #include <__fwd/fstream.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/fstream.h'}}
@@ -776,6 +775,7 @@ END-SCRIPT
 #include <__type_traits/type_identity.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/type_identity.h'}}
 #include <__type_traits/type_list.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/type_list.h'}}
 #include <__type_traits/underlying_type.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/underlying_type.h'}}
+#include <__type_traits/unwrap_ref.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/unwrap_ref.h'}}
 #include <__type_traits/void_t.h> // expected-error@*:* {{use of private header from outside its module: '__type_traits/void_t.h'}}
 #include <__utility/as_const.h> // expected-error@*:* {{use of private header from outside its module: '__utility/as_const.h'}}
 #include <__utility/auto_cast.h> // expected-error@*:* {{use of private header from outside its module: '__utility/auto_cast.h'}}

diff  --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index c32f5ecfa9cf7..4c7e9cfecad31 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -394,7 +394,6 @@ libcxx/include/__functional/ranges_operations.h
 libcxx/include/__functional/reference_wrapper.h
 libcxx/include/__functional/unary_function.h
 libcxx/include/__functional/unary_negate.h
-libcxx/include/__functional/unwrap_ref.h
 libcxx/include/__functional/weak_result_type.h
 libcxx/include/future
 libcxx/include/__fwd/get.h
@@ -757,6 +756,7 @@ libcxx/include/__type_traits/strip_signature.h
 libcxx/include/__type_traits/type_identity.h
 libcxx/include/__type_traits/type_list.h
 libcxx/include/__type_traits/underlying_type.h
+libcxx/include/__type_traits/unwrap_ref.h
 libcxx/include/__type_traits/void_t.h
 libcxx/include/uchar.h
 libcxx/include/unordered_map


        


More information about the libcxx-commits mailing list