From b8c345c854f17896543565ac40f37ca4992b718b Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 5 Sep 2024 08:28:33 -0400 Subject: [PATCH] [libc++][modules] Modularize (#107254) Many headers include `` just for size_t, and pulling in additional content (e.g. the traits used for std::byte) is unnecessary. To solve this problem, this patch splits up `` into subcomponents so that headers can include only the parts that they actually require. This has the added benefit of making the modules build a lot stricter with respect to IWYU, and also providing a canonical location where we define `std::size_t` and friends (which were previously defined in multiple headers like `` and ``). After this patch, there's still many places in the codebase where we include `` when `<__cstddef/size_t.h>` would be sufficient. This patch focuses on removing `` includes from __type_traits to make these headers non-circular with ``. Additional refactorings can be tackled separately. --- libcxx/include/CMakeLists.txt | 5 ++ libcxx/include/__algorithm/ranges_minmax.h | 1 + libcxx/include/__atomic/atomic.h | 2 + libcxx/include/__charconv/to_chars_integral.h | 1 + libcxx/include/__cstddef/byte.h | 84 +++++++++++++++++++ libcxx/include/__cstddef/max_align_t.h | 27 ++++++ libcxx/include/__cstddef/nullptr_t.h | 25 ++++++ libcxx/include/__cstddef/ptrdiff_t.h | 25 ++++++ libcxx/include/__cstddef/size_t.h | 25 ++++++ libcxx/include/__exception/nested_exception.h | 2 + libcxx/include/__fwd/array.h | 3 +- libcxx/include/__fwd/complex.h | 2 +- libcxx/include/__fwd/pair.h | 2 +- libcxx/include/__fwd/span.h | 2 +- libcxx/include/__fwd/subrange.h | 2 +- libcxx/include/__fwd/tuple.h | 2 +- libcxx/include/__iterator/concepts.h | 1 + libcxx/include/__iterator/iterator_traits.h | 2 + libcxx/include/__iterator/wrap_iter.h | 1 + libcxx/include/__mdspan/layout_stride.h | 1 + libcxx/include/__memory/pointer_traits.h | 1 + libcxx/include/__memory/shared_ptr.h | 2 + libcxx/include/__memory/unique_ptr.h | 1 + libcxx/include/__memory/uses_allocator.h | 1 + .../__random/mersenne_twister_engine.h | 1 + libcxx/include/__random/seed_seq.h | 2 + .../__random/subtract_with_carry_engine.h | 1 + libcxx/include/__ranges/subrange.h | 1 + .../include/__string/constexpr_c_functions.h | 2 + libcxx/include/__tuple/tuple_size.h | 2 + .../include/__type_traits/aligned_storage.h | 2 +- libcxx/include/__type_traits/aligned_union.h | 2 +- libcxx/include/__type_traits/alignment_of.h | 2 +- libcxx/include/__type_traits/extent.h | 2 +- libcxx/include/__type_traits/is_allocator.h | 2 +- libcxx/include/__type_traits/is_array.h | 2 +- .../include/__type_traits/is_bounded_array.h | 2 +- .../__type_traits/is_nothrow_destructible.h | 2 +- .../include/__type_traits/is_null_pointer.h | 2 +- libcxx/include/__type_traits/is_swappable.h | 2 +- libcxx/include/__type_traits/rank.h | 2 +- .../__type_traits/remove_all_extents.h | 2 +- libcxx/include/__type_traits/remove_extent.h | 2 +- libcxx/include/__type_traits/type_list.h | 2 +- libcxx/include/__utility/in_place.h | 1 + libcxx/include/__utility/pair.h | 1 + libcxx/include/__utility/swap.h | 1 + libcxx/include/any | 1 + libcxx/include/cstddef | 83 ++---------------- libcxx/include/cstdio | 2 +- libcxx/include/cstdlib | 2 +- libcxx/include/cstring | 2 +- libcxx/include/ctime | 2 +- libcxx/include/cuchar | 2 +- libcxx/include/cwchar | 2 +- .../include/experimental/__simd/reference.h | 1 + libcxx/include/experimental/__simd/scalar.h | 1 + libcxx/include/experimental/__simd/simd.h | 1 + .../include/experimental/__simd/simd_mask.h | 1 + libcxx/include/experimental/__simd/vec_ext.h | 1 + libcxx/include/module.modulemap | 31 +++++-- libcxx/include/typeinfo | 1 + libcxx/include/unordered_map | 2 + libcxx/include/unordered_set | 2 + .../test/libcxx/transitive_includes/cxx03.csv | 2 - .../test/libcxx/transitive_includes/cxx11.csv | 2 - .../test/libcxx/transitive_includes/cxx14.csv | 2 - .../test/libcxx/transitive_includes/cxx17.csv | 2 - .../test/libcxx/transitive_includes/cxx20.csv | 2 - .../test/libcxx/transitive_includes/cxx23.csv | 2 - .../test/libcxx/transitive_includes/cxx26.csv | 2 - .../bit/bit.pow.two/bit_ceil.pass.cpp | 1 + .../bit/bit.pow.two/bit_floor.pass.cpp | 1 + .../bit/bit.pow.two/bit_width.pass.cpp | 1 + .../bit/bit.pow.two/has_single_bit.pass.cpp | 1 + .../bit/bitops.count/countl_one.pass.cpp | 1 + .../bit/bitops.count/countl_zero.pass.cpp | 1 + .../bit/bitops.count/countr_one.pass.cpp | 1 + .../bit/bitops.count/countr_zero.pass.cpp | 1 + .../bit/bitops.count/popcount.pass.cpp | 1 + .../std/numerics/bit/bitops.rot/rotl.pass.cpp | 1 + .../std/numerics/bit/bitops.rot/rotr.pass.cpp | 1 + .../header_exportable_declarations.cpp | 4 +- libcxx/utils/libcxx/test/modules.py | 4 + 84 files changed, 306 insertions(+), 124 deletions(-) create mode 100644 libcxx/include/__cstddef/byte.h create mode 100644 libcxx/include/__cstddef/max_align_t.h create mode 100644 libcxx/include/__cstddef/nullptr_t.h create mode 100644 libcxx/include/__cstddef/ptrdiff_t.h create mode 100644 libcxx/include/__cstddef/size_t.h diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 210beaf5a336422..0f43916dae4384a 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -324,6 +324,11 @@ set(files __coroutine/coroutine_traits.h __coroutine/noop_coroutine_handle.h __coroutine/trivial_awaitables.h + __cstddef/byte.h + __cstddef/max_align_t.h + __cstddef/nullptr_t.h + __cstddef/ptrdiff_t.h + __cstddef/size_t.h __debug_utils/randomize_range.h __debug_utils/sanitizers.h __debug_utils/strict_weak_ordering_check.h diff --git a/libcxx/include/__algorithm/ranges_minmax.h b/libcxx/include/__algorithm/ranges_minmax.h index 1b43b1e19cdec97..5f2e5cb2a1eeab7 100644 --- a/libcxx/include/__algorithm/ranges_minmax.h +++ b/libcxx/include/__algorithm/ranges_minmax.h @@ -24,6 +24,7 @@ #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__type_traits/desugars_to.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_reference.h> #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/remove_cvref.h> diff --git a/libcxx/include/__atomic/atomic.h b/libcxx/include/__atomic/atomic.h index bcea21f5ce2e177..af6d12b5e4ce913 100644 --- a/libcxx/include/__atomic/atomic.h +++ b/libcxx/include/__atomic/atomic.h @@ -16,8 +16,10 @@ #include <__config> #include <__functional/operations.h> #include <__memory/addressof.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_floating_point.h> #include <__type_traits/is_function.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_const.h> #include <__type_traits/remove_pointer.h> diff --git a/libcxx/include/__charconv/to_chars_integral.h b/libcxx/include/__charconv/to_chars_integral.h index 0369f4dfb9bda6b..ccb5856df17993f 100644 --- a/libcxx/include/__charconv/to_chars_integral.h +++ b/libcxx/include/__charconv/to_chars_integral.h @@ -21,6 +21,7 @@ #include <__system_error/errc.h> #include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/make_32_64_or_128_bit.h> #include <__type_traits/make_unsigned.h> diff --git a/libcxx/include/__cstddef/byte.h b/libcxx/include/__cstddef/byte.h new file mode 100644 index 000000000000000..b8cfe5e8d1c7ef6 --- /dev/null +++ b/libcxx/include/__cstddef/byte.h @@ -0,0 +1,84 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_BYTE_H +#define _LIBCPP___CSTDDEF_BYTE_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 17 +namespace std { // purposefully not versioned + +enum class byte : unsigned char {}; + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { + return static_cast( + static_cast(static_cast(__lhs) | static_cast(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs | __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { + return static_cast( + static_cast(static_cast(__lhs) & static_cast(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs & __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { + return static_cast( + static_cast(static_cast(__lhs) ^ static_cast(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs ^ __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { + return static_cast(static_cast(~static_cast(__b))); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { + return __lhs = __lhs << __shift; +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { + return static_cast(static_cast(static_cast(__lhs) << __shift)); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { + return __lhs = __lhs >> __shift; +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { + return static_cast(static_cast(static_cast(__lhs) >> __shift)); +} + +template ::value, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { + return static_cast<_Integer>(__b); +} + +} // namespace std +#endif // _LIBCPP_STD_VER >= 17 + +#endif // _LIBCPP___CSTDDEF_BYTE_H diff --git a/libcxx/include/__cstddef/max_align_t.h b/libcxx/include/__cstddef/max_align_t.h new file mode 100644 index 000000000000000..7c09c7e7f301726 --- /dev/null +++ b/libcxx/include/__cstddef/max_align_t.h @@ -0,0 +1,27 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_MAX_ALIGN_T_H +#define _LIBCPP___CSTDDEF_MAX_ALIGN_T_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_CXX03_LANG) +using ::max_align_t _LIBCPP_USING_IF_EXISTS; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H diff --git a/libcxx/include/__cstddef/nullptr_t.h b/libcxx/include/__cstddef/nullptr_t.h new file mode 100644 index 000000000000000..de3f7d4ab5fa751 --- /dev/null +++ b/libcxx/include/__cstddef/nullptr_t.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_NULLPTR_T_H +#define _LIBCPP___CSTDDEF_NULLPTR_T_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ::nullptr_t; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_NULLPTR_T_H diff --git a/libcxx/include/__cstddef/ptrdiff_t.h b/libcxx/include/__cstddef/ptrdiff_t.h new file mode 100644 index 000000000000000..f8b5cdaaff01c9f --- /dev/null +++ b/libcxx/include/__cstddef/ptrdiff_t.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_PTRDIFF_T_H +#define _LIBCPP___CSTDDEF_PTRDIFF_T_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_PTRDIFF_T_H diff --git a/libcxx/include/__cstddef/size_t.h b/libcxx/include/__cstddef/size_t.h new file mode 100644 index 000000000000000..91abbf013189539 --- /dev/null +++ b/libcxx/include/__cstddef/size_t.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_SIZE_T_H +#define _LIBCPP___CSTDDEF_SIZE_T_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ::size_t _LIBCPP_USING_IF_EXISTS; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_SIZE_T_H diff --git a/libcxx/include/__exception/nested_exception.h b/libcxx/include/__exception/nested_exception.h index feb489f87f62f54..4c7970d167ffa50 100644 --- a/libcxx/include/__exception/nested_exception.h +++ b/libcxx/include/__exception/nested_exception.h @@ -13,6 +13,8 @@ #include <__exception/exception_ptr.h> #include <__memory/addressof.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_base_of.h> #include <__type_traits/is_class.h> #include <__type_traits/is_constructible.h> diff --git a/libcxx/include/__fwd/array.h b/libcxx/include/__fwd/array.h index 6c6461e7276040a..794779ae46ab748 100644 --- a/libcxx/include/__fwd/array.h +++ b/libcxx/include/__fwd/array.h @@ -10,7 +10,8 @@ #define _LIBCPP___FWD_ARRAY_H #include <__config> -#include +#include <__cstddef/size_t.h> +#include <__type_traits/integral_constant.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__fwd/complex.h b/libcxx/include/__fwd/complex.h index 22c78c5cc3c77a0..092d2e10b12b5b4 100644 --- a/libcxx/include/__fwd/complex.h +++ b/libcxx/include/__fwd/complex.h @@ -10,7 +10,7 @@ #define _LIBCPP___FWD_COMPLEX_H #include <__config> -#include +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__fwd/pair.h b/libcxx/include/__fwd/pair.h index af32628fe1e0d03..b8ba2b7e9232412 100644 --- a/libcxx/include/__fwd/pair.h +++ b/libcxx/include/__fwd/pair.h @@ -10,8 +10,8 @@ #define _LIBCPP___FWD_PAIR_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/tuple.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__fwd/span.h b/libcxx/include/__fwd/span.h index 8dafa742c19df5a..5d473ee51c6b740 100644 --- a/libcxx/include/__fwd/span.h +++ b/libcxx/include/__fwd/span.h @@ -11,7 +11,7 @@ #define _LIBCPP___FWD_SPAN_H #include <__config> -#include +#include <__cstddef/size_t.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/libcxx/include/__fwd/subrange.h b/libcxx/include/__fwd/subrange.h index 60a41da23dd44e4..5b3a07e55348a63 100644 --- a/libcxx/include/__fwd/subrange.h +++ b/libcxx/include/__fwd/subrange.h @@ -11,8 +11,8 @@ #include <__concepts/copyable.h> #include <__config> +#include <__cstddef/size_t.h> #include <__iterator/concepts.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__fwd/tuple.h b/libcxx/include/__fwd/tuple.h index 902770c29555ed8..2ed32bc0df4e149 100644 --- a/libcxx/include/__fwd/tuple.h +++ b/libcxx/include/__fwd/tuple.h @@ -10,7 +10,7 @@ #define _LIBCPP___FWD_TUPLE_H #include <__config> -#include +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h index be2890bee49284f..93ea7efd4953789 100644 --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -34,6 +34,7 @@ #include <__memory/pointer_traits.h> #include <__type_traits/add_pointer.h> #include <__type_traits/common_reference.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_pointer.h> #include <__type_traits/is_primary_template.h> #include <__type_traits/is_reference.h> diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h index 11af9e301842cf5..4d9ad480cc4a298 100644 --- a/libcxx/include/__iterator/iterator_traits.h +++ b/libcxx/include/__iterator/iterator_traits.h @@ -24,6 +24,8 @@ #include <__type_traits/common_reference.h> #include <__type_traits/conditional.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_convertible.h> #include <__type_traits/is_object.h> #include <__type_traits/is_primary_template.h> diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h index 34f8d5f1663b24a..549d8ff2dbd7db1 100644 --- a/libcxx/include/__iterator/wrap_iter.h +++ b/libcxx/include/__iterator/wrap_iter.h @@ -17,6 +17,7 @@ #include <__memory/addressof.h> #include <__memory/pointer_traits.h> #include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_convertible.h> #include diff --git a/libcxx/include/__mdspan/layout_stride.h b/libcxx/include/__mdspan/layout_stride.h index 704a5a4c1aea51a..c57f596431c7c56 100644 --- a/libcxx/include/__mdspan/layout_stride.h +++ b/libcxx/include/__mdspan/layout_stride.h @@ -25,6 +25,7 @@ #include <__type_traits/common_type.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_convertible.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_same.h> #include <__utility/as_const.h> diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h index 0914aceb318b74e..8e08eb74413ee5c 100644 --- a/libcxx/include/__memory/pointer_traits.h +++ b/libcxx/include/__memory/pointer_traits.h @@ -15,6 +15,7 @@ #include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_class.h> #include <__type_traits/is_function.h> #include <__type_traits/is_void.h> diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h index d487e4fbe3a9535..4dd8022822d2231 100644 --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -34,6 +34,8 @@ #include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_array.h> #include <__type_traits/is_bounded_array.h> #include <__type_traits/is_constructible.h> diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h index 7f5e0ea243c9566..392cf421378214d 100644 --- a/libcxx/include/__memory/unique_ptr.h +++ b/libcxx/include/__memory/unique_ptr.h @@ -23,6 +23,7 @@ #include <__type_traits/common_type.h> #include <__type_traits/conditional.h> #include <__type_traits/dependent_type.h> +#include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_array.h> #include <__type_traits/is_assignable.h> diff --git a/libcxx/include/__memory/uses_allocator.h b/libcxx/include/__memory/uses_allocator.h index 84310c3fa56739a..16504e8b2a99895 100644 --- a/libcxx/include/__memory/uses_allocator.h +++ b/libcxx/include/__memory/uses_allocator.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_USES_ALLOCATOR_H #include <__config> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_convertible.h> #include diff --git a/libcxx/include/__random/mersenne_twister_engine.h b/libcxx/include/__random/mersenne_twister_engine.h index 65280d7c5505f77..1f50e608ce8d4e9 100644 --- a/libcxx/include/__random/mersenne_twister_engine.h +++ b/libcxx/include/__random/mersenne_twister_engine.h @@ -13,6 +13,7 @@ #include <__algorithm/min.h> #include <__config> #include <__random/is_seed_sequence.h> +#include <__type_traits/enable_if.h> #include #include #include diff --git a/libcxx/include/__random/seed_seq.h b/libcxx/include/__random/seed_seq.h index 5cf84aeb8a72b38..c1a320a75c88aaf 100644 --- a/libcxx/include/__random/seed_seq.h +++ b/libcxx/include/__random/seed_seq.h @@ -14,6 +14,8 @@ #include <__algorithm/max.h> #include <__config> #include <__iterator/iterator_traits.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_unsigned.h> #include #include diff --git a/libcxx/include/__random/subtract_with_carry_engine.h b/libcxx/include/__random/subtract_with_carry_engine.h index ec25fed49f94981..926333cdda45ee8 100644 --- a/libcxx/include/__random/subtract_with_carry_engine.h +++ b/libcxx/include/__random/subtract_with_carry_engine.h @@ -14,6 +14,7 @@ #include <__config> #include <__random/is_seed_sequence.h> #include <__random/linear_congruential_engine.h> +#include <__type_traits/enable_if.h> #include #include #include diff --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h index aba584ef933542f..144746babb325f7 100644 --- a/libcxx/include/__ranges/subrange.h +++ b/libcxx/include/__ranges/subrange.h @@ -33,6 +33,7 @@ #include <__tuple/tuple_size.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_pointer.h> #include <__type_traits/is_reference.h> #include <__type_traits/make_unsigned.h> diff --git a/libcxx/include/__string/constexpr_c_functions.h b/libcxx/include/__string/constexpr_c_functions.h index 32fc06e121b3628..9b8871e2e71a38f 100644 --- a/libcxx/include/__string/constexpr_c_functions.h +++ b/libcxx/include/__string/constexpr_c_functions.h @@ -13,11 +13,13 @@ #include <__memory/addressof.h> #include <__memory/construct_at.h> #include <__type_traits/datasizeof.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_always_bitcastable.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_equality_comparable.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/is_trivially_lexicographically_comparable.h> diff --git a/libcxx/include/__tuple/tuple_size.h b/libcxx/include/__tuple/tuple_size.h index 18a17fd4d58780b..21c9811abeee7b3 100644 --- a/libcxx/include/__tuple/tuple_size.h +++ b/libcxx/include/__tuple/tuple_size.h @@ -12,6 +12,8 @@ #include <__config> #include <__fwd/tuple.h> #include <__tuple/tuple_types.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_const.h> #include <__type_traits/is_volatile.h> #include diff --git a/libcxx/include/__type_traits/aligned_storage.h b/libcxx/include/__type_traits/aligned_storage.h index 46aae12832f8674..49b4e971bbb675e 100644 --- a/libcxx/include/__type_traits/aligned_storage.h +++ b/libcxx/include/__type_traits/aligned_storage.h @@ -10,11 +10,11 @@ #define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/conditional.h> #include <__type_traits/integral_constant.h> #include <__type_traits/nat.h> #include <__type_traits/type_list.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/aligned_union.h b/libcxx/include/__type_traits/aligned_union.h index 005ed9a096ea8eb..de62a4b1c2a3316 100644 --- a/libcxx/include/__type_traits/aligned_union.h +++ b/libcxx/include/__type_traits/aligned_union.h @@ -10,9 +10,9 @@ #define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/aligned_storage.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/alignment_of.h b/libcxx/include/__type_traits/alignment_of.h index f2d069bf2488f72..8871c8ce110d67a 100644 --- a/libcxx/include/__type_traits/alignment_of.h +++ b/libcxx/include/__type_traits/alignment_of.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/extent.h b/libcxx/include/__type_traits/extent.h index bab03fe997eb6b0..1c34a4db1c4b52b 100644 --- a/libcxx/include/__type_traits/extent.h +++ b/libcxx/include/__type_traits/extent.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_EXTENT_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_allocator.h b/libcxx/include/__type_traits/is_allocator.h index 144ffac4d7ce5b0..191eeb9a1f52269 100644 --- a/libcxx/include/__type_traits/is_allocator.h +++ b/libcxx/include/__type_traits/is_allocator.h @@ -10,10 +10,10 @@ #define _LIBCPP___TYPE_IS_ALLOCATOR_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> #include <__type_traits/void_t.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_array.h b/libcxx/include/__type_traits/is_array.h index dc23de28d2c63b6..f34204e19ed899d 100644 --- a/libcxx/include/__type_traits/is_array.h +++ b/libcxx/include/__type_traits/is_array.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_bounded_array.h b/libcxx/include/__type_traits/is_bounded_array.h index 211403d638d08c8..a78b52e7062b82c 100644 --- a/libcxx/include/__type_traits/is_bounded_array.h +++ b/libcxx/include/__type_traits/is_bounded_array.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_nothrow_destructible.h b/libcxx/include/__type_traits/is_nothrow_destructible.h index c2d5ca87232aa1d..41271a38f37116f 100644 --- a/libcxx/include/__type_traits/is_nothrow_destructible.h +++ b/libcxx/include/__type_traits/is_nothrow_destructible.h @@ -10,10 +10,10 @@ #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_destructible.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_null_pointer.h b/libcxx/include/__type_traits/is_null_pointer.h index 9f5697e232684ed..abc5d142562f1ed 100644 --- a/libcxx/include/__type_traits/is_null_pointer.h +++ b/libcxx/include/__type_traits/is_null_pointer.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H #include <__config> +#include <__cstddef/nullptr_t.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_swappable.h b/libcxx/include/__type_traits/is_swappable.h index 0b817e65099339f..f4d687094bbca18 100644 --- a/libcxx/include/__type_traits/is_swappable.h +++ b/libcxx/include/__type_traits/is_swappable.h @@ -10,6 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_assignable.h> @@ -18,7 +19,6 @@ #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/void_t.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/rank.h b/libcxx/include/__type_traits/rank.h index 7f6fad1c540245b..aeeedec40dee568 100644 --- a/libcxx/include/__type_traits/rank.h +++ b/libcxx/include/__type_traits/rank.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_RANK_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/remove_all_extents.h b/libcxx/include/__type_traits/remove_all_extents.h index d5373b51f52215e..db7dab4a6c13226 100644 --- a/libcxx/include/__type_traits/remove_all_extents.h +++ b/libcxx/include/__type_traits/remove_all_extents.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H #include <__config> -#include +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/remove_extent.h b/libcxx/include/__type_traits/remove_extent.h index fe37b5c7266c6ba..aceeb47069660bb 100644 --- a/libcxx/include/__type_traits/remove_extent.h +++ b/libcxx/include/__type_traits/remove_extent.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H #include <__config> -#include +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/type_list.h b/libcxx/include/__type_traits/type_list.h index 02905707ee37a29..0d9ca9895837721 100644 --- a/libcxx/include/__type_traits/type_list.h +++ b/libcxx/include/__type_traits/type_list.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H #include <__config> -#include +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__utility/in_place.h b/libcxx/include/__utility/in_place.h index fa7a2f4bfd4a95f..459b271675261cb 100644 --- a/libcxx/include/__utility/in_place.h +++ b/libcxx/include/__utility/in_place.h @@ -10,6 +10,7 @@ #define _LIBCPP___UTILITY_IN_PLACE_H #include <__config> +#include <__type_traits/integral_constant.h> #include <__type_traits/remove_cvref.h> #include diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h index 0afbebcdc9f2ae5..78534a3f399f25e 100644 --- a/libcxx/include/__utility/pair.h +++ b/libcxx/include/__utility/pair.h @@ -25,6 +25,7 @@ #include <__type_traits/common_type.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> diff --git a/libcxx/include/__utility/swap.h b/libcxx/include/__utility/swap.h index ab88b8e0a0b5313..ecfbdec75a2aeb4 100644 --- a/libcxx/include/__utility/swap.h +++ b/libcxx/include/__utility/swap.h @@ -10,6 +10,7 @@ #define _LIBCPP___UTILITY_SWAP_H #include <__config> +#include <__type_traits/enable_if.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> diff --git a/libcxx/include/any b/libcxx/include/any index 5def14dc87e6bfb..7630e8a057d0554 100644 --- a/libcxx/include/any +++ b/libcxx/include/any @@ -90,6 +90,7 @@ namespace std { #include <__type_traits/aligned_storage.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_function.h> #include <__type_traits/is_nothrow_constructible.h> diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef index 592f6261a6de3f5..2b138d9690393f8 100644 --- a/libcxx/include/cstddef +++ b/libcxx/include/cstddef @@ -34,9 +34,6 @@ Types: */ #include <__config> -#include <__type_traits/enable_if.h> -#include <__type_traits/integral_constant.h> -#include <__type_traits/is_integral.h> #include #include @@ -53,80 +50,10 @@ Types: # pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD - -using ::nullptr_t; -using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; - -#if !defined(_LIBCPP_CXX03_LANG) -using ::max_align_t _LIBCPP_USING_IF_EXISTS; -#endif - -_LIBCPP_END_NAMESPACE_STD - -#if _LIBCPP_STD_VER >= 17 -namespace std { // purposefully not versioned - -enum class byte : unsigned char {}; - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { - return static_cast( - static_cast(static_cast(__lhs) | static_cast(__rhs))); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { - return __lhs = __lhs | __rhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { - return static_cast( - static_cast(static_cast(__lhs) & static_cast(__rhs))); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { - return __lhs = __lhs & __rhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { - return static_cast( - static_cast(static_cast(__lhs) ^ static_cast(__rhs))); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { - return __lhs = __lhs ^ __rhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { - return static_cast(static_cast(~static_cast(__b))); -} - -template ::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { - return __lhs = __lhs << __shift; -} - -template ::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { - return static_cast(static_cast(static_cast(__lhs) << __shift)); -} - -template ::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { - return __lhs = __lhs >> __shift; -} - -template ::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { - return static_cast(static_cast(static_cast(__lhs) >> __shift)); -} - -template ::value, int> = 0> -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { - return static_cast<_Integer>(__b); -} - -} // namespace std -#endif // _LIBCPP_STD_VER >= 17 +#include <__cstddef/byte.h> +#include <__cstddef/max_align_t.h> +#include <__cstddef/nullptr_t.h> +#include <__cstddef/ptrdiff_t.h> +#include <__cstddef/size_t.h> #endif // _LIBCPP_CSTDDEF diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio index 7f94371081f8b1c..a461c24dcc01930 100644 --- a/libcxx/include/cstdio +++ b/libcxx/include/cstdio @@ -96,6 +96,7 @@ void perror(const char* s); */ #include <__config> +#include <__cstddef/size_t.h> #include @@ -115,7 +116,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::FILE _LIBCPP_USING_IF_EXISTS; using ::fpos_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::fclose _LIBCPP_USING_IF_EXISTS; using ::fflush _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib index c817fd8f4accdaf..1ecdd3a6d0328cd 100644 --- a/libcxx/include/cstdlib +++ b/libcxx/include/cstdlib @@ -82,6 +82,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 */ #include <__config> +#include <__cstddef/size_t.h> #include @@ -99,7 +100,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 _LIBCPP_BEGIN_NAMESPACE_STD -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::div_t _LIBCPP_USING_IF_EXISTS; using ::ldiv_t _LIBCPP_USING_IF_EXISTS; using ::lldiv_t _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/cstring b/libcxx/include/cstring index c2c92b02e73cc1f..5bb6e3e10628f21 100644 --- a/libcxx/include/cstring +++ b/libcxx/include/cstring @@ -57,6 +57,7 @@ size_t strlen(const char* s); */ #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/is_constant_evaluated.h> #include @@ -75,7 +76,6 @@ size_t strlen(const char* s); _LIBCPP_BEGIN_NAMESPACE_STD -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::memcpy _LIBCPP_USING_IF_EXISTS; using ::memmove _LIBCPP_USING_IF_EXISTS; using ::strcpy _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/ctime b/libcxx/include/ctime index f47b49a43e23ef9..d2d2470f2fa60b4 100644 --- a/libcxx/include/ctime +++ b/libcxx/include/ctime @@ -46,6 +46,7 @@ int timespec_get( struct timespec *ts, int base); // C++17 */ #include <__config> +#include <__cstddef/size_t.h> // is not provided by libc++ #if __has_include() @@ -62,7 +63,6 @@ int timespec_get( struct timespec *ts, int base); // C++17 _LIBCPP_BEGIN_NAMESPACE_STD using ::clock_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::time_t _LIBCPP_USING_IF_EXISTS; using ::tm _LIBCPP_USING_IF_EXISTS; #if _LIBCPP_STD_VER >= 17 diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar index f0015be275367da..bfc26f03aaf7826 100644 --- a/libcxx/include/cuchar +++ b/libcxx/include/cuchar @@ -37,6 +37,7 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); */ #include <__config> +#include <__cstddef/size_t.h> #include @@ -57,7 +58,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_CXX03_LANG) using ::mbstate_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; # if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar index 08cfac58c846acf..f5a26664c1c3e4a 100644 --- a/libcxx/include/cwchar +++ b/libcxx/include/cwchar @@ -103,6 +103,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, */ #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/copy_cv.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_equality_comparable.h> @@ -127,7 +128,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, _LIBCPP_BEGIN_NAMESPACE_STD using ::mbstate_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::tm _LIBCPP_USING_IF_EXISTS; using ::wint_t _LIBCPP_USING_IF_EXISTS; using ::FILE _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/experimental/__simd/reference.h b/libcxx/include/experimental/__simd/reference.h index 39f60d64f7b41fb..c60c08b0ea459c2 100644 --- a/libcxx/include/experimental/__simd/reference.h +++ b/libcxx/include/experimental/__simd/reference.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H #define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H +#include <__type_traits/enable_if.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_same.h> #include <__utility/declval.h> diff --git a/libcxx/include/experimental/__simd/scalar.h b/libcxx/include/experimental/__simd/scalar.h index 1add4653209ace7..a2aeeb5cd0f54fd 100644 --- a/libcxx/include/experimental/__simd/scalar.h +++ b/libcxx/include/experimental/__simd/scalar.h @@ -11,6 +11,7 @@ #define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H #include <__assert> +#include <__type_traits/integral_constant.h> #include #include #include diff --git a/libcxx/include/experimental/__simd/simd.h b/libcxx/include/experimental/__simd/simd.h index 37e334aad6da07f..db0f9b39d9600c9 100644 --- a/libcxx/include/experimental/__simd/simd.h +++ b/libcxx/include/experimental/__simd/simd.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H +#include <__type_traits/enable_if.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_cvref.h> #include <__utility/forward.h> diff --git a/libcxx/include/experimental/__simd/simd_mask.h b/libcxx/include/experimental/__simd/simd_mask.h index fd6dee2e28ee919..d54d4898b718af3 100644 --- a/libcxx/include/experimental/__simd/simd_mask.h +++ b/libcxx/include/experimental/__simd/simd_mask.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H +#include <__type_traits/enable_if.h> #include <__type_traits/is_same.h> #include #include diff --git a/libcxx/include/experimental/__simd/vec_ext.h b/libcxx/include/experimental/__simd/vec_ext.h index 316866b84873dda..5787f237bb01ef3 100644 --- a/libcxx/include/experimental/__simd/vec_ext.h +++ b/libcxx/include/experimental/__simd/vec_ext.h @@ -12,6 +12,7 @@ #include <__assert> #include <__bit/bit_ceil.h> +#include <__type_traits/integral_constant.h> #include <__utility/forward.h> #include <__utility/integer_sequence.h> #include diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index 7cde21417561edf..3abc11723a5a927 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -440,6 +440,11 @@ module std_cstdbool [system] { } module std_cstddef [system] { header "cstddef" + module byte { header "__cstddef/byte.h" } + module max_align_t { header "__cstddef/max_align_t.h" } + module nullptr_t { header "__cstddef/nullptr_t.h" } + module ptrdiff_t { header "__cstddef/ptrdiff_t.h" } + module size_t { header "__cstddef/size_t.h" } export * } module std_cstdint [system] { @@ -1418,6 +1423,7 @@ module std_private_iterator_iterator [system] { header "__iterato module std_private_iterator_iterator_traits [system] { header "__iterator/iterator_traits.h" export std_private_type_traits_is_primary_template + export std_private_type_traits_integral_constant } module std_private_iterator_iterator_with_data [system] { header "__iterator/iterator_with_data.h" } module std_private_iterator_mergeable [system] { @@ -1814,7 +1820,10 @@ module std_private_tuple_tuple_like [system] { export * } module std_private_tuple_tuple_like_ext [system] { header "__tuple/tuple_like_ext.h" } -module std_private_tuple_tuple_size [system] { header "__tuple/tuple_size.h" } +module std_private_tuple_tuple_size [system] { + header "__tuple/tuple_size.h" + export std_private_type_traits_integral_constant +} module std_private_tuple_tuple_types [system] { header "__tuple/tuple_types.h" } module std_private_type_traits_add_const [system] { header "__type_traits/add_const.h" } @@ -1926,7 +1935,10 @@ 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_integral [system] { + header "__type_traits/is_integral.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_literal_type [system] { header "__type_traits/is_literal_type.h" } module std_private_type_traits_is_member_pointer [system] { header "__type_traits/is_member_pointer.h" } module std_private_type_traits_is_nothrow_assignable [system] { header "__type_traits/is_nothrow_assignable.h" } @@ -1954,7 +1966,10 @@ module std_private_type_traits_is_primary_template [system header "__type_traits/is_primary_template.h" export std_private_type_traits_enable_if } -module std_private_type_traits_is_reference [system] { header "__type_traits/is_reference.h" } +module std_private_type_traits_is_reference [system] { + header "__type_traits/is_reference.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_reference_wrapper [system] { header "__type_traits/is_reference_wrapper.h" } module std_private_type_traits_is_referenceable [system] { header "__type_traits/is_referenceable.h" } module std_private_type_traits_is_same [system] { @@ -1976,7 +1991,10 @@ module std_private_type_traits_is_swappable [system module std_private_type_traits_is_trivial [system] { header "__type_traits/is_trivial.h" } module std_private_type_traits_is_trivially_assignable [system] { header "__type_traits/is_trivially_assignable.h" } module std_private_type_traits_is_trivially_constructible [system] { header "__type_traits/is_trivially_constructible.h" } -module std_private_type_traits_is_trivially_copyable [system] { header "__type_traits/is_trivially_copyable.h" } +module std_private_type_traits_is_trivially_copyable [system] { + header "__type_traits/is_trivially_copyable.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_trivially_destructible [system] { header "__type_traits/is_trivially_destructible.h" } module std_private_type_traits_is_trivially_lexicographically_comparable [system] { header "__type_traits/is_trivially_lexicographically_comparable.h" } module std_private_type_traits_is_trivially_relocatable [system] { header "__type_traits/is_trivially_relocatable.h" } @@ -2044,7 +2062,10 @@ module std_private_utility_exception_guard [system] { header "__utility/e module std_private_utility_exchange [system] { header "__utility/exchange.h" } module std_private_utility_forward [system] { header "__utility/forward.h" } module std_private_utility_forward_like [system] { header "__utility/forward_like.h" } -module std_private_utility_in_place [system] { header "__utility/in_place.h" } +module std_private_utility_in_place [system] { + header "__utility/in_place.h" + export std_private_type_traits_integral_constant +} module std_private_utility_integer_sequence [system] { header "__utility/integer_sequence.h" } module std_private_utility_is_pointer_in_range [system] { header "__utility/is_pointer_in_range.h" } module std_private_utility_is_valid_range [system] { header "__utility/is_valid_range.h" } diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo index 2727cad02fa99ab..54e0b4cf5d63480 100644 --- a/libcxx/include/typeinfo +++ b/libcxx/include/typeinfo @@ -58,6 +58,7 @@ public: #include <__config> #include <__exception/exception.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_constant_evaluated.h> #include <__verbose_abort> #include diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map index acf3485e644afba..69314ba75631974 100644 --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -600,7 +600,9 @@ template #include <__ranges/concepts.h> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> +#include <__type_traits/is_integral.h> #include <__type_traits/type_identity.h> #include <__utility/forward.h> #include diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set index d11ceacba81433d..fb50f78a02941c9 100644 --- a/libcxx/include/unordered_set +++ b/libcxx/include/unordered_set @@ -548,7 +548,9 @@ template #include <__ranges/concepts.h> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> +#include <__type_traits/is_integral.h> #include <__utility/forward.h> #include diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index 3bf39ea17c9129e..51f38ea086ac025 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -231,7 +231,6 @@ expected cstddef expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iosfwd experimental/iterator iterator experimental/iterator type_traits @@ -918,7 +917,6 @@ tuple type_traits tuple typeinfo tuple utility tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 49125486cfcf6ef..f7b0179f6f60ed6 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -232,7 +232,6 @@ expected cstddef expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iosfwd experimental/iterator iterator experimental/iterator type_traits @@ -925,7 +924,6 @@ tuple type_traits tuple typeinfo tuple utility tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 28dfb320fe06c9f..11afb76583a8cce 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -233,7 +233,6 @@ expected cstddef expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iosfwd experimental/iterator iterator experimental/iterator type_traits @@ -928,7 +927,6 @@ tuple type_traits tuple typeinfo tuple utility tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index 5b7b6cecf73f89e..42ba4ef3f6f5275 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -233,7 +233,6 @@ expected cstddef expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iosfwd experimental/iterator iterator experimental/iterator type_traits @@ -929,7 +928,6 @@ tuple type_traits tuple typeinfo tuple utility tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index 84ea6433fb12df7..cd48b37520f157f 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -241,7 +241,6 @@ expected cstddef expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iosfwd experimental/iterator iterator experimental/iterator type_traits @@ -936,7 +935,6 @@ tuple type_traits tuple typeinfo tuple utility tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index 946ba486294d3df..db09568fc76ffcb 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -155,7 +155,6 @@ expected cstdint expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iterator experimental/memory cstddef experimental/memory cstdint @@ -647,7 +646,6 @@ tuple compare tuple cstddef tuple cstdint tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 946ba486294d3df..db09568fc76ffcb 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -155,7 +155,6 @@ expected cstdint expected initializer_list expected new expected version -experimental/iterator cstddef experimental/iterator iterator experimental/memory cstddef experimental/memory cstdint @@ -647,7 +646,6 @@ tuple compare tuple cstddef tuple cstdint tuple version -type_traits cstddef type_traits cstdint type_traits version typeindex compare diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp index 5e37db95ab090e8..1ab1aa60ab826fe 100644 --- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp +++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp index 38a46fcc1222744..f243e9d1f63b50c 100644 --- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp +++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp index baf2032a4a1f00c..e6a0cfb9d11e025 100644 --- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp +++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp index 81dca301e21fb39..a1088218a35f010 100644 --- a/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp +++ b/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp index 92268cf563b4717..82931162b4f39f9 100644 --- a/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp index 9d5d361662e8c8e..20e0eff91b253ca 100644 --- a/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp index 63b60640ac04804..1fedc4f8a5386ed 100644 --- a/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp index 1df1d883a12e1f1..4221b86fe1cc661 100644 --- a/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp index 588c5e0cf7af278..a7c5c43a4e2c2ef 100644 --- a/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp b/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp index 16eabbd2a5a4de0..72e412772fb0815 100644 --- a/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp b/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp index 53405588266f74b..fc0fff60394e316 100644 --- a/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp +++ b/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include diff --git a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp index 9d5d37abde95849..897da8b769e6a96 100644 --- a/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp +++ b/libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp @@ -122,7 +122,9 @@ void header_exportable_declarations::registerMatchers(clang::ast_matchers::Match [[fallthrough]]; case FileType::ModulePartition: case FileType::CompatModulePartition: - finder->addMatcher(namedDecl(isExpansionInFileMatching(filename_)).bind("header_exportable_declarations"), this); + finder->addMatcher(namedDecl(anyOf(isExpansionInFileMatching(filename_), isExpansionInFileMatching(extra_header_))) + .bind("header_exportable_declarations"), + this); break; case FileType::Module: case FileType::CompatModule: diff --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py index b7758dc9a41ee80..91933d4f425bd87 100644 --- a/libcxx/utils/libcxx/test/modules.py +++ b/libcxx/utils/libcxx/test/modules.py @@ -99,6 +99,10 @@ # same definition. ExtraHeader["functional"] = "v1/__compare/compare_three_way.h$" +# Some C compatibility headers define std::size_t, which is in <__cstddef/size_t.h> +for header in ("cstdio", "cstdlib", "cstring", "ctime", "cuchar", "cwchar"): + ExtraHeader[header] = "v1/__cstddef/size_t.h$" + # newline needs to be escaped for the module partition output. nl = "\\\\n"