From 66ba7c32add07204dd0b8a7e0c14b44f0d3b850d Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 20 Dec 2022 18:01:34 +0100 Subject: [PATCH] [libc++] Granularize includes in Reviewed By: ldionne, Mordante, #libc Spies: jloser, libcxx-commits Differential Revision: https://reviews.llvm.org/D139189 --- libcxx/include/__concepts/arithmetic.h | 4 +++- libcxx/include/__concepts/assignable.h | 2 +- libcxx/include/__concepts/class_or_enum.h | 5 ++++- libcxx/include/__concepts/common_reference_with.h | 2 +- libcxx/include/__concepts/common_with.h | 5 ++++- libcxx/include/__concepts/constructible.h | 2 +- libcxx/include/__concepts/convertible_to.h | 2 +- libcxx/include/__concepts/derived_from.h | 3 ++- libcxx/include/__concepts/destructible.h | 2 +- libcxx/include/__concepts/different_from.h | 2 +- libcxx/include/__concepts/equality_comparable.h | 2 +- libcxx/include/__concepts/invocable.h | 1 - libcxx/include/__concepts/movable.h | 2 +- libcxx/include/__concepts/predicate.h | 2 +- libcxx/include/__concepts/same_as.h | 2 +- libcxx/include/__concepts/swappable.h | 6 +++++- libcxx/include/__concepts/totally_ordered.h | 3 ++- libcxx/include/__type_traits/is_nothrow_constructible.h | 1 + libcxx/include/__type_traits/is_signed.h | 2 ++ libcxx/include/__type_traits/remove_cvref.h | 1 + libcxx/include/__utility/swap.h | 6 +++++- libcxx/include/concepts | 4 ++++ libcxx/include/module.modulemap.in | 5 ++++- libcxx/include/sstream | 4 ++++ .../range.utility.helpers/different_from.compile.pass.cpp | 6 +++--- 25 files changed, 54 insertions(+), 22 deletions(-) diff --git a/libcxx/include/__concepts/arithmetic.h b/libcxx/include/__concepts/arithmetic.h index d91570f02b8bb..215b52aa02187 100644 --- a/libcxx/include/__concepts/arithmetic.h +++ b/libcxx/include/__concepts/arithmetic.h @@ -10,9 +10,11 @@ #define _LIBCPP___CONCEPTS_ARITHMETIC_H #include <__config> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_signed.h> #include <__type_traits/is_signed_integer.h> #include <__type_traits/is_unsigned_integer.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/assignable.h b/libcxx/include/__concepts/assignable.h index db09e5a0a5d11..91edd400adf6d 100644 --- a/libcxx/include/__concepts/assignable.h +++ b/libcxx/include/__concepts/assignable.h @@ -12,9 +12,9 @@ #include <__concepts/common_reference_with.h> #include <__concepts/same_as.h> #include <__config> +#include <__type_traits/is_reference.h> #include <__type_traits/make_const_lvalue_ref.h> #include <__utility/forward.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/class_or_enum.h b/libcxx/include/__concepts/class_or_enum.h index 6287c5299239e..c4d2f98952c01 100644 --- a/libcxx/include/__concepts/class_or_enum.h +++ b/libcxx/include/__concepts/class_or_enum.h @@ -10,7 +10,10 @@ #define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H #include <__config> -#include +#include <__type_traits/is_class.h> +#include <__type_traits/is_enum.h> +#include <__type_traits/is_union.h> +#include <__type_traits/remove_cvref.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/common_reference_with.h b/libcxx/include/__concepts/common_reference_with.h index cae2f5bccce05..cc92762d31091 100644 --- a/libcxx/include/__concepts/common_reference_with.h +++ b/libcxx/include/__concepts/common_reference_with.h @@ -12,7 +12,7 @@ #include <__concepts/convertible_to.h> #include <__concepts/same_as.h> #include <__config> -#include +#include <__type_traits/common_reference.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/common_with.h b/libcxx/include/__concepts/common_with.h index 1b5f4da4af9a9..9bd8bf1eb59fb 100644 --- a/libcxx/include/__concepts/common_with.h +++ b/libcxx/include/__concepts/common_with.h @@ -12,7 +12,10 @@ #include <__concepts/common_reference_with.h> #include <__concepts/same_as.h> #include <__config> -#include +#include <__type_traits/add_lvalue_reference.h> +#include <__type_traits/common_reference.h> +#include <__type_traits/common_type.h> +#include <__utility/declval.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/constructible.h b/libcxx/include/__concepts/constructible.h index aaf515417e4cf..1d78eb5fd157c 100644 --- a/libcxx/include/__concepts/constructible.h +++ b/libcxx/include/__concepts/constructible.h @@ -12,7 +12,7 @@ #include <__concepts/convertible_to.h> #include <__concepts/destructible.h> #include <__config> -#include +#include <__type_traits/is_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/convertible_to.h b/libcxx/include/__concepts/convertible_to.h index 5d9d437104212..a1c2c3a1fb83b 100644 --- a/libcxx/include/__concepts/convertible_to.h +++ b/libcxx/include/__concepts/convertible_to.h @@ -10,8 +10,8 @@ #define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H #include <__config> +#include <__type_traits/is_convertible.h> #include <__utility/declval.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/derived_from.h b/libcxx/include/__concepts/derived_from.h index 4b2914794735a..0d3462df6a6d7 100644 --- a/libcxx/include/__concepts/derived_from.h +++ b/libcxx/include/__concepts/derived_from.h @@ -10,7 +10,8 @@ #define _LIBCPP___CONCEPTS_DERIVED_FROM_H #include <__config> -#include +#include <__type_traits/is_base_of.h> +#include <__type_traits/is_convertible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/destructible.h b/libcxx/include/__concepts/destructible.h index 90a043d314c23..ad3819d5dcfe4 100644 --- a/libcxx/include/__concepts/destructible.h +++ b/libcxx/include/__concepts/destructible.h @@ -10,7 +10,7 @@ #define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H #include <__config> -#include +#include <__type_traits/is_nothrow_destructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/different_from.h b/libcxx/include/__concepts/different_from.h index 3066372e86839..15fd8f05510b2 100644 --- a/libcxx/include/__concepts/different_from.h +++ b/libcxx/include/__concepts/different_from.h @@ -11,7 +11,7 @@ #include <__concepts/same_as.h> #include <__config> -#include +#include <__type_traits/remove_cvref.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/equality_comparable.h b/libcxx/include/__concepts/equality_comparable.h index c2293d5cd014b..b865141705f1b 100644 --- a/libcxx/include/__concepts/equality_comparable.h +++ b/libcxx/include/__concepts/equality_comparable.h @@ -12,8 +12,8 @@ #include <__concepts/boolean_testable.h> #include <__concepts/common_reference_with.h> #include <__config> +#include <__type_traits/common_reference.h> #include <__type_traits/make_const_lvalue_ref.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/invocable.h b/libcxx/include/__concepts/invocable.h index d90389e97f3bc..ec39b7b817cc7 100644 --- a/libcxx/include/__concepts/invocable.h +++ b/libcxx/include/__concepts/invocable.h @@ -12,7 +12,6 @@ #include <__config> #include <__functional/invoke.h> #include <__utility/forward.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/movable.h b/libcxx/include/__concepts/movable.h index 639219ed6b485..749b78ad10b80 100644 --- a/libcxx/include/__concepts/movable.h +++ b/libcxx/include/__concepts/movable.h @@ -13,7 +13,7 @@ #include <__concepts/constructible.h> #include <__concepts/swappable.h> #include <__config> -#include +#include <__type_traits/is_object.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/predicate.h b/libcxx/include/__concepts/predicate.h index cb239752309fd..7ae97832642d5 100644 --- a/libcxx/include/__concepts/predicate.h +++ b/libcxx/include/__concepts/predicate.h @@ -12,7 +12,7 @@ #include <__concepts/boolean_testable.h> #include <__concepts/invocable.h> #include <__config> -#include +#include <__functional/invoke.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/same_as.h b/libcxx/include/__concepts/same_as.h index 7654906611488..554ebc3b074bd 100644 --- a/libcxx/include/__concepts/same_as.h +++ b/libcxx/include/__concepts/same_as.h @@ -10,7 +10,7 @@ #define _LIBCPP___CONCEPTS_SAME_AS_H #include <__config> -#include +#include <__type_traits/is_same.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/swappable.h b/libcxx/include/__concepts/swappable.h index dbb428364550b..d91a7a1dc3c32 100644 --- a/libcxx/include/__concepts/swappable.h +++ b/libcxx/include/__concepts/swappable.h @@ -14,11 +14,15 @@ #include <__concepts/common_reference_with.h> #include <__concepts/constructible.h> #include <__config> +#include <__type_traits/extent.h> +#include <__type_traits/is_nothrow_move_assignable.h> +#include <__type_traits/is_nothrow_move_constructible.h> +#include <__type_traits/remove_cvref.h> #include <__utility/exchange.h> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/swap.h> -#include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__concepts/totally_ordered.h b/libcxx/include/__concepts/totally_ordered.h index 25347790de07e..f12d26b10827f 100644 --- a/libcxx/include/__concepts/totally_ordered.h +++ b/libcxx/include/__concepts/totally_ordered.h @@ -12,7 +12,8 @@ #include <__concepts/boolean_testable.h> #include <__concepts/equality_comparable.h> #include <__config> -#include +#include <__type_traits/common_reference.h> +#include <__type_traits/make_const_lvalue_ref.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_nothrow_constructible.h b/libcxx/include/__type_traits/is_nothrow_constructible.h index 6272298889be8..4caad81ad11ca 100644 --- a/libcxx/include/__type_traits/is_nothrow_constructible.h +++ b/libcxx/include/__type_traits/is_nothrow_constructible.h @@ -14,6 +14,7 @@ #include <__type_traits/is_constructible.h> #include <__type_traits/is_reference.h> #include <__utility/declval.h> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_signed.h b/libcxx/include/__type_traits/is_signed.h index e9722c9b21926..aa42a4e420da6 100644 --- a/libcxx/include/__type_traits/is_signed.h +++ b/libcxx/include/__type_traits/is_signed.h @@ -11,6 +11,8 @@ #include <__config> #include <__type_traits/integral_constant.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/remove_cvref.h b/libcxx/include/__type_traits/remove_cvref.h index e96cc6523b71d..faada28ae8b95 100644 --- a/libcxx/include/__type_traits/remove_cvref.h +++ b/libcxx/include/__type_traits/remove_cvref.h @@ -12,6 +12,7 @@ #include <__config> #include <__type_traits/is_same.h> #include <__type_traits/remove_cv.h> +#include <__type_traits/remove_cvref.h> #include <__type_traits/remove_reference.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/libcxx/include/__utility/swap.h b/libcxx/include/__utility/swap.h index 545614aecad5d..0843b35a8b586 100644 --- a/libcxx/include/__utility/swap.h +++ b/libcxx/include/__utility/swap.h @@ -10,10 +10,14 @@ #define _LIBCPP___UTILITY_SWAP_H #include <__config> +#include <__type_traits/is_move_assignable.h> +#include <__type_traits/is_move_constructible.h> +#include <__type_traits/is_nothrow_move_assignable.h> +#include <__type_traits/is_nothrow_move_constructible.h> +#include <__type_traits/is_swappable.h> #include <__utility/declval.h> #include <__utility/move.h> #include -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/concepts b/libcxx/include/concepts index 301256ca7ef7e..196fa2e0ea706 100644 --- a/libcxx/include/concepts +++ b/libcxx/include/concepts @@ -155,6 +155,10 @@ namespace std { #include <__config> #include +#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in index 4c3a09d1a5f00..2a2064c74aea3 100644 --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -1436,7 +1436,10 @@ module std [system] { module is_reference { private header "__type_traits/is_reference.h" } module is_reference_wrapper { private header "__type_traits/is_reference_wrapper.h" } module is_referenceable { private header "__type_traits/is_referenceable.h" } - module is_same { private header "__type_traits/is_same.h" } + module is_same { + private header "__type_traits/is_same.h" + export type_traits.integral_constant + } module is_scalar { private header "__type_traits/is_scalar.h" } module is_scoped_enum { private header "__type_traits/is_scoped_enum.h" } module is_signed { private header "__type_traits/is_signed.h" } diff --git a/libcxx/include/sstream b/libcxx/include/sstream index 91d1a07353aa4..20f9c60d4c240 100644 --- a/libcxx/include/sstream +++ b/libcxx/include/sstream @@ -876,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +#endif + #endif // _LIBCPP_SSTREAM diff --git a/libcxx/test/libcxx/ranges/range.utility.helpers/different_from.compile.pass.cpp b/libcxx/test/libcxx/ranges/range.utility.helpers/different_from.compile.pass.cpp index 2d594f44b9833..f19c1ba4dda71 100644 --- a/libcxx/test/libcxx/ranges/range.utility.helpers/different_from.compile.pass.cpp +++ b/libcxx/test/libcxx/ranges/range.utility.helpers/different_from.compile.pass.cpp @@ -10,9 +10,10 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 -#include +// Check that different_from.h is self-contained +// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header -#include "test_macros.h" +#include <__concepts/different_from.h> static_assert(std::__different_from); static_assert(std::__different_from); @@ -25,4 +26,3 @@ static_assert(!std::__different_from); static_assert(!std::__different_from); static_assert(!std::__different_from); static_assert(std::__different_from); -