Skip to content

Commit 33de5a3

Browse files
authored
[libc++] Rename __fwd/hash.h to __fwd/functional.h and add reference_wrapper (llvm#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`.
1 parent 0c90e88 commit 33de5a3

File tree

19 files changed

+20
-28
lines changed

19 files changed

+20
-28
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ set(files
431431
__fwd/bit_reference.h
432432
__fwd/complex.h
433433
__fwd/fstream.h
434-
__fwd/hash.h
434+
__fwd/functional.h
435435
__fwd/ios.h
436436
__fwd/istream.h
437437
__fwd/mdspan.h

libcxx/include/__filesystem/path.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
#include <__algorithm/replace_copy.h>
1515
#include <__availability>
1616
#include <__config>
17-
#include <__functional/hash.h>
1817
#include <__functional/unary_function.h>
19-
#include <__fwd/hash.h>
18+
#include <__fwd/functional.h>
2019
#include <__iterator/back_insert_iterator.h>
2120
#include <__iterator/iterator_traits.h>
2221
#include <__type_traits/decay.h>

libcxx/include/__functional/bind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <__config>
1414
#include <__functional/invoke.h>
1515
#include <__functional/weak_result_type.h>
16+
#include <__fwd/functional.h>
1617
#include <__type_traits/decay.h>
1718
#include <__type_traits/is_reference_wrapper.h>
1819
#include <__type_traits/is_void.h>

libcxx/include/__functional/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <__config>
1313
#include <__functional/invoke.h>
1414
#include <__functional/unary_function.h>
15-
#include <__fwd/hash.h>
15+
#include <__fwd/functional.h>
1616
#include <__tuple/sfinae_helpers.h>
1717
#include <__type_traits/is_copy_constructible.h>
1818
#include <__type_traits/is_default_constructible.h>

libcxx/include/__functional/identity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define _LIBCPP___FUNCTIONAL_IDENTITY_H
1212

1313
#include <__config>
14-
#include <__functional/reference_wrapper.h>
14+
#include <__fwd/functional.h>
1515
#include <__type_traits/integral_constant.h>
1616
#include <__utility/forward.h>
1717

libcxx/include/__fwd/hash.h renamed to libcxx/include/__fwd/functional.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===---------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___FWD_HASH_H
10-
#define _LIBCPP___FWD_HASH_H
9+
#ifndef _LIBCPP___FWD_FUNCTIONAL_H
10+
#define _LIBCPP___FWD_FUNCTIONAL_H
1111

1212
#include <__config>
1313

@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
template <class>
2121
struct _LIBCPP_TEMPLATE_VIS hash;
2222

23+
template <class>
24+
class _LIBCPP_TEMPLATE_VIS reference_wrapper;
25+
2326
_LIBCPP_END_NAMESPACE_STD
2427

25-
#endif // _LIBCPP___FWD_HASH_H
28+
#endif // _LIBCPP___FWD_FUNCTIONAL_H

libcxx/include/__thread/id.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <__compare/ordering.h>
1414
#include <__config>
15-
#include <__fwd/hash.h>
15+
#include <__fwd/functional.h>
1616
#include <__fwd/ostream.h>
1717
#include <__thread/support.h>
1818

libcxx/include/__thread/support/pthread.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <__chrono/convert_to_timespec.h>
1515
#include <__chrono/duration.h>
1616
#include <__config>
17-
#include <__fwd/hash.h>
1817
#include <ctime>
1918
#include <errno.h>
2019
#include <pthread.h>

libcxx/include/__type_traits/is_reference_wrapper.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H
1111

1212
#include <__config>
13+
#include <__fwd/functional.h>
1314
#include <__type_traits/integral_constant.h>
1415
#include <__type_traits/remove_cv.h>
1516

@@ -19,9 +20,6 @@
1920

2021
_LIBCPP_BEGIN_NAMESPACE_STD
2122

22-
template <class _Tp>
23-
class _LIBCPP_TEMPLATE_VIS reference_wrapper;
24-
2523
template <class _Tp>
2624
struct __is_reference_wrapper_impl : public false_type {};
2725
template <class _Tp>

libcxx/include/__type_traits/unwrap_ref.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
1111

1212
#include <__config>
13+
#include <__fwd/functional.h>
1314
#include <__type_traits/decay.h>
1415

1516
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -23,17 +24,11 @@ struct __unwrap_reference {
2324
typedef _LIBCPP_NODEBUG _Tp type;
2425
};
2526

26-
template <class _Tp>
27-
class reference_wrapper;
28-
2927
template <class _Tp>
3028
struct __unwrap_reference<reference_wrapper<_Tp> > {
3129
typedef _LIBCPP_NODEBUG _Tp& type;
3230
};
3331

34-
template <class _Tp>
35-
struct decay;
36-
3732
#if _LIBCPP_STD_VER >= 20
3833
template <class _Tp>
3934
struct unwrap_reference : __unwrap_reference<_Tp> {};

libcxx/include/experimental/propagate_const

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
*/
109109

110110
#include <__functional/operations.h>
111-
#include <__fwd/hash.h>
111+
#include <__fwd/functional.h>
112112
#include <__type_traits/conditional.h>
113113
#include <__type_traits/decay.h>
114114
#include <__type_traits/enable_if.h>

libcxx/include/filesystem

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
564564
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
565565
# include <concepts>
566566
# include <cstdlib>
567+
# include <cstring>
567568
# include <iosfwd>
568569
# include <new>
569570
# include <system_error>

libcxx/include/libcxx.imp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426
{ include: [ "<__fwd/bit_reference.h>", "private", "<vector>", "public" ] },
427427
{ include: [ "<__fwd/complex.h>", "private", "<complex>", "public" ] },
428428
{ include: [ "<__fwd/fstream.h>", "private", "<iosfwd>", "public" ] },
429-
{ include: [ "<__fwd/hash.h>", "private", "<functional>", "public" ] },
429+
{ include: [ "<__fwd/functional.h>", "private", "<functional>", "public" ] },
430430
{ include: [ "<__fwd/ios.h>", "private", "<iosfwd>", "public" ] },
431431
{ include: [ "<__fwd/istream.h>", "private", "<iosfwd>", "public" ] },
432432
{ include: [ "<__fwd/mdspan.h>", "private", "<mdspan>", "public" ] },

libcxx/include/module.modulemap.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ module std_private_functional_hash [system] {
13651365
export std_private_type_traits_underlying_type
13661366
export std_private_utility_pair
13671367
}
1368-
module std_private_functional_hash_fwd [system] { header "__fwd/hash.h" }
1368+
module std_private_functional_fwd [system] { header "__fwd/functional.h" }
13691369
module std_private_functional_identity [system] { header "__functional/identity.h" }
13701370
module std_private_functional_invoke [system] {
13711371
header "__functional/invoke.h"

libcxx/include/optional

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ namespace std {
186186
#include <__exception/exception.h>
187187
#include <__functional/hash.h>
188188
#include <__functional/invoke.h>
189-
#include <__functional/reference_wrapper.h>
190189
#include <__functional/unary_function.h>
190+
#include <__fwd/functional.h>
191191
#include <__memory/addressof.h>
192192
#include <__memory/construct_at.h>
193193
#include <__tuple/sfinae_helpers.h>

libcxx/include/type_traits

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ namespace std
418418
*/
419419

420420
#include <__config>
421-
#include <__fwd/hash.h> // This is https://llvm.org/PR56938
421+
#include <__fwd/functional.h> // This is https://llvm.org/PR56938
422422
#include <__type_traits/add_const.h>
423423
#include <__type_traits/add_cv.h>
424424
#include <__type_traits/add_lvalue_reference.h>

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ experimental/utility utility
178178
filesystem compare
179179
filesystem cstddef
180180
filesystem cstdint
181-
filesystem cstring
182181
filesystem ctime
183182
filesystem iomanip
184183
filesystem limits

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ experimental/utility utility
178178
filesystem compare
179179
filesystem cstddef
180180
filesystem cstdint
181-
filesystem cstring
182181
filesystem ctime
183182
filesystem iomanip
184183
filesystem limits

libcxx/utils/generate_iwyu_mapping.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def IWYU_mapping(header: str) -> typing.Optional[typing.List[str]]:
3434
return ["atomic", "mutex", "semaphore", "thread"]
3535
elif header == "__tree":
3636
return ["map", "set"]
37-
elif header == "__fwd/hash.h":
38-
return ["functional"]
3937
elif header == "__fwd/pair.h":
4038
return ["utility"]
4139
elif header == "__fwd/subrange.h":

0 commit comments

Comments
 (0)