diff options
Diffstat (limited to 'libcxx')
| -rw-r--r-- | libcxx/docs/ReleaseNotes/22.rst | 5 | ||||
| -rw-r--r-- | libcxx/include/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | libcxx/include/__algorithm/generate_n.h | 16 | ||||
| -rw-r--r-- | libcxx/include/__algorithm/ranges_generate_n.h | 8 | ||||
| -rw-r--r-- | libcxx/include/__config | 4 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api.h | 2 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/support/bsd_like.h | 4 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/support/netbsd.h | 20 | ||||
| -rw-r--r-- | libcxx/include/module.modulemap.in | 1 | ||||
| -rw-r--r-- | libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp | 5 | ||||
| -rw-r--r-- | libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp | 25 | ||||
| -rw-r--r-- | libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp | 5 | ||||
| -rw-r--r-- | libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp | 25 | ||||
| -rw-r--r-- | libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp | 30 | ||||
| -rw-r--r-- | libcxx/utils/libcxx/test/features.py | 17 |
15 files changed, 87 insertions, 81 deletions
diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst index 25d33a9..980390c 100644 --- a/libcxx/docs/ReleaseNotes/22.rst +++ b/libcxx/docs/ReleaseNotes/22.rst @@ -76,8 +76,9 @@ Improvements and New Features - The ``std::{fill, fill_n}`` and ``std::ranges::{fill, fill_n}`` algorithms have been optimized for segmented iterators, resulting in a performance improvement of at least 10x for ``std::deque<int>`` iterators and ``std::join_view<std::vector<std::vector<int>>>`` iterators. -- The ``std::generate`` and ``std::generate_n`` algorithms have been optimized for segmented iterators, resulting in a - performance improvement for ``std::deque<short>`` and ``std::join_view<vector<vector<short>>>`` iterators. +- The ``std::{generate, generate_n}`` and ``std::ranges::generate_n`` algorithms have been optimized for segmented + iterators, resulting in a performance improvement for ``std::deque<short>`` and + ``std::join_view<vector<vector<short>>>`` iterators. Deprecations and Removals ------------------------- diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 37259a7..de9819c 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -529,6 +529,7 @@ set(files __locale_dir/support/freebsd.h __locale_dir/support/fuchsia.h __locale_dir/support/linux.h + __locale_dir/support/netbsd.h __locale_dir/support/no_locale/characters.h __locale_dir/support/no_locale/strtonum.h __locale_dir/support/windows.h diff --git a/libcxx/include/__algorithm/generate_n.h b/libcxx/include/__algorithm/generate_n.h index e9da133..23899e4 100644 --- a/libcxx/include/__algorithm/generate_n.h +++ b/libcxx/include/__algorithm/generate_n.h @@ -13,22 +13,34 @@ #include <__config> #include <__functional/identity.h> #include <__utility/forward.h> +#include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template <class _OutputIterator, class _Size, class _Generator> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator -generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) { +__generate_n(_OutputIterator __first, _Size __orig_n, _Generator& __gen) { using __iter_ref = decltype(*__first); __identity __proj; auto __f = [&](__iter_ref __element) { std::forward<__iter_ref>(__element) = __gen(); }; - return std::__for_each_n(__first, __orig_n, __f, __proj); + return std::__for_each_n(std::move(__first), __orig_n, __f, __proj); +} + +template <class _OutputIterator, class _Size, class _Generator> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator +generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) { + return std::__generate_n(std::move(__first), __orig_n, __gen); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_GENERATE_N_H diff --git a/libcxx/include/__algorithm/ranges_generate_n.h b/libcxx/include/__algorithm/ranges_generate_n.h index a318994..0cc9ce7 100644 --- a/libcxx/include/__algorithm/ranges_generate_n.h +++ b/libcxx/include/__algorithm/ranges_generate_n.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H #define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H +#include <__algorithm/generate_n.h> #include <__concepts/constructible.h> #include <__concepts/invocable.h> #include <__config> @@ -38,12 +39,7 @@ struct __generate_n { requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> _LIBCPP_HIDE_FROM_ABI constexpr _OutIter operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const { - for (; __n > 0; --__n) { - *__first = __gen(); - ++__first; - } - - return __first; + return std::__generate_n(std::move(__first), __n, __gen); } }; diff --git a/libcxx/include/__config b/libcxx/include/__config index 5971a3c..b4c081d 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1021,9 +1021,7 @@ typedef __char32_t char32_t; // the latter depends on internal GNU libc details that are not appropriate // to depend on here, so any declarations present when __cpp_char8_t is not // defined are ignored. -# if defined(__clang__) -# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1 -# elif defined(_LIBCPP_GLIBC_PREREQ) +# if defined(_LIBCPP_GLIBC_PREREQ) # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1 # else diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h index 9f3ce02..8c8f000 100644 --- a/libcxx/include/__locale_dir/locale_base_api.h +++ b/libcxx/include/__locale_dir/locale_base_api.h @@ -115,6 +115,8 @@ # include <__locale_dir/support/apple.h> # elif defined(__FreeBSD__) # include <__locale_dir/support/freebsd.h> +# elif defined(__NetBSD__) +# include <__locale_dir/support/netbsd.h> # elif defined(_LIBCPP_MSVCRT_LIKE) # include <__locale_dir/support/windows.h> # elif defined(__Fuchsia__) diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h index ac40292..9d4bdd1 100644 --- a/libcxx/include/__locale_dir/support/bsd_like.h +++ b/libcxx/include/__locale_dir/support/bsd_like.h @@ -24,7 +24,9 @@ # include <wctype.h> #endif -#include <xlocale.h> +#if __has_include(<xlocale.h>) +# include <xlocale.h> +#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__locale_dir/support/netbsd.h b/libcxx/include/__locale_dir/support/netbsd.h new file mode 100644 index 0000000..190857f --- /dev/null +++ b/libcxx/include/__locale_dir/support/netbsd.h @@ -0,0 +1,20 @@ +//===-----------------------------------------------------------------------===// +// +// 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___LOCALE_DIR_SUPPORT_NETBSD_H +#define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#include <__locale_dir/support/bsd_like.h> + +#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in index a86d6c6..11ab61d 100644 --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -1587,6 +1587,7 @@ module std [system] { textual header "__locale_dir/support/freebsd.h" textual header "__locale_dir/support/fuchsia.h" textual header "__locale_dir/support/linux.h" + textual header "__locale_dir/support/netbsd.h" textual header "__locale_dir/support/no_locale/characters.h" textual header "__locale_dir/support/no_locale/strtonum.h" textual header "__locale_dir/support/windows.h" diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp index c448ba8..a1560c8 100644 --- a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp +++ b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp @@ -23,6 +23,11 @@ // __STDC_UTF_16__ may or may not be defined by the C standard library // __STDC_UTF_32__ may or may not be defined by the C standard library +#if !defined(TEST_HAS_NO_C8RTOMB_MBRTOC8) +ASSERT_SAME_TYPE(size_t, decltype(mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); +ASSERT_SAME_TYPE(size_t, decltype(c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); +#endif + ASSERT_SAME_TYPE(size_t, decltype(mbrtoc16((char16_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); ASSERT_SAME_TYPE(size_t, decltype(c16rtomb((char*)0, (char16_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp deleted file mode 100644 index 34b512f..0000000 --- a/libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03 - -// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail -// XFAIL: target={{.+}}-aix{{.*}} -// XFAIL: android -// XFAIL: darwin -// XFAIL: freebsd -// XFAIL: windows -// XFAIL: glibc-no-char8_t-support -// XFAIL: LIBCXX-PICOLIBC-FIXME - -// <uchar.h> - -#include <uchar.h> - -ASSERT_SAME_TYPE(size_t, decltype(mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); -ASSERT_SAME_TYPE(size_t, decltype(c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp index 96b394a..2076384 100644 --- a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp +++ b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp @@ -23,6 +23,11 @@ // __STDC_UTF_16__ may or may not be defined by the C standard library // __STDC_UTF_32__ may or may not be defined by the C standard library +#if !defined(TEST_HAS_NO_C8RTOMB_MBRTOC8) +ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); +ASSERT_SAME_TYPE(std::size_t, decltype(std::c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); +#endif + ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtoc16((char16_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); ASSERT_SAME_TYPE(std::size_t, decltype(std::c16rtomb((char*)0, (char16_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp deleted file mode 100644 index 019265b..0000000 --- a/libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03 - -// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail -// XFAIL: target={{.+}}-aix{{.*}} -// XFAIL: android -// XFAIL: darwin -// XFAIL: freebsd -// XFAIL: windows -// XFAIL: glibc-no-char8_t-support -// XFAIL: LIBCXX-PICOLIBC-FIXME - -// <cuchar> - -#include <cuchar> - -ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); -ASSERT_SAME_TYPE(std::size_t, decltype(std::c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp new file mode 100644 index 0000000..1d4a225 --- /dev/null +++ b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03 + +#include <uchar.h> + +#include "test_macros.h" + +// When C++ char8_t support is not enabled, definitions of these functions that +// match the C2X declarations may still be present in the global namespace with +// a char8_t typedef substituted for the C++ char8_t type. If so, these are not +// the declarations we are looking for, so don't test for them. +#if !defined(TEST_HAS_NO_CHAR8_T) +using U = decltype(::c8rtomb); +using V = decltype(::mbrtoc8); +# if !_LIBCPP_HAS_C8RTOMB_MBRTOC8 +// expected-error@-3 {{no member named 'c8rtomb' in the global namespace}} +// expected-error@-3 {{no member named 'mbrtoc8' in the global namespace}} +# else +// expected-no-diagnostics +# endif +#else +// expected-no-diagnostics +#endif diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py index 1668e4a..7d6e78d 100644 --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -293,23 +293,6 @@ DEFAULT_FEATURES = [ """, ), ), - # Check for Glibc < 2.36, where there was no support for char8_t functions - Feature( - name="glibc-no-char8_t-support", - when=lambda cfg: "__GLIBC__" in compilerMacros(cfg) - and not sourceBuilds( - cfg, - """ - #include <uchar.h> - #include <wchar.h> - int main(void) { - char8_t c; - mbstate_t s = {0}; - return mbrtoc8(&c, "", 0, &s); - } - """, - ), - ), Feature( name="has-unix-headers", when=lambda cfg: sourceBuilds( |
