[libcxx-commits] [libcxx] 33de5a3 - [libc++] Rename __fwd/hash.h to __fwd/functional.h and add reference_wrapper (#81445)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Mar 3 11:45:20 PST 2024
Author: Nikolas Klauser
Date: 2024-03-03T20:45:17+01:00
New Revision: 33de5a316caa3c9b07ee1ccc7fbc3434247ff787
URL: https://github.com/llvm/llvm-project/commit/33de5a316caa3c9b07ee1ccc7fbc3434247ff787
DIFF: https://github.com/llvm/llvm-project/commit/33de5a316caa3c9b07ee1ccc7fbc3434247ff787.diff
LOG: [libc++] Rename __fwd/hash.h to __fwd/functional.h and add reference_wrapper (#81445)
We forward declare `reference_wrapper` in multiple places already. This
moves the declaration to the canonical place and removes unnecessary
includes of `__functional/reference_wrapper.h`.
Added:
libcxx/include/__fwd/functional.h
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/__filesystem/path.h
libcxx/include/__functional/bind.h
libcxx/include/__functional/hash.h
libcxx/include/__functional/identity.h
libcxx/include/__thread/id.h
libcxx/include/__thread/support/pthread.h
libcxx/include/__type_traits/is_reference_wrapper.h
libcxx/include/__type_traits/unwrap_ref.h
libcxx/include/experimental/propagate_const
libcxx/include/filesystem
libcxx/include/libcxx.imp
libcxx/include/module.modulemap.in
libcxx/include/optional
libcxx/include/type_traits
libcxx/test/libcxx/transitive_includes/cxx23.csv
libcxx/test/libcxx/transitive_includes/cxx26.csv
libcxx/utils/generate_iwyu_mapping.py
Removed:
libcxx/include/__fwd/hash.h
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index cafd8c6e00d968..459b077087e2b5 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -431,7 +431,7 @@ set(files
__fwd/bit_reference.h
__fwd/complex.h
__fwd/fstream.h
- __fwd/hash.h
+ __fwd/functional.h
__fwd/ios.h
__fwd/istream.h
__fwd/mdspan.h
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index 8c7d426f7a6f4f..9ffc90ada5e716 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -14,9 +14,8 @@
#include <__algorithm/replace_copy.h>
#include <__availability>
#include <__config>
-#include <__functional/hash.h>
#include <__functional/unary_function.h>
-#include <__fwd/hash.h>
+#include <__fwd/functional.h>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/iterator_traits.h>
#include <__type_traits/decay.h>
diff --git a/libcxx/include/__functional/bind.h b/libcxx/include/__functional/bind.h
index 19e7d82155ec97..8a0e3b7ffa5840 100644
--- a/libcxx/include/__functional/bind.h
+++ b/libcxx/include/__functional/bind.h
@@ -13,6 +13,7 @@
#include <__config>
#include <__functional/invoke.h>
#include <__functional/weak_result_type.h>
+#include <__fwd/functional.h>
#include <__type_traits/decay.h>
#include <__type_traits/is_reference_wrapper.h>
#include <__type_traits/is_void.h>
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index ff22055d6915e4..a466c837038f8d 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -12,7 +12,7 @@
#include <__config>
#include <__functional/invoke.h>
#include <__functional/unary_function.h>
-#include <__fwd/hash.h>
+#include <__fwd/functional.h>
#include <__tuple/sfinae_helpers.h>
#include <__type_traits/is_copy_constructible.h>
#include <__type_traits/is_default_constructible.h>
diff --git a/libcxx/include/__functional/identity.h b/libcxx/include/__functional/identity.h
index 7fbfc6c6249b65..b7be367bd5eed7 100644
--- a/libcxx/include/__functional/identity.h
+++ b/libcxx/include/__functional/identity.h
@@ -11,7 +11,7 @@
#define _LIBCPP___FUNCTIONAL_IDENTITY_H
#include <__config>
-#include <__functional/reference_wrapper.h>
+#include <__fwd/functional.h>
#include <__type_traits/integral_constant.h>
#include <__utility/forward.h>
diff --git a/libcxx/include/__fwd/hash.h b/libcxx/include/__fwd/functional.h
similarity index 77%
rename from libcxx/include/__fwd/hash.h
rename to libcxx/include/__fwd/functional.h
index af9eca876a1047..32c9ef33e453b1 100644
--- a/libcxx/include/__fwd/hash.h
+++ b/libcxx/include/__fwd/functional.h
@@ -6,8 +6,8 @@
//
//===---------------------------------------------------------------------===//
-#ifndef _LIBCPP___FWD_HASH_H
-#define _LIBCPP___FWD_HASH_H
+#ifndef _LIBCPP___FWD_FUNCTIONAL_H
+#define _LIBCPP___FWD_FUNCTIONAL_H
#include <__config>
@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class>
struct _LIBCPP_TEMPLATE_VIS hash;
+template <class>
+class _LIBCPP_TEMPLATE_VIS reference_wrapper;
+
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP___FWD_HASH_H
+#endif // _LIBCPP___FWD_FUNCTIONAL_H
diff --git a/libcxx/include/__thread/id.h b/libcxx/include/__thread/id.h
index d5aef3f860ce27..6db0ccbfe569b6 100644
--- a/libcxx/include/__thread/id.h
+++ b/libcxx/include/__thread/id.h
@@ -12,7 +12,7 @@
#include <__compare/ordering.h>
#include <__config>
-#include <__fwd/hash.h>
+#include <__fwd/functional.h>
#include <__fwd/ostream.h>
#include <__thread/support.h>
diff --git a/libcxx/include/__thread/support/pthread.h b/libcxx/include/__thread/support/pthread.h
index d8e3f938ddf629..e194e5c68ad339 100644
--- a/libcxx/include/__thread/support/pthread.h
+++ b/libcxx/include/__thread/support/pthread.h
@@ -14,7 +14,6 @@
#include <__chrono/convert_to_timespec.h>
#include <__chrono/duration.h>
#include <__config>
-#include <__fwd/hash.h>
#include <ctime>
#include <errno.h>
#include <pthread.h>
diff --git a/libcxx/include/__type_traits/is_reference_wrapper.h b/libcxx/include/__type_traits/is_reference_wrapper.h
index b638e7046b71ca..310a910040e8be 100644
--- a/libcxx/include/__type_traits/is_reference_wrapper.h
+++ b/libcxx/include/__type_traits/is_reference_wrapper.h
@@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H
#include <__config>
+#include <__fwd/functional.h>
#include <__type_traits/integral_constant.h>
#include <__type_traits/remove_cv.h>
@@ -19,9 +20,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS reference_wrapper;
-
template <class _Tp>
struct __is_reference_wrapper_impl : public false_type {};
template <class _Tp>
diff --git a/libcxx/include/__type_traits/unwrap_ref.h b/libcxx/include/__type_traits/unwrap_ref.h
index 5fed08f7ddda1a..6bd74550f30921 100644
--- a/libcxx/include/__type_traits/unwrap_ref.h
+++ b/libcxx/include/__type_traits/unwrap_ref.h
@@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
#include <__config>
+#include <__fwd/functional.h>
#include <__type_traits/decay.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -23,17 +24,11 @@ struct __unwrap_reference {
typedef _LIBCPP_NODEBUG _Tp type;
};
-template <class _Tp>
-class reference_wrapper;
-
template <class _Tp>
struct __unwrap_reference<reference_wrapper<_Tp> > {
typedef _LIBCPP_NODEBUG _Tp& type;
};
-template <class _Tp>
-struct decay;
-
#if _LIBCPP_STD_VER >= 20
template <class _Tp>
struct unwrap_reference : __unwrap_reference<_Tp> {};
diff --git a/libcxx/include/experimental/propagate_const b/libcxx/include/experimental/propagate_const
index 8c2ceb9def3357..43648015fe80ed 100644
--- a/libcxx/include/experimental/propagate_const
+++ b/libcxx/include/experimental/propagate_const
@@ -108,7 +108,7 @@
*/
#include <__functional/operations.h>
-#include <__fwd/hash.h>
+#include <__fwd/functional.h>
#include <__type_traits/conditional.h>
#include <__type_traits/decay.h>
#include <__type_traits/enable_if.h>
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index b344ed468082e8..eff7dff4a45512 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -564,6 +564,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <concepts>
# include <cstdlib>
+# include <cstring>
# include <iosfwd>
# include <new>
# include <system_error>
diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp
index eeeae39ca101d9..cdbb0a63fc0eae 100644
--- a/libcxx/include/libcxx.imp
+++ b/libcxx/include/libcxx.imp
@@ -426,7 +426,7 @@
{ include: [ "<__fwd/bit_reference.h>", "private", "<vector>", "public" ] },
{ include: [ "<__fwd/complex.h>", "private", "<complex>", "public" ] },
{ include: [ "<__fwd/fstream.h>", "private", "<iosfwd>", "public" ] },
- { include: [ "<__fwd/hash.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__fwd/functional.h>", "private", "<functional>", "public" ] },
{ include: [ "<__fwd/ios.h>", "private", "<iosfwd>", "public" ] },
{ include: [ "<__fwd/istream.h>", "private", "<iosfwd>", "public" ] },
{ include: [ "<__fwd/mdspan.h>", "private", "<mdspan>", "public" ] },
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 219906aa9a5668..b247f97c1804d9 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1365,7 +1365,7 @@ module std_private_functional_hash [system] {
export std_private_type_traits_underlying_type
export std_private_utility_pair
}
-module std_private_functional_hash_fwd [system] { header "__fwd/hash.h" }
+module std_private_functional_fwd [system] { header "__fwd/functional.h" }
module std_private_functional_identity [system] { header "__functional/identity.h" }
module std_private_functional_invoke [system] {
header "__functional/invoke.h"
diff --git a/libcxx/include/optional b/libcxx/include/optional
index 9e4f0fff2f4a7a..99bfd0dd900d3a 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -186,8 +186,8 @@ namespace std {
#include <__exception/exception.h>
#include <__functional/hash.h>
#include <__functional/invoke.h>
-#include <__functional/reference_wrapper.h>
#include <__functional/unary_function.h>
+#include <__fwd/functional.h>
#include <__memory/addressof.h>
#include <__memory/construct_at.h>
#include <__tuple/sfinae_helpers.h>
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 0037c426560e6f..54c8abec340c4d 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -418,7 +418,7 @@ namespace std
*/
#include <__config>
-#include <__fwd/hash.h> // This is https://llvm.org/PR56938
+#include <__fwd/functional.h> // This is https://llvm.org/PR56938
#include <__type_traits/add_const.h>
#include <__type_traits/add_cv.h>
#include <__type_traits/add_lvalue_reference.h>
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 49b3ac265487d7..ce11a358fc3e27 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -178,7 +178,6 @@ experimental/utility utility
filesystem compare
filesystem cstddef
filesystem cstdint
-filesystem cstring
filesystem ctime
filesystem iomanip
filesystem limits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 49b3ac265487d7..ce11a358fc3e27 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -178,7 +178,6 @@ experimental/utility utility
filesystem compare
filesystem cstddef
filesystem cstdint
-filesystem cstring
filesystem ctime
filesystem iomanip
filesystem limits
diff --git a/libcxx/utils/generate_iwyu_mapping.py b/libcxx/utils/generate_iwyu_mapping.py
index 6eb2c6095bf1e7..8ab7b86299edca 100644
--- a/libcxx/utils/generate_iwyu_mapping.py
+++ b/libcxx/utils/generate_iwyu_mapping.py
@@ -34,8 +34,6 @@ def IWYU_mapping(header: str) -> typing.Optional[typing.List[str]]:
return ["atomic", "mutex", "semaphore", "thread"]
elif header == "__tree":
return ["map", "set"]
- elif header == "__fwd/hash.h":
- return ["functional"]
elif header == "__fwd/pair.h":
return ["utility"]
elif header == "__fwd/subrange.h":
More information about the libcxx-commits
mailing list