[libcxx-commits] [libcxx] [libc++] Include the rest of the detail headers by version in the umbrella headers (PR #96032)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 19 00:25:47 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/96032

This is a follow-up to #83740.


>From f6a3cf338f0d16eee128146407f8c2c6213fbee8 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 19 Jun 2024 09:23:31 +0200
Subject: [PATCH] [libc++] Include the rest of the detail headers by version in
 the umbrella headers

---
 libcxx/include/atomic                         |  5 +-
 libcxx/include/expected                       | 18 +++-
 libcxx/include/filesystem                     | 36 +++----
 libcxx/include/format                         | 81 ++++++++++------
 libcxx/include/functional                     | 47 ++++++---
 libcxx/include/iterator                       | 56 ++++++-----
 libcxx/include/mdspan                         | 27 ++++--
 libcxx/include/memory                         | 28 ++++--
 libcxx/include/memory_resource                | 26 +++--
 libcxx/include/module.modulemap               | 16 +++-
 libcxx/include/numeric                        | 29 ++++--
 libcxx/include/ostream                        |  9 +-
 libcxx/include/random                         |  3 -
 libcxx/include/ranges                         | 95 +++++++++++--------
 libcxx/include/stop_token                     |  9 +-
 libcxx/include/type_traits                    | 63 ++++++------
 libcxx/include/utility                        | 38 +++++---
 .../sequences/deque/abi.compile.pass.cpp      |  1 +
 .../sequences/list/abi.compile.pass.cpp       |  1 +
 .../bounded_iter/arithmetic.pass.cpp          |  2 +-
 .../bounded_iter/comparison.pass.cpp          |  2 +-
 .../bounded_iter/dereference.pass.cpp         |  2 +-
 .../bounded_iter/pointer_traits.pass.cpp      |  3 +-
 .../bounded_iter/types.compile.pass.cpp       |  1 +
 .../libcxx/memory/allocation_guard.pass.cpp   |  2 +-
 .../compressed_pair/compressed_pair.pass.cpp  |  2 +-
 .../numerics/clamp_to_integral.pass.cpp       |  2 +-
 .../as-lvalue.lifetimebound.verify.cpp        |  2 +-
 .../range.adaptor.helpers/as-lvalue.pass.cpp  |  1 +
 .../test/libcxx/transitive_includes/cxx03.csv |  1 +
 .../test/libcxx/transitive_includes/cxx11.csv |  1 +
 .../test/libcxx/transitive_includes/cxx14.csv |  1 +
 .../test/libcxx/transitive_includes/cxx17.csv |  1 +
 .../test/libcxx/transitive_includes/cxx20.csv |  2 +
 .../test/libcxx/transitive_includes/cxx23.csv |  1 -
 .../test/libcxx/transitive_includes/cxx26.csv |  1 -
 .../type_traits/is_callable.compile.pass.cpp  |  2 +-
 ..._implicitly_default_constructible.pass.cpp |  3 +-
 .../is_specialization.compile.pass.cpp        |  5 +-
 .../type_traits/is_specialization.verify.cpp  |  3 +-
 .../exception_guard.no_exceptions.pass.cpp    |  1 +
 .../libcxx/utilities/exception_guard.pass.cpp |  1 +
 .../func.bind.partial/compose.pass.cpp        |  2 +-
 .../make.heap/ranges_make_heap.pass.cpp       |  1 +
 .../pop.heap/ranges_pop_heap.pass.cpp         |  1 +
 .../push.heap/ranges_push_heap.pass.cpp       |  1 +
 .../range.owning.view/begin_end.pass.cpp      |  1 +
 .../iterator/plus_eq.pass.cpp                 |  3 +-
 libcxx/test/support/test_iterators.h          |  1 +
 49 files changed, 406 insertions(+), 234 deletions(-)

diff --git a/libcxx/include/atomic b/libcxx/include/atomic
index 80a0f9ee373e9..0d13619d6ce45 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -599,7 +599,6 @@ template <class T>
 #include <__atomic/atomic_flag.h>
 #include <__atomic/atomic_init.h>
 #include <__atomic/atomic_lock_free.h>
-#include <__atomic/atomic_ref.h>
 #include <__atomic/atomic_sync.h>
 #include <__atomic/check_memory_order.h>
 #include <__atomic/contention_t.h>
@@ -610,6 +609,10 @@ template <class T>
 #include <__atomic/memory_order.h>
 #include <version>
 
+#if _LIBCPP_STD_VER >= 20
+#  include <__atomic/atomic_ref.h>
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
diff --git a/libcxx/include/expected b/libcxx/include/expected
index f455ab7d5d61c..6a2f12f2bf3b5 100644
--- a/libcxx/include/expected
+++ b/libcxx/include/expected
@@ -39,14 +39,24 @@ namespace std {
 */
 
 #include <__config>
-#include <__expected/bad_expected_access.h>
-#include <__expected/expected.h>
-#include <__expected/unexpect.h>
-#include <__expected/unexpected.h>
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__expected/bad_expected_access.h>
+#  include <__expected/expected.h>
+#  include <__expected/unexpect.h>
+#  include <__expected/unexpected.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+#  include <cstddef>
+#  include <initializer_list>
+#  include <new>
+#endif
+
 #endif // _LIBCPP_EXPECTED
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index eff7dff4a4551..6ea04df0a089b 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -534,22 +534,26 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
 */
 
 #include <__config>
-#include <__filesystem/copy_options.h>
-#include <__filesystem/directory_entry.h>
-#include <__filesystem/directory_iterator.h>
-#include <__filesystem/directory_options.h>
-#include <__filesystem/file_status.h>
-#include <__filesystem/file_time_type.h>
-#include <__filesystem/file_type.h>
-#include <__filesystem/filesystem_error.h>
-#include <__filesystem/operations.h>
-#include <__filesystem/path.h>
-#include <__filesystem/path_iterator.h>
-#include <__filesystem/perm_options.h>
-#include <__filesystem/perms.h>
-#include <__filesystem/recursive_directory_iterator.h>
-#include <__filesystem/space_info.h>
-#include <__filesystem/u8path.h>
+
+#if _LIBCPP_STD_VER >= 17
+#  include <__filesystem/copy_options.h>
+#  include <__filesystem/directory_entry.h>
+#  include <__filesystem/directory_iterator.h>
+#  include <__filesystem/directory_options.h>
+#  include <__filesystem/file_status.h>
+#  include <__filesystem/file_time_type.h>
+#  include <__filesystem/file_type.h>
+#  include <__filesystem/filesystem_error.h>
+#  include <__filesystem/operations.h>
+#  include <__filesystem/path.h>
+#  include <__filesystem/path_iterator.h>
+#  include <__filesystem/perm_options.h>
+#  include <__filesystem/perms.h>
+#  include <__filesystem/recursive_directory_iterator.h>
+#  include <__filesystem/space_info.h>
+#  include <__filesystem/u8path.h>
+#endif
+
 #include <version>
 
 // standard-mandated includes
diff --git a/libcxx/include/format b/libcxx/include/format
index 07c2ba083199e..c3f2b45f0f730 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -189,40 +189,65 @@ namespace std {
 */
 
 #include <__config>
-#include <__format/buffer.h>
-#include <__format/concepts.h>
-#include <__format/container_adaptor.h>
-#include <__format/enable_insertable.h>
-#include <__format/escaped_output_table.h>
-#include <__format/extended_grapheme_cluster_table.h>
-#include <__format/format_arg.h>
-#include <__format/format_arg_store.h>
-#include <__format/format_args.h>
-#include <__format/format_context.h>
-#include <__format/format_error.h>
-#include <__format/format_functions.h>
-#include <__format/format_parse_context.h>
-#include <__format/format_string.h>
-#include <__format/format_to_n_result.h>
-#include <__format/formatter.h>
-#include <__format/formatter_bool.h>
-#include <__format/formatter_char.h>
-#include <__format/formatter_floating_point.h>
-#include <__format/formatter_integer.h>
-#include <__format/formatter_pointer.h>
-#include <__format/formatter_string.h>
-#include <__format/formatter_tuple.h>
-#include <__format/parser_std_format_spec.h>
-#include <__format/range_default_formatter.h>
-#include <__format/range_formatter.h>
-#include <__format/unicode.h>
-#include <__fwd/format.h>
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__format/buffer.h>
+#  include <__format/concepts.h>
+#  include <__format/container_adaptor.h>
+#  include <__format/enable_insertable.h>
+#  include <__format/escaped_output_table.h>
+#  include <__format/extended_grapheme_cluster_table.h>
+#  include <__format/format_arg.h>
+#  include <__format/format_arg_store.h>
+#  include <__format/format_args.h>
+#  include <__format/format_context.h>
+#  include <__format/format_error.h>
+#  include <__format/format_functions.h>
+#  include <__format/format_parse_context.h>
+#  include <__format/format_string.h>
+#  include <__format/format_to_n_result.h>
+#  include <__format/formatter.h>
+#  include <__format/formatter_bool.h>
+#  include <__format/formatter_char.h>
+#  include <__format/formatter_floating_point.h>
+#  include <__format/formatter_integer.h>
+#  include <__format/formatter_pointer.h>
+#  include <__format/formatter_string.h>
+#  include <__format/formatter_tuple.h>
+#  include <__format/parser_std_format_spec.h>
+#  include <__format/range_default_formatter.h>
+#  include <__format/range_formatter.h>
+#  include <__format/unicode.h>
+#  include <__fwd/format.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+#  include <array>
+#  include <cctype>
+#  include <cerrno>
+#  include <clocale>
+#  include <cmath>
+#  include <cstddef>
+#  include <cstdint>
+#  include <cstdlib>
+#  include <cstring>
+#  include <cwchar>
+#  include <initializer_list>
+#  include <limits>
+#  include <new>
+#  include <optional>
+#  include <stdexcept>
+#  include <string>
+#  include <string_view>
+#  include <tuple>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <locale>
 #  include <queue>
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 27cf21e1a4c8b..3d39f654ddb08 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -527,41 +527,60 @@ POLICY:  For non-variadic implementations, the number of arguments is limited
 
 */
 
-#include <__algorithm/search.h>
-#include <__compare/compare_three_way.h>
 #include <__config>
+
 #include <__functional/binary_function.h>
 #include <__functional/binary_negate.h>
 #include <__functional/bind.h>
-#include <__functional/bind_back.h>
-#include <__functional/bind_front.h>
 #include <__functional/binder1st.h>
 #include <__functional/binder2nd.h>
-#include <__functional/boyer_moore_searcher.h>
-#include <__functional/compose.h>
-#include <__functional/default_searcher.h>
-#include <__functional/function.h>
 #include <__functional/hash.h>
-#include <__functional/identity.h>
-#include <__functional/invoke.h>
 #include <__functional/mem_fn.h> // TODO: deprecate
 #include <__functional/mem_fun_ref.h>
-#include <__functional/not_fn.h>
 #include <__functional/operations.h>
 #include <__functional/pointer_to_binary_function.h>
 #include <__functional/pointer_to_unary_function.h>
-#include <__functional/ranges_operations.h>
 #include <__functional/reference_wrapper.h>
 #include <__functional/unary_function.h>
 #include <__functional/unary_negate.h>
-#include <__type_traits/unwrap_ref.h>
-#include <__utility/forward.h>
+
+#ifndef _LIBCPP_CXX03_LANG
+#  include <__functional/function.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+#  include <__functional/boyer_moore_searcher.h>
+#  include <__functional/default_searcher.h>
+#  include <__functional/invoke.h>
+#  include <__functional/not_fn.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__functional/bind_back.h>
+#  include <__functional/bind_front.h>
+#  include <__functional/identity.h>
+#  include <__functional/ranges_operations.h>
+#  include <__type_traits/unwrap_ref.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG)
+#  include <limits>
+#  include <new>
+#endif
+
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
+#  include <array>
+#  include <initializer_list>
+#  include <unordered_map>
+#  include <vector>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <atomic>
 #  include <concepts>
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index 1b9e7eaf0c1e8..fca75f0a19ed1 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -683,43 +683,49 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
 #include <__iterator/access.h>
 #include <__iterator/advance.h>
 #include <__iterator/back_insert_iterator.h>
-#include <__iterator/bounded_iter.h>
-#include <__iterator/common_iterator.h>
-#include <__iterator/concepts.h>
-#include <__iterator/counted_iterator.h>
-#include <__iterator/data.h>
-#include <__iterator/default_sentinel.h>
 #include <__iterator/distance.h>
-#include <__iterator/empty.h>
-#include <__iterator/erase_if_container.h>
 #include <__iterator/front_insert_iterator.h>
-#include <__iterator/incrementable_traits.h>
-#include <__iterator/indirectly_comparable.h>
 #include <__iterator/insert_iterator.h>
 #include <__iterator/istream_iterator.h>
 #include <__iterator/istreambuf_iterator.h>
-#include <__iterator/iter_move.h>
-#include <__iterator/iter_swap.h>
 #include <__iterator/iterator.h>
 #include <__iterator/iterator_traits.h>
-#include <__iterator/mergeable.h>
 #include <__iterator/move_iterator.h>
-#include <__iterator/move_sentinel.h>
 #include <__iterator/next.h>
 #include <__iterator/ostream_iterator.h>
 #include <__iterator/ostreambuf_iterator.h>
-#include <__iterator/permutable.h>
 #include <__iterator/prev.h>
-#include <__iterator/projected.h>
-#include <__iterator/readable_traits.h>
-#include <__iterator/reverse_access.h>
 #include <__iterator/reverse_iterator.h>
-#include <__iterator/size.h>
-#include <__iterator/sortable.h>
-#include <__iterator/unreachable_sentinel.h>
 #include <__iterator/wrap_iter.h>
-#include <__memory/addressof.h>
-#include <__memory/pointer_traits.h>
+
+#if _LIBCPP_STD_VER >= 14
+#  include <__iterator/reverse_access.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+#  include <__iterator/data.h>
+#  include <__iterator/empty.h>
+#  include <__iterator/size.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__iterator/common_iterator.h>
+#  include <__iterator/concepts.h>
+#  include <__iterator/counted_iterator.h>
+#  include <__iterator/default_sentinel.h>
+#  include <__iterator/incrementable_traits.h>
+#  include <__iterator/indirectly_comparable.h>
+#  include <__iterator/iter_move.h>
+#  include <__iterator/iter_swap.h>
+#  include <__iterator/mergeable.h>
+#  include <__iterator/move_sentinel.h>
+#  include <__iterator/permutable.h>
+#  include <__iterator/projected.h>
+#  include <__iterator/readable_traits.h>
+#  include <__iterator/sortable.h>
+#  include <__iterator/unreachable_sentinel.h>
+#endif
+
 #include <version>
 
 // standard-mandated includes
@@ -732,6 +738,10 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+#  include <variant>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <cstdlib>
 #  include <exception>
diff --git a/libcxx/include/mdspan b/libcxx/include/mdspan
index 8d443f4acd1dd..813af6839dbd0 100644
--- a/libcxx/include/mdspan
+++ b/libcxx/include/mdspan
@@ -405,17 +405,30 @@ namespace std {
 #define _LIBCPP_MDSPAN
 
 #include <__config>
-#include <__fwd/mdspan.h>
-#include <__mdspan/default_accessor.h>
-#include <__mdspan/extents.h>
-#include <__mdspan/layout_left.h>
-#include <__mdspan/layout_right.h>
-#include <__mdspan/layout_stride.h>
-#include <__mdspan/mdspan.h>
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__fwd/mdspan.h>
+#  include <__mdspan/default_accessor.h>
+#  include <__mdspan/extents.h>
+#  include <__mdspan/layout_left.h>
+#  include <__mdspan/layout_right.h>
+#  include <__mdspan/layout_stride.h>
+#  include <__mdspan/mdspan.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+#  include <array>
+#  include <cinttypes>
+#  include <concepts>
+#  include <cstddef>
+#  include <limits>
+#  include <span>
+#endif
+
 #endif // _LIBCPP_MDSPAN
diff --git a/libcxx/include/memory b/libcxx/include/memory
index a8c0264eb9eb7..d52ee7b4c8eee 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -920,30 +920,38 @@ template<size_t N, class T>
 #include <__config>
 #include <__memory/addressof.h>
 #include <__memory/align.h>
-#include <__memory/allocate_at_least.h>
-#include <__memory/allocation_guard.h>
 #include <__memory/allocator.h>
 #include <__memory/allocator_arg_t.h>
 #include <__memory/allocator_traits.h>
-#include <__memory/assume_aligned.h>
 #include <__memory/auto_ptr.h>
-#include <__memory/compressed_pair.h>
-#include <__memory/concepts.h>
-#include <__memory/construct_at.h>
 #include <__memory/pointer_traits.h>
-#include <__memory/ranges_construct_at.h>
-#include <__memory/ranges_uninitialized_algorithms.h>
 #include <__memory/raw_storage_iterator.h>
 #include <__memory/shared_ptr.h>
 #include <__memory/temporary_buffer.h>
 #include <__memory/uninitialized_algorithms.h>
 #include <__memory/unique_ptr.h>
 #include <__memory/uses_allocator.h>
-#include <__memory/uses_allocator_construction.h>
-#include <version>
 
 // standard-mandated includes
 
+#if _LIBCPP_STD_VER >= 17
+#  include <__memory/construct_at.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__memory/assume_aligned.h>
+#  include <__memory/concepts.h>
+#  include <__memory/ranges_construct_at.h>
+#  include <__memory/ranges_uninitialized_algorithms.h>
+#  include <__memory/uses_allocator_construction.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__memory/allocate_at_least.h>
+#endif
+
+#include <version>
+
 // [memory.syn]
 #include <compare>
 
diff --git a/libcxx/include/memory_resource b/libcxx/include/memory_resource
index e9c87777e8f75..67411054820a1 100644
--- a/libcxx/include/memory_resource
+++ b/libcxx/include/memory_resource
@@ -50,18 +50,32 @@ namespace std::pmr {
  */
 
 #include <__config>
-#include <__memory_resource/memory_resource.h>
-#include <__memory_resource/monotonic_buffer_resource.h>
-#include <__memory_resource/polymorphic_allocator.h>
-#include <__memory_resource/pool_options.h>
-#include <__memory_resource/synchronized_pool_resource.h>
-#include <__memory_resource/unsynchronized_pool_resource.h>
+
+#if _LIBCPP_STD_VER >= 17
+#  include <__memory_resource/memory_resource.h>
+#  include <__memory_resource/monotonic_buffer_resource.h>
+#  include <__memory_resource/polymorphic_allocator.h>
+#  include <__memory_resource/pool_options.h>
+#  include <__memory_resource/synchronized_pool_resource.h>
+#  include <__memory_resource/unsynchronized_pool_resource.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
+#  include <cstddef>
+#  include <cstdint>
+#  include <limits>
+#  include <mutex>
+#  include <new>
+#  include <stdexcept>
+#  include <tuple>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <stdexcept>
 #endif
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 9ffccf66ff094..30e732f1d8e01 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1081,7 +1081,10 @@ module std_private_charconv_tables                  [system] { header "__charcon
 module std_private_charconv_to_chars                [system] { header "__charconv/to_chars.h" }
 module std_private_charconv_to_chars_base_10        [system] { header "__charconv/to_chars_base_10.h" }
 module std_private_charconv_to_chars_floating_point [system] { header "__charconv/to_chars_floating_point.h" }
-module std_private_charconv_to_chars_integral       [system] { header "__charconv/to_chars_integral.h" }
+module std_private_charconv_to_chars_integral       [system] {
+  header "__charconv/to_chars_integral.h"
+  export std_private_charconv_traits
+}
 module std_private_charconv_to_chars_result         [system] {
   header "__charconv/to_chars_result.h"
   export *
@@ -1130,6 +1133,7 @@ module std_private_chrono_steady_clock           [system] {
 }
 module std_private_chrono_time_zone              [system] {
   header "__chrono/time_zone.h"
+  export std_private_memory_unique_ptr
 }
 module std_private_chrono_time_zone_link         [system] {
   header "__chrono/time_zone_link.h"
@@ -1923,7 +1927,10 @@ module std_private_type_traits_is_array                                  [system
 module std_private_type_traits_is_assignable                             [system] { header "__type_traits/is_assignable.h" }
 module std_private_type_traits_is_base_of                                [system] { header "__type_traits/is_base_of.h" }
 module std_private_type_traits_is_bounded_array                          [system] { header "__type_traits/is_bounded_array.h" }
-module std_private_type_traits_is_callable                               [system] { header "__type_traits/is_callable.h" }
+module std_private_type_traits_is_callable                               [system] {
+  header "__type_traits/is_callable.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_type_traits_is_char_like_type                         [system] { header "__type_traits/is_char_like_type.h" }
 module std_private_type_traits_is_class                                  [system] { header "__type_traits/is_class.h" }
 module std_private_type_traits_is_compound                               [system] { header "__type_traits/is_compound.h" }
@@ -1958,7 +1965,10 @@ module std_private_type_traits_is_final                                  [system
 module std_private_type_traits_is_floating_point                         [system] { header "__type_traits/is_floating_point.h" }
 module std_private_type_traits_is_function                               [system] { header "__type_traits/is_function.h" }
 module std_private_type_traits_is_fundamental                            [system] { header "__type_traits/is_fundamental.h" }
-module std_private_type_traits_is_implicitly_default_constructible       [system] { header "__type_traits/is_implicitly_default_constructible.h" }
+module std_private_type_traits_is_implicitly_default_constructible       [system] {
+  header "__type_traits/is_implicitly_default_constructible.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_type_traits_is_integral                               [system] { header "__type_traits/is_integral.h" }
 module std_private_type_traits_is_literal_type                           [system] { header "__type_traits/is_literal_type.h" }
 module std_private_type_traits_is_member_function_pointer                [system] { header "__type_traits/is_member_function_pointer.h" }
diff --git a/libcxx/include/numeric b/libcxx/include/numeric
index 9fb5e9fb1da70..6b92ce3a07123 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -157,31 +157,40 @@ constexpr T saturate_cast(U x) noexcept;                    // freestanding, Sin
 */
 
 #include <__config>
-#include <version>
 
 #include <__numeric/accumulate.h>
 #include <__numeric/adjacent_difference.h>
-#include <__numeric/exclusive_scan.h>
-#include <__numeric/gcd_lcm.h>
-#include <__numeric/inclusive_scan.h>
 #include <__numeric/inner_product.h>
 #include <__numeric/iota.h>
-#include <__numeric/midpoint.h>
 #include <__numeric/partial_sum.h>
-#include <__numeric/reduce.h>
-#include <__numeric/saturation_arithmetic.h>
-#include <__numeric/transform_exclusive_scan.h>
-#include <__numeric/transform_inclusive_scan.h>
-#include <__numeric/transform_reduce.h>
 
 #if _LIBCPP_STD_VER >= 17
+#  include <__numeric/exclusive_scan.h>
+#  include <__numeric/gcd_lcm.h>
+#  include <__numeric/inclusive_scan.h>
 #  include <__numeric/pstl.h>
+#  include <__numeric/reduce.h>
+#  include <__numeric/transform_exclusive_scan.h>
+#  include <__numeric/transform_inclusive_scan.h>
+#  include <__numeric/transform_reduce.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__numeric/midpoint.h>
+#  include <__numeric/saturation_arithmetic.h>
 #endif
 
+#include <version>
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
+#  include <initializer_list>
+#  include <limits>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <climits>
 #  include <cmath>
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index f75110e7d73f7..359d3c0e19c4c 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -173,8 +173,13 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
 */
 
 #include <__config>
+
 #include <__ostream/basic_ostream.h>
-#include <__ostream/print.h>
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__ostream/print.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -186,8 +191,10 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
 #  include <concepts>
 #  include <cstdio>
 #  include <cstdlib>
+#  include <format>
 #  include <iosfwd>
 #  include <iterator>
+#  include <print>
 #  include <stdexcept>
 #  include <type_traits>
 #endif
diff --git a/libcxx/include/random b/libcxx/include/random
index 9edd6c4608ec2..6cc3760c20e16 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -1682,7 +1682,6 @@ class piecewise_linear_distribution
 #include <__random/binomial_distribution.h>
 #include <__random/cauchy_distribution.h>
 #include <__random/chi_squared_distribution.h>
-#include <__random/clamp_to_integral.h>
 #include <__random/default_random_engine.h>
 #include <__random/discard_block_engine.h>
 #include <__random/discrete_distribution.h>
@@ -1694,10 +1693,8 @@ class piecewise_linear_distribution
 #include <__random/geometric_distribution.h>
 #include <__random/independent_bits_engine.h>
 #include <__random/is_seed_sequence.h>
-#include <__random/is_valid.h>
 #include <__random/knuth_b.h>
 #include <__random/linear_congruential_engine.h>
-#include <__random/log2.h>
 #include <__random/lognormal_distribution.h>
 #include <__random/mersenne_twister_engine.h>
 #include <__random/negative_binomial_distribution.h>
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index 07a525ed8641f..fa35874265de6 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -381,49 +381,56 @@ namespace std {
 */
 
 #include <__config>
-#include <__ranges/access.h>
-#include <__ranges/all.h>
-#include <__ranges/as_rvalue_view.h>
-#include <__ranges/chunk_by_view.h>
-#include <__ranges/common_view.h>
-#include <__ranges/concepts.h>
-#include <__ranges/counted.h>
-#include <__ranges/dangling.h>
-#include <__ranges/data.h>
-#include <__ranges/drop_view.h>
-#include <__ranges/drop_while_view.h>
-#include <__ranges/elements_view.h>
-#include <__ranges/empty.h>
-#include <__ranges/empty_view.h>
-#include <__ranges/enable_borrowed_range.h>
-#include <__ranges/enable_view.h>
-#include <__ranges/filter_view.h>
-#include <__ranges/from_range.h>
-#include <__ranges/iota_view.h>
-#include <__ranges/join_view.h>
-#include <__ranges/lazy_split_view.h>
-#include <__ranges/rbegin.h>
-#include <__ranges/ref_view.h>
-#include <__ranges/rend.h>
-#include <__ranges/repeat_view.h>
-#include <__ranges/reverse_view.h>
-#include <__ranges/single_view.h>
-#include <__ranges/size.h>
-#include <__ranges/split_view.h>
-#include <__ranges/subrange.h>
-#include <__ranges/take_view.h>
-#include <__ranges/take_while_view.h>
-#include <__ranges/to.h>
-#include <__ranges/transform_view.h>
-#include <__ranges/view_interface.h>
-#include <__ranges/views.h>
-#include <__ranges/zip_view.h>
-#include <version>
 
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#  include <__ranges/istream_view.h>
+#if _LIBCPP_STD_VER >= 20
+#  include <__ranges/access.h>
+#  include <__ranges/all.h>
+#  include <__ranges/common_view.h>
+#  include <__ranges/concepts.h>
+#  include <__ranges/counted.h>
+#  include <__ranges/dangling.h>
+#  include <__ranges/data.h>
+#  include <__ranges/drop_view.h>
+#  include <__ranges/drop_while_view.h>
+#  include <__ranges/elements_view.h>
+#  include <__ranges/empty.h>
+#  include <__ranges/empty_view.h>
+#  include <__ranges/enable_borrowed_range.h>
+#  include <__ranges/enable_view.h>
+#  include <__ranges/filter_view.h>
+#  include <__ranges/iota_view.h>
+#  include <__ranges/join_view.h>
+#  include <__ranges/lazy_split_view.h>
+#  include <__ranges/rbegin.h>
+#  include <__ranges/ref_view.h>
+#  include <__ranges/rend.h>
+#  include <__ranges/reverse_view.h>
+#  include <__ranges/single_view.h>
+#  include <__ranges/size.h>
+#  include <__ranges/split_view.h>
+#  include <__ranges/subrange.h>
+#  include <__ranges/take_view.h>
+#  include <__ranges/take_while_view.h>
+#  include <__ranges/transform_view.h>
+#  include <__ranges/view_interface.h>
+#  include <__ranges/views.h>
+
+#  if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#    include <__ranges/istream_view.h>
+#  endif
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__ranges/as_rvalue_view.h>
+#  include <__ranges/chunk_by_view.h>
+#  include <__ranges/from_range.h>
+#  include <__ranges/repeat_view.h>
+#  include <__ranges/to.h>
+#  include <__ranges/zip_view.h>
 #endif
 
+#include <version>
+
 // standard-mandated includes
 
 // [ranges.syn]
@@ -439,6 +446,14 @@ namespace std {
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
+#  include <cstddef>
+#  include <limits>
+#  include <optional>
+#  include <span>
+#  include <tuple>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <cstdlib>
 #  include <iosfwd>
diff --git a/libcxx/include/stop_token b/libcxx/include/stop_token
index fee195f9d63d4..39981052ccedd 100644
--- a/libcxx/include/stop_token
+++ b/libcxx/include/stop_token
@@ -37,9 +37,12 @@ namespace std {
 #  error "<stop_token> is not supported since libc++ has been configured without support for threads."
 #endif
 
-#include <__stop_token/stop_callback.h>
-#include <__stop_token/stop_source.h>
-#include <__stop_token/stop_token.h>
+#if _LIBCPP_STD_VER >= 20
+#  include <__stop_token/stop_callback.h>
+#  include <__stop_token/stop_source.h>
+#  include <__stop_token/stop_token.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index aee9fcf4137f3..08badb6aa06e8 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -428,43 +428,29 @@ namespace std
 #include <__type_traits/aligned_storage.h>
 #include <__type_traits/aligned_union.h>
 #include <__type_traits/alignment_of.h>
-#include <__type_traits/can_extract_key.h>
-#include <__type_traits/common_reference.h>
 #include <__type_traits/common_type.h>
 #include <__type_traits/conditional.h>
-#include <__type_traits/conjunction.h>
 #include <__type_traits/decay.h>
-#include <__type_traits/dependent_type.h>
-#include <__type_traits/disjunction.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/extent.h>
-#include <__type_traits/has_unique_object_representation.h>
 #include <__type_traits/has_virtual_destructor.h>
 #include <__type_traits/integral_constant.h>
-#include <__type_traits/invoke.h>
 #include <__type_traits/is_abstract.h>
-#include <__type_traits/is_aggregate.h>
 #include <__type_traits/is_arithmetic.h>
 #include <__type_traits/is_array.h>
 #include <__type_traits/is_assignable.h>
 #include <__type_traits/is_base_of.h>
-#include <__type_traits/is_bounded_array.h>
-#include <__type_traits/is_callable.h>
-#include <__type_traits/is_char_like_type.h>
 #include <__type_traits/is_class.h>
 #include <__type_traits/is_compound.h>
 #include <__type_traits/is_const.h>
-#include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_convertible.h>
 #include <__type_traits/is_destructible.h>
 #include <__type_traits/is_empty.h>
 #include <__type_traits/is_enum.h>
-#include <__type_traits/is_final.h>
 #include <__type_traits/is_floating_point.h>
 #include <__type_traits/is_function.h>
 #include <__type_traits/is_fundamental.h>
-#include <__type_traits/is_implicitly_default_constructible.h>
 #include <__type_traits/is_integral.h>
 #include <__type_traits/is_literal_type.h>
 #include <__type_traits/is_member_function_pointer.h>
@@ -472,55 +458,68 @@ namespace std
 #include <__type_traits/is_member_pointer.h>
 #include <__type_traits/is_nothrow_assignable.h>
 #include <__type_traits/is_nothrow_constructible.h>
-#include <__type_traits/is_nothrow_convertible.h>
 #include <__type_traits/is_nothrow_destructible.h>
-#include <__type_traits/is_null_pointer.h>
 #include <__type_traits/is_object.h>
 #include <__type_traits/is_pod.h>
 #include <__type_traits/is_pointer.h>
 #include <__type_traits/is_polymorphic.h>
 #include <__type_traits/is_reference.h>
-#include <__type_traits/is_reference_wrapper.h>
-#include <__type_traits/is_referenceable.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/is_scalar.h>
-#include <__type_traits/is_scoped_enum.h>
 #include <__type_traits/is_signed.h>
-#include <__type_traits/is_specialization.h>
 #include <__type_traits/is_standard_layout.h>
-#include <__type_traits/is_swappable.h>
 #include <__type_traits/is_trivial.h>
 #include <__type_traits/is_trivially_assignable.h>
 #include <__type_traits/is_trivially_constructible.h>
 #include <__type_traits/is_trivially_copyable.h>
 #include <__type_traits/is_trivially_destructible.h>
-#include <__type_traits/is_unbounded_array.h>
 #include <__type_traits/is_union.h>
 #include <__type_traits/is_unsigned.h>
 #include <__type_traits/is_void.h>
 #include <__type_traits/is_volatile.h>
-#include <__type_traits/make_const_lvalue_ref.h>
 #include <__type_traits/make_signed.h>
 #include <__type_traits/make_unsigned.h>
-#include <__type_traits/maybe_const.h>
-#include <__type_traits/negation.h>
 #include <__type_traits/rank.h>
 #include <__type_traits/remove_all_extents.h>
 #include <__type_traits/remove_const.h>
-#include <__type_traits/remove_const_ref.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_extent.h>
 #include <__type_traits/remove_pointer.h>
 #include <__type_traits/remove_reference.h>
 #include <__type_traits/remove_volatile.h>
 #include <__type_traits/result_of.h>
-#include <__type_traits/type_identity.h>
 #include <__type_traits/underlying_type.h>
-#include <__type_traits/unwrap_ref.h>
-#include <__type_traits/void_t.h>
-#include <__utility/declval.h>
-#include <cstddef>
-#include <cstdint>
+
+#if _LIBCPP_STD_VER >= 14
+#  include <__type_traits/is_final.h>
+#  include <__type_traits/is_null_pointer.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+#  include <__type_traits/conjunction.h>
+#  include <__type_traits/disjunction.h>
+#  include <__type_traits/has_unique_object_representation.h>
+#  include <__type_traits/invoke.h>
+#  include <__type_traits/is_aggregate.h>
+#  include <__type_traits/is_swappable.h>
+#  include <__type_traits/negation.h>
+#  include <__type_traits/void_t.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__type_traits/common_reference.h>
+#  include <__type_traits/is_bounded_array.h>
+#  include <__type_traits/is_constant_evaluated.h>
+#  include <__type_traits/is_nothrow_convertible.h>
+#  include <__type_traits/is_unbounded_array.h>
+#  include <__type_traits/type_identity.h>
+#  include <__type_traits/unwrap_ref.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__type_traits/is_scoped_enum.h>
+#endif
+
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 90713da621c5d..6a0f0c33b61c9 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -247,25 +247,35 @@ template <class T>
 */
 
 #include <__config>
-#include <__utility/as_const.h>
-#include <__utility/as_lvalue.h>
-#include <__utility/auto_cast.h>
-#include <__utility/cmp.h>
+
 #include <__utility/declval.h>
-#include <__utility/exception_guard.h>
-#include <__utility/exchange.h>
 #include <__utility/forward.h>
-#include <__utility/forward_like.h>
-#include <__utility/in_place.h>
-#include <__utility/integer_sequence.h>
 #include <__utility/move.h>
 #include <__utility/pair.h>
 #include <__utility/piecewise_construct.h>
-#include <__utility/priority_tag.h>
 #include <__utility/rel_ops.h>
 #include <__utility/swap.h>
-#include <__utility/to_underlying.h>
-#include <__utility/unreachable.h>
+
+#if _LIBCPP_STD_VER >= 14
+#  include <__utility/exchange.h>
+#  include <__utility/integer_sequence.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+#  include <__utility/as_const.h>
+#  include <__utility/in_place.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+#  include <__utility/cmp.h>
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__utility/forward_like.h>
+#  include <__utility/to_underlying.h>
+#  include <__utility/unreachable.h>
+#endif
+
 #include <version>
 
 // standard-mandated includes
@@ -282,6 +292,10 @@ template <class T>
 #  pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+#  include <limits>
+#endif
+
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <cstdlib>
 #  include <iosfwd>
diff --git a/libcxx/test/libcxx/containers/sequences/deque/abi.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/abi.compile.pass.cpp
index 9910befb0349e..7d2dd218f967b 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/abi.compile.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/abi.compile.pass.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <cstdint>
 #include <deque>
 
 #include "min_allocator.h"
diff --git a/libcxx/test/libcxx/containers/sequences/list/abi.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/abi.compile.pass.cpp
index 8ace45d661df6..a16ae1d527921 100644
--- a/libcxx/test/libcxx/containers/sequences/list/abi.compile.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/abi.compile.pass.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <cstdint>
 #include <list>
 
 #include "min_allocator.h"
diff --git a/libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp
index feaef53ae09d5..45d0cc3b95f90 100644
--- a/libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp
+++ b/libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp
@@ -11,8 +11,8 @@
 //
 // Arithmetic operators
 
+#include <__iterator/bounded_iter.h>
 #include <cstddef>
-#include <iterator>
 
 #include "test_iterators.h"
 #include "test_macros.h"
diff --git a/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp
index f4b0da9511eaf..9c5df5da55b9c 100644
--- a/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp
+++ b/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp
@@ -11,7 +11,7 @@
 //
 // Comparison operators
 
-#include <iterator>
+#include <__iterator/bounded_iter.h>
 
 #include "test_iterators.h"
 #include "test_macros.h"
diff --git a/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
index bf723f14e80a9..7e3a59a49ffd4 100644
--- a/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
+++ b/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
@@ -16,7 +16,7 @@
 // UNSUPPORTED: libcpp-hardening-mode=none
 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
 
-#include <iterator>
+#include <__iterator/bounded_iter.h>
 
 #include "check_assertion.h"
 #include "test_iterators.h"
diff --git a/libcxx/test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp
index 6ae0928b7e528..bfd779d644f51 100644
--- a/libcxx/test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp
+++ b/libcxx/test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp
@@ -11,9 +11,10 @@
 //
 // std::pointer_traits specialization
 
+#include <__iterator/bounded_iter.h>
 #include <cassert>
 #include <cstddef>
-#include <iterator>
+#include <memory>
 #include <type_traits>
 
 #include "test_iterators.h"
diff --git a/libcxx/test/libcxx/iterators/bounded_iter/types.compile.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/types.compile.pass.cpp
index db95513055f81..56ded9ae5ed21 100644
--- a/libcxx/test/libcxx/iterators/bounded_iter/types.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/bounded_iter/types.compile.pass.cpp
@@ -11,6 +11,7 @@
 //
 // Nested types
 
+#include <__iterator/bounded_iter.h>
 #include <cstddef>
 #include <iterator>
 #include <type_traits>
diff --git a/libcxx/test/libcxx/memory/allocation_guard.pass.cpp b/libcxx/test/libcxx/memory/allocation_guard.pass.cpp
index 4b2f7abe9159b..493ebf044187c 100644
--- a/libcxx/test/libcxx/memory/allocation_guard.pass.cpp
+++ b/libcxx/test/libcxx/memory/allocation_guard.pass.cpp
@@ -15,8 +15,8 @@
 // template<class _Alloc>
 // struct __allocation_guard;
 
+#include <__memory/allocation_guard.h>
 #include <cassert>
-#include <memory>
 #include <type_traits>
 #include <utility>
 
diff --git a/libcxx/test/libcxx/memory/compressed_pair/compressed_pair.pass.cpp b/libcxx/test/libcxx/memory/compressed_pair/compressed_pair.pass.cpp
index 8bc890a208d0c..4258089813e0d 100644
--- a/libcxx/test/libcxx/memory/compressed_pair/compressed_pair.pass.cpp
+++ b/libcxx/test/libcxx/memory/compressed_pair/compressed_pair.pass.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <__memory/compressed_pair.h>
 #include <assert.h>
-#include <memory>
 #include <new>
 
 #include "test_macros.h"
diff --git a/libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp b/libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp
index a826555d48dda..aed78f9cddf84 100644
--- a/libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp
+++ b/libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp
@@ -12,10 +12,10 @@
 // closest representable value for the specified integer type, or
 // numeric_limits<IntT>::max()/min() if the value isn't representable.
 
+#include <__random/clamp_to_integral.h>
 #include <cassert>
 #include <cmath>
 #include <limits>
-#include <random> // for __clamp_to_integral
 
 template <class IntT>
 void test() {
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.lifetimebound.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.lifetimebound.verify.cpp
index 7046936b1b7a7..b60f172363350 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.lifetimebound.verify.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.lifetimebound.verify.cpp
@@ -11,7 +11,7 @@
 // template<class T>
 // constexpr T& as-lvalue(T&& t) { // exposition only
 
-#include <utility>
+#include <__utility/as_lvalue.h>
 
 void test() {
   // Check prvalue
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.pass.cpp
index 721279fcd586b..8e47a507f2f8a 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.pass.cpp
@@ -11,6 +11,7 @@
 // template<class T>
 // constexpr T& as-lvalue(T&& t) { // exposition only
 
+#include <__utility/as_lvalue.h>
 #include <type_traits>
 #include <utility>
 
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index c720a0c9a05ec..a401c37574dad 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -961,6 +961,7 @@ unordered_set type_traits
 unordered_set version
 utility compare
 utility cstddef
+utility cstdint
 utility cstdlib
 utility initializer_list
 utility iosfwd
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index b00436a1be7f7..17d1038c5039d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -968,6 +968,7 @@ unordered_set type_traits
 unordered_set version
 utility compare
 utility cstddef
+utility cstdint
 utility cstdlib
 utility initializer_list
 utility iosfwd
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 4b8c12929de0d..7f36e8901d534 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -971,6 +971,7 @@ unordered_set type_traits
 unordered_set version
 utility compare
 utility cstddef
+utility cstdint
 utility cstdlib
 utility initializer_list
 utility iosfwd
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index a51a7e2de1d38..b6d58db62a4d2 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -972,6 +972,7 @@ unordered_set type_traits
 unordered_set version
 utility compare
 utility cstddef
+utility cstdint
 utility cstdlib
 utility initializer_list
 utility iosfwd
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 5280d75cbf2e1..9609985eafe20 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -682,6 +682,7 @@ ranges optional
 ranges span
 ranges tuple
 ranges type_traits
+ranges variant
 ranges version
 ratio climits
 ratio cstdint
@@ -978,6 +979,7 @@ unordered_set type_traits
 unordered_set version
 utility compare
 utility cstddef
+utility cstdint
 utility cstdlib
 utility initializer_list
 utility iosfwd
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index bfb8b5def6224..7d71e647f2a8f 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -457,7 +457,6 @@ ranges cwchar
 ranges initializer_list
 ranges iterator
 ranges limits
-ranges new
 ranges optional
 ranges span
 ranges tuple
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index bfb8b5def6224..7d71e647f2a8f 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -457,7 +457,6 @@ ranges cwchar
 ranges initializer_list
 ranges iterator
 ranges limits
-ranges new
 ranges optional
 ranges span
 ranges tuple
diff --git a/libcxx/test/libcxx/type_traits/is_callable.compile.pass.cpp b/libcxx/test/libcxx/type_traits/is_callable.compile.pass.cpp
index f7f76bbe9bef0..d7bd701aa706a 100644
--- a/libcxx/test/libcxx/type_traits/is_callable.compile.pass.cpp
+++ b/libcxx/test/libcxx/type_traits/is_callable.compile.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <type_traits>
+#include <__type_traits/is_callable.h>
 
 struct Functor {
   void operator()();
diff --git a/libcxx/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp b/libcxx/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp
index e1951cbc8446f..ff0ab6f68df67 100644
--- a/libcxx/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp
+++ b/libcxx/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp
@@ -12,8 +12,7 @@
 
 // __is_implicitly_default_constructible<Tp>
 
-#include <type_traits>
-
+#include <__type_traits/is_implicitly_default_constructible.h>
 
 struct ExplicitlyDefaultConstructible1 {
     explicit ExplicitlyDefaultConstructible1() = default;
diff --git a/libcxx/test/libcxx/type_traits/is_specialization.compile.pass.cpp b/libcxx/test/libcxx/type_traits/is_specialization.compile.pass.cpp
index 134e5f5d186a6..73dfc773aa774 100644
--- a/libcxx/test/libcxx/type_traits/is_specialization.compile.pass.cpp
+++ b/libcxx/test/libcxx/type_traits/is_specialization.compile.pass.cpp
@@ -14,10 +14,7 @@
 // Note instantiation for certain type combinations are ill-formed. These are
 // tested in is_specialization.verify.cpp.
 
-#include <type_traits>
-
-#include <array>
-#include <concepts>
+#include <__type_traits/is_specialization.h>
 #include <string_view>
 #include <tuple>
 #include <utility>
diff --git a/libcxx/test/libcxx/type_traits/is_specialization.verify.cpp b/libcxx/test/libcxx/type_traits/is_specialization.verify.cpp
index 2fd1176417538..a798647d56ee1 100644
--- a/libcxx/test/libcxx/type_traits/is_specialization.verify.cpp
+++ b/libcxx/test/libcxx/type_traits/is_specialization.verify.cpp
@@ -13,8 +13,7 @@
 //
 // Tests the ill-formed instantiations.
 
-#include <type_traits>
-
+#include <__type_traits/is_specialization.h>
 #include <array>
 #include <utility>
 
diff --git a/libcxx/test/libcxx/utilities/exception_guard.no_exceptions.pass.cpp b/libcxx/test/libcxx/utilities/exception_guard.no_exceptions.pass.cpp
index 7f2bcbca11ca0..60cf4f7814597 100644
--- a/libcxx/test/libcxx/utilities/exception_guard.no_exceptions.pass.cpp
+++ b/libcxx/test/libcxx/utilities/exception_guard.no_exceptions.pass.cpp
@@ -10,6 +10,7 @@
 
 // ADDITIONAL_COMPILE_FLAGS: -fno-exceptions
 
+#include <__utility/exception_guard.h>
 #include <utility>
 
 int main(int, char**) {
diff --git a/libcxx/test/libcxx/utilities/exception_guard.pass.cpp b/libcxx/test/libcxx/utilities/exception_guard.pass.cpp
index 71e60fc94542d..0728959c7277b 100644
--- a/libcxx/test/libcxx/utilities/exception_guard.pass.cpp
+++ b/libcxx/test/libcxx/utilities/exception_guard.pass.cpp
@@ -10,6 +10,7 @@
 
 // UNSUPPORTED: no-exceptions
 
+#include <__utility/exception_guard.h>
 #include <cassert>
 #include <type_traits>
 #include <utility>
diff --git a/libcxx/test/libcxx/utilities/function.objects/func.bind.partial/compose.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/func.bind.partial/compose.pass.cpp
index a39352e539135..7e597081cfaad 100644
--- a/libcxx/test/libcxx/utilities/function.objects/func.bind.partial/compose.pass.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/func.bind.partial/compose.pass.cpp
@@ -11,7 +11,7 @@
 // template <class F1, class F2>
 // constexpr unspecified __compose(F1&&, F2&&);
 
-#include <functional>
+#include <__functional/compose.h>
 #include <cassert>
 #include <tuple>
 #include <utility>
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
index 8d9df94eee5a6..f69351209e4f1 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
@@ -25,6 +25,7 @@
 #include <array>
 #include <concepts>
 #include <functional>
+#include <memory>
 #include <ranges>
 
 #include "almost_satisfies_types.h"
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
index 2f13bdc76f793..9efe2513271ed 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
@@ -25,6 +25,7 @@
 #include <array>
 #include <concepts>
 #include <functional>
+#include <memory>
 #include <ranges>
 
 #include "almost_satisfies_types.h"
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
index 6f8a1a20c965c..571da879ed3f5 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
@@ -25,6 +25,7 @@
 #include <array>
 #include <concepts>
 #include <functional>
+#include <memory>
 #include <ranges>
 
 #include "almost_satisfies_types.h"
diff --git a/libcxx/test/std/ranges/range.adaptors/range.all/range.owning.view/begin_end.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.all/range.owning.view/begin_end.pass.cpp
index 155f88010309c..2dddd84d8796e 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.all/range.owning.view/begin_end.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.all/range.owning.view/begin_end.pass.cpp
@@ -19,6 +19,7 @@
 #include <array>
 #include <cassert>
 #include <concepts>
+#include <memory>
 
 #include "test_iterators.h"
 #include "test_macros.h"
diff --git a/libcxx/test/std/ranges/range.factories/range.repeat.view/iterator/plus_eq.pass.cpp b/libcxx/test/std/ranges/range.factories/range.repeat.view/iterator/plus_eq.pass.cpp
index a4696d73839b6..549ebffe5c97e 100644
--- a/libcxx/test/std/ranges/range.factories/range.repeat.view/iterator/plus_eq.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.repeat.view/iterator/plus_eq.pass.cpp
@@ -10,9 +10,10 @@
 
 // constexpr iterator& operator+=(difference_type n);
 
-#include <ranges>
 #include <cassert>
 #include <concepts>
+#include <memory>
+#include <ranges>
 
 constexpr bool test() {
   std::ranges::repeat_view<int> v(10);
diff --git a/libcxx/test/support/test_iterators.h b/libcxx/test/support/test_iterators.h
index aa819ecd4733b..bb3ba2182f557 100644
--- a/libcxx/test/support/test_iterators.h
+++ b/libcxx/test/support/test_iterators.h
@@ -11,6 +11,7 @@
 
 #include <cassert>
 #include <concepts>
+#include <cstdint>
 #include <iterator>
 #include <ranges>
 #include <stdexcept>



More information about the libcxx-commits mailing list