From e12b3766726e6b9f8f204504c52faffa551d2375 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 13 May 2024 13:38:11 +0200 Subject: Update std.cppm to Clang 18, add std.compat.cppm Note that Clang 17 is not longer supported with regards to standard library modules. --- libbuild2/cc/std.cppm | 134 ++++++++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 60 deletions(-) (limited to 'libbuild2/cc/std.cppm') diff --git a/libbuild2/cc/std.cppm b/libbuild2/cc/std.cppm index 5368d1c..575e6a4 100644 --- a/libbuild2/cc/std.cppm +++ b/libbuild2/cc/std.cppm @@ -8,15 +8,15 @@ //===----------------------------------------------------------------------===// // WARNING, this entire header is generated by -// utils/generate_std_cppm_in.py +// utils/generate_libcxx_cppm_in.py // DO NOT MODIFY! module; #include <__config> -#if _LIBCPP_VERSION < 170000 -#error libc++ version 17.0.0 or later required +#if _LIBCPP_VERSION < 180000 +#error libc++ version 18.0.0 or later required #endif // The headers of Table 24: C++ library headersā€ƒ[tab:headers.cpp] @@ -153,11 +153,8 @@ module; # include #endif #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#if __has_include() -# define _LIPCPP_HAS_YES_SYNCSTREAM # include #endif -#endif #include #if !defined(_LIBCPP_HAS_NO_THREADS) # include @@ -177,38 +174,38 @@ module; #if 0 // *** Headers not yet available *** #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #if __has_include() -# error "update the header information for in libcxx/utils/generate_std_cppm_in.py" -#endif // __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +#endif // __has_include() #endif export module std; @@ -232,7 +229,9 @@ export namespace std { using std::ranges::in_in_result; using std::ranges::in_out_out_result; using std::ranges::in_out_result; - // using std::ranges::in_value_result; +#if _LIBCPP_STD_VER >= 23 + using std::ranges::in_value_result; +#endif using std::ranges::min_max_result; // using std::ranges::out_value_result; } // namespace ranges @@ -256,13 +255,15 @@ export namespace std { using std::ranges::none_of; } +#if _LIBCPP_STD_VER >= 23 // [alg.contains], contains -#if 0 namespace ranges { using std::ranges::contains; +#if 0 using std::ranges::contains_subrange; - } // namespace ranges #endif + } // namespace ranges +#endif // _LIBCPP_STD_VER >= 23 // [alg.foreach], for each using std::for_each; @@ -370,20 +371,18 @@ export namespace std { // [alg.starts.with], starts with using std::ranges::starts_with; -#if _LIBCPP_VERSION >= 180000 // [alg.ends.with], ends with using std::ranges::ends_with; -#endif -# if 0 // [alg.fold], fold using std::ranges::fold_left; + using std::ranges::fold_left_with_iter; + using std::ranges::fold_left_with_iter_result; +# if 0 using std::ranges::fold_left_first; using std::ranges::fold_right; using std::ranges::fold_right_last; using std::ranges::fold_left_with_iter; - using std::ranges::fold_left_with_iter_result; - using std::ranges::fold_left_with_iter; using std::ranges::fold_left_first_with_iter; using std::ranges::fold_left_first_with_iter; # endif @@ -955,7 +954,9 @@ export namespace std { using std::atomic_char; using std::atomic_char16_t; using std::atomic_char32_t; +#ifndef _LIBCPP_HAS_NO_CHAR8_T using std::atomic_char8_t; +#endif using std::atomic_int; using std::atomic_llong; using std::atomic_long; @@ -1993,11 +1994,13 @@ export namespace std { export namespace std { #ifndef _LIBCPP_HAS_NO_LOCALIZATION +# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) using std::codecvt_mode; using std::codecvt_utf16; using std::codecvt_utf8; using std::codecvt_utf8_utf16; +# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) #endif // _LIBCPP_HAS_NO_LOCALIZATION } // namespace std @@ -2617,7 +2620,7 @@ export namespace std { using std::mktime; using std::strftime; using std::time; - using std::timespec_get; + using std::timespec_get _LIBCPP_USING_IF_EXISTS; } // namespace std // cuchar.inc @@ -3108,6 +3111,9 @@ export namespace std { #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wformat_string; #endif +#if _LIBCPP_STD_VER >= 26 + using std::runtime_format; +#endif //_LIBCPP_STD_VER >= 26 // [format.functions], formatting functions using std::format; @@ -3590,9 +3596,11 @@ export namespace std { #endif using std::u16streampos; using std::u32streampos; +#ifndef _LIBCPP_HAS_NO_CHAR8_T using std::u8streampos; +#endif -#ifdef _LIBCPP_HAS_YES_SYNCSTREAM +#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM using std::basic_osyncstream; using std::basic_syncbuf; #endif @@ -3600,13 +3608,11 @@ export namespace std { using std::istreambuf_iterator; using std::ostreambuf_iterator; -#ifdef _LIBCPP_HAS_YES_SYNCSTREAM +#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM using std::osyncstream; using std::syncbuf; -#endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -#ifdef _LIBCPP_HAS_YES_SYNCSTREAM using std::wosyncstream; using std::wsyncbuf; #endif @@ -4112,9 +4118,7 @@ export namespace std { // [mdspan.layout], layout mapping using std::layout_left; using std::layout_right; -#if _LIBCPP_VERSION >= 180000 using std::layout_stride; -#endif // [mdspan.accessor.default], class template default_accessor using std::default_accessor; @@ -4171,7 +4175,9 @@ export namespace std { #if _LIBCPP_STD_VER >= 23 using std::allocation_result; - using std::allocate_at_least; + // Note: no longer in Clang 19. + // + //using std::allocate_at_least; #endif // [default.allocator], the default allocator @@ -4283,7 +4289,9 @@ export namespace std { using std::reinterpret_pointer_cast; using std::static_pointer_cast; +#ifndef _LIBCPP_HAS_NO_RTTI using std::get_deleter; +#endif // _LIBCPP_HAS_NO_RTTI // [util.smartptr.shared.io], shared_ptr I/O @@ -4555,6 +4563,16 @@ export namespace std { // [numeric.ops.midpoint], midpoint using std::midpoint; + +#if _LIBCPP_STD_VER >= 26 + // [numeric.sat], saturation arithmetic + using std::add_sat; + using std::div_sat; + using std::mul_sat; + using std::saturate_cast; + using std::sub_sat; +#endif + } // namespace std // optional.inc @@ -4626,14 +4644,17 @@ export namespace std { # endif using std::operator<<; -# if 0 +# if _LIBCPP_STD_VER >= 23 // [ostream.formatted.print], print functions using std::print; using std::println; using std::vprint_nonunicode; +# ifndef _LIBCPP_HAS_NO_UNICODE using std::vprint_unicode; -# endif +# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_STD_VER >= 23 + #endif // _LIBCPP_HAS_NO_LOCALIZATION } // namespace std @@ -5013,13 +5034,11 @@ export namespace std { using std::ranges::views::drop_while; } // namespace views -#ifdef _LIBCPP_ENABLE_EXPERIMENTAL using std::ranges::join_view; namespace views { using std::ranges::views::join; } // namespace views -#endif // _LIBCPP_ENABLE_EXPERIMENTAL #if 0 using std::ranges::join_with_view; @@ -5123,14 +5142,12 @@ export namespace std { #endif #if _LIBCPP_STD_VER >= 23 -#if _LIBCPP_VERSION >= 180000 // [range.chunk.by], chunk by view using std::ranges::chunk_by_view; namespace views { using std::ranges::views::chunk_by; } -#endif #endif // _LIBCPP_STD_VER >= 23 #if 0 @@ -5783,7 +5800,9 @@ export namespace std { using std::string; using std::u16string; using std::u32string; +#ifndef _LIBCPP_HAS_NO_CHAR8_T using std::u8string; +#endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wstring; #endif @@ -5807,7 +5826,9 @@ export namespace std { using std::pmr::string; using std::pmr::u16string; using std::pmr::u32string; +#ifndef _LIBCPP_HAS_NO_CHAR8_T using std::pmr::u8string; +#endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::pmr::wstring; #endif @@ -5816,17 +5837,12 @@ export namespace std { // [basic.string.hash], hash support using std::hash; - // TODO MODULES is this a bug? -#if _LIBCPP_STD_VER >= 23 - using std::operator""s; -#else inline namespace literals { inline namespace string_literals { // [basic.string.literals], suffix for basic_string literals using std::literals::string_literals::operator""s; } // namespace string_literals - } // namespace literals -#endif + } // namespace literals } // namespace std // string_view.inc @@ -5859,7 +5875,9 @@ export namespace std { using std::string_view; using std::u16string_view; using std::u32string_view; +#ifndef _LIBCPP_HAS_NO_CHAR8_T using std::u8string_view; +#endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wstring_view; #endif @@ -5904,8 +5922,6 @@ export namespace std { // //===----------------------------------------------------------------------===// -#ifdef _LIBCPP_HAS_YES_SYNCSTREAM - export namespace std { #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) using std::basic_syncbuf; @@ -5926,8 +5942,6 @@ export namespace std { #endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) } // namespace std -#endif - // system_error.inc // -*- C++ -*- //===----------------------------------------------------------------------===// -- cgit v1.1