Skip to content

Commit

Permalink
[libc++] Granularize <type_traits> includes in <utility>
Browse files Browse the repository at this point in the history
Reviewed By: Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D140426
  • Loading branch information
philnik777 committed Dec 22, 2022
1 parent 2c5ffa1 commit 947dfc9
Show file tree
Hide file tree
Showing 37 changed files with 74 additions and 44 deletions.
3 changes: 2 additions & 1 deletion libcxx/include/__compare/common_comparison_category.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

#include <__compare/ordering.h>
#include <__config>
#include <type_traits>
#include <__type_traits/is_same.h>
#include <cstddef>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__compare/ordering.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#define _LIBCPP___COMPARE_ORDERING_H

#include <__config>
#include <type_traits>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_same.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__compare/three_way_comparable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <__concepts/same_as.h>
#include <__concepts/totally_ordered.h>
#include <__config>
#include <__type_traits/common_reference.h>
#include <__type_traits/make_const_lvalue_ref.h>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__functional/unwrap_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H

#include <__config>
#include <__type_traits/decay.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__utility/as_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define _LIBCPP___UTILITY_AS_CONST_H

#include <__config>
#include <__type_traits/add_const.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__utility/auto_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define _LIBCPP___UTILITY_AUTO_CAST_H

#include <__config>
#include <type_traits>
#include <__type_traits/decay.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
6 changes: 5 additions & 1 deletion libcxx/include/__utility/cmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
#define _LIBCPP___UTILITY_CMP_H

#include <__config>
#include <__type_traits/disjunction.h>
#include <__type_traits/is_integral.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_signed.h>
#include <__type_traits/make_unsigned.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <limits>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__utility/exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
#define _LIBCPP___UTILITY_EXCHANGE_H

#include <__config>
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_move_constructible.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__utility/in_place.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#define _LIBCPP___UTILITY_IN_PLACE_H

#include <__config>
#include <type_traits>
#include <__type_traits/remove_cvref.h>
#include <cstddef>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__utility/integer_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H

#include <__config>
#include <type_traits>
#include <__type_traits/is_integral.h>
#include <cstddef>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
5 changes: 4 additions & 1 deletion libcxx/include/__utility/move.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#define _LIBCPP___UTILITY_MOVE_H

#include <__config>
#include <type_traits>
#include <__type_traits/conditional.h>
#include <__type_traits/is_copy_constructible.h>
#include <__type_traits/is_nothrow_move_constructible.h>
#include <__type_traits/remove_reference.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
19 changes: 18 additions & 1 deletion libcxx/include/__utility/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,29 @@
#include <__tuple_dir/tuple_element.h>
#include <__tuple_dir/tuple_indices.h>
#include <__tuple_dir/tuple_size.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/common_type.h>
#include <__type_traits/conditional.h>
#include <__type_traits/is_assignable.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_convertible.h>
#include <__type_traits/is_copy_assignable.h>
#include <__type_traits/is_default_constructible.h>
#include <__type_traits/is_implicitly_default_constructible.h>
#include <__type_traits/is_move_assignable.h>
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_nothrow_copy_assignable.h>
#include <__type_traits/is_nothrow_copy_constructible.h>
#include <__type_traits/is_nothrow_default_constructible.h>
#include <__type_traits/is_nothrow_move_assignable.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/nat.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/piecewise_construct.h>
#include <cstddef>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
3 changes: 0 additions & 3 deletions libcxx/include/__utility/rel_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#define _LIBCPP___UTILITY_REL_OPS_H

#include <__config>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__utility/to_underlying.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define _LIBCPP___UTILITY_TO_UNDERLYING_H

#include <__config>
#include <type_traits>
#include <__type_traits/underlying_type.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
8 changes: 7 additions & 1 deletion libcxx/include/limits
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ template<> class numeric_limits<cv long double>;

#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <type_traits>
#include <__type_traits/is_arithmetic.h>
#include <__type_traits/is_signed.h>
#include <__type_traits/remove_cv.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -821,4 +823,8 @@ _LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <type_traits>
#endif

#endif // _LIBCPP_LIMITS
5 changes: 4 additions & 1 deletion libcxx/include/module.modulemap.in
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,10 @@ module std [system] {
module is_abstract { private header "__type_traits/is_abstract.h" }
module is_aggregate { private header "__type_traits/is_aggregate.h" }
module is_allocator { private header "__type_traits/is_allocator.h" }
module is_arithmetic { private header "__type_traits/is_arithmetic.h" }
module is_arithmetic {
private header "__type_traits/is_arithmetic.h"
export integral_constant
}
module is_array { private header "__type_traits/is_array.h" }
module is_assignable { private header "__type_traits/is_assignable.h" }
module is_base_of { private header "__type_traits/is_base_of.h" }
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/utility
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ template <class T>
#include <__utility/to_underlying.h>
#include <__utility/transaction.h>
#include <__utility/unreachable.h>
#include <type_traits>
#include <version>

// standard-mandated includes
Expand All @@ -276,6 +275,7 @@ template <class T>

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <iosfwd>
# include <type_traits>
#endif

#endif // _LIBCPP_UTILITY
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx03.csv
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ memory_resource mutex
memory_resource new
memory_resource stdexcept
memory_resource tuple
memory_resource type_traits
memory_resource version
mutex atomic
mutex concepts
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx11.csv
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ memory_resource mutex
memory_resource new
memory_resource stdexcept
memory_resource tuple
memory_resource type_traits
memory_resource version
mutex atomic
mutex concepts
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx14.csv
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ memory_resource mutex
memory_resource new
memory_resource stdexcept
memory_resource tuple
memory_resource type_traits
memory_resource version
mutex atomic
mutex concepts
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx17.csv
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ memory_resource mutex
memory_resource new
memory_resource stdexcept
memory_resource tuple
memory_resource type_traits
memory_resource version
mutex atomic
mutex concepts
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx20.csv
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ memory_resource mutex
memory_resource new
memory_resource stdexcept
memory_resource tuple
memory_resource type_traits
memory_resource version
mutex atomic
mutex concepts
Expand Down
6 changes: 0 additions & 6 deletions libcxx/test/libcxx/transitive_includes/cxx2b.csv
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ complex stdexcept
complex type_traits
complex version
concepts cstddef
concepts type_traits
concepts version
condition_variable atomic
condition_variable cstddef
Expand Down Expand Up @@ -197,7 +196,6 @@ experimental/functional vector
experimental/iterator cstddef
experimental/iterator iosfwd
experimental/iterator iterator
experimental/iterator type_traits
experimental/list experimental/memory_resource
experimental/list list
experimental/map experimental/memory_resource
Expand Down Expand Up @@ -381,7 +379,6 @@ iterator version
latch atomic
latch limits
latch version
limits type_traits
limits version
list compare
list cstddef
Expand Down Expand Up @@ -445,7 +442,6 @@ memory_resource mutex
memory_resource new
memory_resource stdexcept
memory_resource tuple
memory_resource type_traits
memory_resource version
mutex atomic
mutex cstddef
Expand Down Expand Up @@ -598,7 +594,6 @@ sstream cstddef
sstream istream
sstream ostream
sstream string
sstream type_traits
sstream version
stack compare
stack cstddef
Expand Down Expand Up @@ -717,7 +712,6 @@ utility cstddef
utility cstdlib
utility initializer_list
utility limits
utility type_traits
utility version
valarray cmath
valarray cstddef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// template<class U, class V> pair(U&& x, V&& y);

#include <type_traits>
#include <utility>

#include "test_macros.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

// pair(const T1& x, const T2& y);

#include <type_traits>
#include <utility>

#include "test_macros.h"


struct ExplicitT {
constexpr explicit ExplicitT(int x) : value(x) {}
constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// template <class U, class V> EXPLICIT constexpr pair(const pair<U, V>& p);

#include <type_traits>
#include <utility>

#include "test_macros.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cassert>
#include <concepts>
#include <expected>
#include <type_traits>
#include <utility>

// test noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// void
// return_temporary_buffer(T* p);

#include <memory>
#include <cassert>
#include <cstdint>
#include <memory>
#include <utility>

#include "test_macros.h"
Expand Down
5 changes: 2 additions & 3 deletions libcxx/test/std/utilities/utility/as_const/as_const.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
// template <class T> constexpr add_const<T>& as_const(T& t) noexcept; // C++17
// template <class T> add_const<T>& as_const(const T&&) = delete; // C++17

#include <utility>
#include <cassert>

#include "test_macros.h"
#include <type_traits>
#include <utility>

struct S {int i;};
bool operator==(const S& x, const S& y) { return x.i == y.i; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// >::type
// move_if_noexcept(T& x);

#include <type_traits>
#include <utility>

#include "test_macros.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

// tuple_element<I, pair<T1, T2> >::type

#include <type_traits>
#include <utility>

#include "test_macros.h"

template <class T1, class T2>
void test()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

// pair(pair&&) = default;

#include <utility>
#include <memory>
#include <cassert>
#include <memory>
#include <type_traits>
#include <utility>

#include "test_macros.h"

Expand Down
Loading

0 comments on commit 947dfc9

Please sign in to comment.