Skip to content

Commit

Permalink
[libc++] Rename __fwd/hash.h to __fwd/functional.h and add reference_…
Browse files Browse the repository at this point in the history
…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`.
  • Loading branch information
philnik777 authored Mar 3, 2024
1 parent 0c90e88 commit 33de5a3
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 28 deletions.
2 changes: 1 addition & 1 deletion libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions libcxx/include/__filesystem/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__functional/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__functional/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__functional/identity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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
2 changes: 1 addition & 1 deletion libcxx/include/__thread/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 0 additions & 1 deletion libcxx/include/__thread/support/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 1 addition & 3 deletions libcxx/include/__type_traits/is_reference_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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>
Expand Down
7 changes: 1 addition & 6 deletions libcxx/include/__type_traits/unwrap_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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> {};
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/experimental/propagate_const
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/libcxx.imp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] },
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/module.modulemap.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/optional
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx23.csv
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ experimental/utility utility
filesystem compare
filesystem cstddef
filesystem cstdint
filesystem cstring
filesystem ctime
filesystem iomanip
filesystem limits
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx26.csv
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ experimental/utility utility
filesystem compare
filesystem cstddef
filesystem cstdint
filesystem cstring
filesystem ctime
filesystem iomanip
filesystem limits
Expand Down
2 changes: 0 additions & 2 deletions libcxx/utils/generate_iwyu_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit 33de5a3

Please sign in to comment.