summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/string
diff options
context:
space:
mode:
authormikhnenko <[email protected]>2025-02-25 10:55:30 +0300
committermikhnenko <[email protected]>2025-02-25 11:10:50 +0300
commitba3f1646a3a22daceac94dd0cd330152b1d5b5b5 (patch)
tree16da0d516f0c768c219e6f0fc7351676e390873f /contrib/libs/cxxsupp/libcxx/include/string
parentdda9be9e1fde150b4473d9d10ec1a0d3829f7482 (diff)
Update libcxx to 8 July 2024
{% cut "Change log" %} ``` [libc++] Add a test case for std::bit_cast with std::complex (#97751) [libc++] Update status after the St. Louis meeting. (#97951) [libc++] Guard transitive include of `<locale>` with availability macro (#97869) [libc++] Restore `__synth_three_way` lambda (#90398) [libc++][TZDB] Makes implementation experimental. (#95657) [libc++] Remove dead code from the locale base API and support code (#89070) [libc++] Assume newer LLVM versions for not-yet-released macOS versions [libc++] Remove annotations for GCC 13 and update the documentation (#97744) [libc++][test] Updates sized deallocation tests. (#97833) [libc++] Adds a missing include. [libc++] Use __is_array if the builtin is fixed (#93037) [libc++] Use _Complex for multiplication and division of complex floating point types (#83575) [libc++] Adds a new feature-test macro generator class. (#90889) [libc++][chrono] Fixes leap seconds. (#90070) [libc++] Upgrade to GCC 14 (#97205) [libc++] Fix the signatures of `std::rethrow_if_nested` (#91365) [libc++] Use GCC compilers from compiler explorer (#97219) Add a regression test for recent regression in pair. (#97355) [libcxx][Docs] Correct link syntax in hardening docs [libc++] Don't use a ppa for GCC [libc++] Upgrade to GCC 14 in the CI (#95212) [libc++abi] Fix test failures with GCC 14 (#95759) [libc++] Clean up and update deployment target features (#96312) [libc++] Fix how we pass /MANIFEST flag on Windows without clang-cl (#96967) [libc++] Classify iota_view precondition (#96662) [libc++] restrict the expected conversion constructor not compete against copy constructor (#96101) "[libc++] Try again LWG3233 Broken requirements for shared_ptr converting constructors" (#96103) [libc++] LWG3382: NTTP for `pair` and `array` (#85811) [libc++] Get the GCC build mostly clean of warnings (#96604) [libc++] P3029R1: Better `mdspan`'s CTAD - `std::extents` (#89015) [libc++] Move allocator assertion into allocator_traits (#94750) [libc++] change the visibility of libc++ header to public in libcxx module (#91240) [libc++] Use _If for conditional_t (#96193) [libc++] Remove the allocator<const T> extension (#96319) [libc++] Fix incorrect overflow checking in std::lcm (#96310) [libc++] Use __is_nothrow_destructible (#95766) [libc++] Remove Windows-specific configuration from libcxx/test/CMakeLists.txt (#96330) [libc++] Build with -fsized-deallocation (#96217) [libc++] <experimental/simd> Add swap functions of simd reference (#86478) [libc++] Fix deployment target Lit features (#94791) [libc++] Workaround clang bug in __has_unique_object_representations (#95314) [libc++] Remove <ostream> include from <chrono> (#96035) [libc++] Fix triviality of std::pair for trivially copyable types without an assignment operator (#95444) [libc++] Install Python packaging to resolve LLDB data formatter issues (#95971) [libc++] Properly define _LIBCPP_HAS_NO_UNICODE in __config_site (#95138) [libc++] Refactor<__type_traits/is_swappable.h> (#86822) [libc++] Enable modernize-use-equals-delete (#93293) [libc++] Test suite adjustments on macOS (#95835) [libc++] Guard transitive include of `<locale>` with availability macro (#95686) [libc++] Mark more types as trivially relocatable (#89724) [libcxx] [ci] Simplify the mingw x86_64 configs (#95609) [libc++][TZDB] Disables a failing test. (#95659) [libc++] Add default copy ctor to "__chrono/exception.h" (#95338) [libcxx][test][AIX] address more platform differences in locale tests (#94826) [libc++] Remove unnecessary #ifdef guards around PSTL implementation details (#95268) [libc++] Mark local_time test as a long test (#95170) Update actions-runner version for libc++ builder images [libc++] Move the implementation of CPU-based basis operations to namespace __pstl (#95267) [libc++][modules] Mark as implemented. (#90091) [libc++] Adds __cpp_lib_three_way_comparison FTM. (#91515) [libc++] Overhaul the PSTL dispatching mechanism (#88131) [libcxx] Correct and clean-up filesystem operations error_code paths (#88341) [libc++][z/OS] Disable portion of formatter.char.funsigned-char.pass.cpp for no unicode (#94044) [libc++] Mark a few functions in the dylib as noexcept (#94098) [libc++] Fix UB in filesystem::__copy for non-existent destination. (#87615) [libc++] Simplify the definition of string::operator== (#95000) [libc++] Update with LWG issue number for shared-ptr constructor [libc++] Tweak how we check constraints on shared_ptr(nullptr_t) (#94996) [HWASan] make get_info.local_time.pass.cpp UNSUPPORTED [libc++] Fix endianness for algorithm mismatch (#93082) [HWASan] skip libcxx test that times out with hwasan [libc++][TZDB] Implements zoned_traits. (#91059) [libc++][test] Avoid `-Wunused-variable` warnings in mutex tests (#94907) [libc++] Fix invalid escape sequences in Python comments (#94032) [libc++][TZDB] Implements time_zone::to_local. (#91003) [libc++][TZDB] Implements time_zone::to_sys. (#90901) [libc++][TZDB] Implements time_zone::to_sys. (#90394) [libc++][TZDB] Implements time_zone get_info(local_time). (#89537) [libc++] Undeprecate shared_ptr atomic access APIs (#92920) [libc++][regex] Correctly adjust match prefix for zero-length matches. (#94550) [libc++][test][AIX] Only XFAIL atomic tests for before clang 19 (#94646) [libc++] Fix naming of value template parameters (#76888) [libc++][hardening] Finish documenting hardening. (#92021) Fix detection of __datasizeof with Clang. (#94174) [libc++] Fix SyntaxWarning messages from python 3.12 (#93637) [libc++] [test] Consistently use `REQUIRES: has-unix-headers` (#94122) [libc++] Add missing noexcept to span constructor (#94381) Remove act from builder image. It never turned out to be useful [libc++] Adjust XFAIL for quick_exit (#94274) [libc++] Properly detect whether C++20 modules are supported by the compiler (#94275) [libc++] Handle 0 size case for testing support operator new (#93834) [libc++] Fix regression about parsing leading decimal points (#93989) [libc++][test] Mark `optional` test functions as `TEST_CONSTEXPR_CXX20` (#94172) [clang][Modules] Remove unnecessary includes of `Module.h` (#93417) [libc++] Don't give functions C linkage (#94102) [libc++] [test] Cleanup compile-only tests (#94121) [libc++] [test] Fix `__has_include` usage, expand condvarany and spaceship coverage (#94120) [libc++] Fix `std::atomic::wait` ulock wait UL_COMPARE_AND_WAIT64 (#92783) Fix order of include flags for the target & regular include paths. (#93547) [libc++] Fix failures with GCC 14 (#92663) [libc++] Remove the inline namespace for std::filesystem in ABIv2 (#92971) [runtimes] Correctly apply libdir subdir for multilib (#93354) [clang] Preserve Qualifiers and type sugar in TemplateNames (#93433) [libc++][test] Close LWG3018 and add tests (#93047) [runtimes][CMake] Simplify the propagation of test dependencies (#93558) [runtimes] Reintroduce a way to select the compiler used for the test suite (#93542) [libc++] Make the __availability header a sub-header of __config (#93083) [libc++][test] Close LWG3238 and add tests (#93043) [libc++] LWG3223 Broken requirements for shared_ptr converting constructors (#93071) [libc++][test] Close LWG3382 and add tests (#93039) [libc++] [test] Fix portability issues for MSVC (#93259) [libc++] [test] Fix MSVC warnings (#93257) [libc++] Mark P2845R8 `__cpp_lib_format_path` and P2587R3 `__cpp_lib_to_string` as C++26 (#93255) [libc++] Split up ABI and platform configuration to their own headers (#90863) [libc++][pstl] Merge all frontend functions for the PSTL (#89219) [libcxx][test][AIX] Fix the thousands_sep expectation for fr_FR locales (#92312) [libcxx] [test] Use `shlex.quote()` to fix Python 3.13 compatibility (#93376) [libc++] Remove libcxx/include/libcxx.imp Revise IDE folder structure (#89755) [libc++][test] Close LWG3045 (#93053) [libc++] Remove a few unused includes of trivially_copyable.h (#93200) [test][libcxx] Update deallocation after #90373 (#93145) [libc++] Refactor tests for std::condition_variable (#91530) Removed redundant template in '__delete_node()' member function of '__forward_list_base' and '__list_imp' classes. (#84323) [libc++][pstl] Improve exception handling (#88998) [WebAssembly] Upstream misc. EH changes (#92990) [libc++] <experimental/simd> Add copy functions for class simd/simd_mask (#78935) [libc++][vector] Inline remaining constructors filling vector with the same value (#82068) Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373) [libc++] Implement C++20 atomic_ref (#76647) [libc++] Refactor flaky tests for std::shared_lock (#91779) [libcxx] [test] Detect mingw-w64 headers compatible with C++ module builds (#92893) [libc++] LWG2381: Inconsistency in parsing floating point numbers (#77948) [libcxx] removes unnecessary traits from `has_unique_object_representations` (#69241) [libc++][z/OS] Switch to use TEST_HAS_NO_INT128 as per comment in PR 92261 (#92434) [libcxx] Add cast to avoid pointer casting warning on Windows (#92738) [libcxx] locale.cpp: Move build_name helper into unnamed namespace (#92461) [libcxx][libcxxabi] Fix build for OpenBSD (#92186) [libc++] LWG3672: `common_iterator::operator->()` should return by value (#87899) [libc++][z/OS] Correct a definition of __native_vector_size (#91995) [libc++][z/OS] Fixup two linear_congruential_engine tests (#92261) [libc++][test] `__cpp_lib_within_lifetime` -> `__cpp_lib_is_within_lifetime` (#91896) Fix typo "indicies" (#92232) [libcxx][test] Fix numpunct grouping tests on AIX (#91781) [libcxx] [test] Fix the locale ctype widen tests on AIX (#91744) [libc++] Vectorize std::mismatch with trivially equality comparable types (#87716) [libc++] Make `constexpr std::variant`. Implement P2231R1 (#83335) [libc++][doc] Updates Spaceship status page. [libc++][ASan] Fix std::basic_string trait type (#91590) [libc++][test] Fixes constexpr char_traits. (#90981) [libc++][functional] P2944R3 (partial): Comparisons for `reference_wrapper` (`reference_wrapper` operators only) (#88384) [libc++][CI] Reenables clang-tidy. (#90077) [libc++] Implement std::gcd using the binary version (#77747) [ASan][libc++] Turn on ASan annotations for short strings (#79536) [AIX][libc++] Enable clang_modules_include.gen.py tests (#90971) [libc++] Rename _LIBCPP_INTRODUCED_foo_MARKUP to _LIBCPP_INTRODUCED_foo_ATTRIBUTE (#91269) [libc++] Fix P1206R7 feature test macros (#90914) [libc++] Adjust some of the [rand.dist] critical values that are too strict (#88669) [libc++][modules] Uses _LIBCPP_USING_IF_EXISTS. (#90409) Bump actions runner image used for libc++'s builders. [libcxx] Align `__recommend() + 1` by __endian_factor (#90292) [libc++] Granularize <ostream> (#85537) [libc++] Remove a few __has_foo defines in __config (#90511) [libc++] Remove _LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS (#90512) [libcxx][ci] In picolib build, ask clang for the normalised triple (#90722) [libc++][ranges] Implement LWG4053 and LWG4054 (#88612) [libc++] Some tests are missing include for `numeric_limits` (#90345) [libc++] Mark scoped_lock and unique_lock constructors as [[nodiscard]] (#89397) [libc++] Improve libc++ tests when using optimizations (#88897) [libc++][modules] Enable installation by default. (#90094) [libc++][format] Improves escaping performance. (#88533) [libcxx] Remove empty ~__no_destroy (#89882) [libc++][ranges] Exports operator|. (#90071) [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (#89446) [libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed (#87964) [clang] Enable sized deallocation by default in C++14 onwards (#83774) [libc++][format] Improves escaping. (#88283) [libc++] Implement LWG4023 (#87513) [libc++] Reformulate availability in terms of LLVM releases (#87563) [libc++] Reorganize the std::variant macros (#89419) [libc++][format] Adds an escaped output benchmark. (#88020) [libc++] Makes saturation functions privately available. (#89503) [libcxx] [modules] Add _LIBCPP_USING_IF_EXISTS on aligned_alloc (#89827) [libc++][TZDB] Fixes reverse time lookups. (#89502) [libc++][doc] Updates module build instructions. (#89413) [libc++][chrono] Fixes format output of negative values. (#89408) [libc++][ranges] export `std::ranges::range_adaptor_closure` (#89793) [libc++][ranges] P2387R3: Pipe support for user-defined range adaptors (#89148) [libc++] Add some private headers to libcxx.imp (#89568) [libc++] Remove _LIBCPP_DISABLE_NODISCARD_EXTENSIONS and refactor the tests (#87094) [libc++] Remove stray CMake install step for modulemap file (#89394) [libc++] Don't commit libcxx.imp (#89391) [libc++] Removes a Clang 16 Windows workaround. (#88560) [libc++][TZDB] Renames incomplete. (#89250) [libc++] Optimize char_traits a bit (#72799) [libc++] Fix usage of 'exclude_from_explicit_instantiation' attribute on local class members (#89377) linear_congruential_engine: add using more precision to prevent overflow (#81583) CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE (#89234) [libc++][TZDB] Adds local_info formatter. (#86256) [libc++][pstl] Move the CPU algorithm implementations to __pstl (#89109) [libc++][TZDB] Adds sys_info formatter. (#85896) [libc++][pstl] Promote CPU backends to top-level backends (#88968) [libc++][chrono] Improves date formatting. (#86127) [libc++] Add missing iterator requirement checks in the PSTL (#88127) [libc++][TZDB] Improves time zone format specifiers. (#85797) [libc++][chrono] Disables a test. [libc++][doc] Documents -DLIBCXX_INSTALL_MODULES=ON. (#88547) [libc++][test] Removes Clang 16 validation. (#88558) [libc++] Removes deprecated _LIBCPP_ENABLE_<VERSION>_REMOVED_FEATURES macros (#88548) [libc++][modules] Removes some validation quirks. (#88031) [libc++] Deprecate the C++20 synchronization library before C++20 (#86410) [libc++] Use availability to rely on key functions for bad_expected_access and bad_function_call (#87390) [libc++] Rename __cpu_traits functions (#88741) [libc++][CI] Tests LLDB libc++ data formatters. (#88312) [libc++] Add a utility to check whether a range is valid (#87665) [libc++][PSTL] Introduce cpu traits (#88134) [libc++][RFC] Only include what is required by-version in the umbrella headers (#83740) [libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2 & Implemented P2869R3: Remove Deprecated `shared_ptr` Atomic Access APIs from C++26 (#87111) [libc++][TZDB] Removes test_indian_kerguelen test. [libc++][TZDZ] Validates the database version. [libc++] Undeprecate POSIX STREAM macros. (#88296) [libc++] Marks a variable const. (#88562) [libc++][CMake] Removes LIBCXX_ENABLE_CLANG_TIDY. (#85794) [tzdb] Replace shared_mutex with mutex. (#87929) [libc++] P3029R1: Better `mdspan`'s CTAD (#87873) [libc++][ranges] LWG3736: move_iterator missing disable_sized_sentinel_for specialization (#85611) [libc++] LWG3643: Missing `constexpr` in `std::counted_iterator` (#87901) [libcxx] applies changes regarding post-commit feedback to #75259 (#76534) [libc++] Fix -Wgnu-include-next in stddef.h (#88214) [libcxx] Use generic builtins for popcount, clz and ctz (#86563) [libc++] Adds a global private constructor tag. (#87920) [libc++] Removes Clang-16 support. (#87810) [lib++][CI] Changes bootstrap build type. (#88175) [libc++][CI] Updates Docker LLDB dependencies. (#88174) [libc++][chrono] Adds the sys_info class. (#85619) [libc++][format] Switches to Unicode 15.1. (#86543) [libc++] Avoids using ENODATA. (#86165) [libc++][TZDB] Fixes relative path resolving. (#87882) [libc++][format] adds a basic fuzzer test. (#87883) [libc++] Add test coverage for our implementation of LWG4031 (#87508) [libc++] Implement `bind_back` (#81055) [libc++][format] Fixed `println.blank_line.sh.cpp` test on llvm-clang-win-x-* configurations (#88011) [libc++][doc] Updates format status page. [libc++][format] P3142R0: Printing Blank Lines with `println` (#87277) [libc++] Optimize ranges::minmax (#87335) [libc++] Implement LWG3430 disallow implicit conversion of the source arguments to `std::filesystem::path` when constructing `std::basic_*fstream` (#85079) [libc++] P2872R3: Remove ``wstring_convert`` From C++26 (#87100) Fix issue with never-constexpr __construct_at in C++ < 20. (#87403) [libcxx] coerce formatter precision to int (#87738) [libc++][CI] Updates to Clang 19. (#85301) [libc++][chrono] Completes the tzdb class. (#82157) [libc++][oss-fuzz] Updates C++ version used. (#87531) [libc++] P2867R1: Remove Deprecated `strstream`s From C++26 (#87107) [libc++] Fix copy/pasta error in atomic tests for `atomic_compare_exchange_{weak,strong}` (#87135) [libc++] Mark some recent LWG issues and papers as done (#87502) [libc++][chrono] Loads leap-seconds.list in tzdb. (#82113) [libc++] Disables -Wweak-vtables diagnostics. (#85577) [libc++] Update status page after the Tokyo meeting (#87395) [libc++] Upstream ptrauth support in libc++ and libc++abi (#84573) [libc++] Fix tests on musl (#85085) (#86934) [libc++] Add a static_assert for a Mandates in seed_seq (#86992) [libc++][ranges] Avoid using `distance` in `ranges::contains_subrange` (#87155) [libc++] `std::ranges::advance`: avoid unneeded bounds checks when advancing iterator (#84126) ``` {% endcut %} commit_hash:45feb9db5b173f12bf29de2a3ee73006d4371a4e
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/string')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/string194
1 files changed, 98 insertions, 96 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string
index 64657021c20..74c06906174 100644
--- a/contrib/libs/cxxsupp/libcxx/include/string
+++ b/contrib/libs/cxxsupp/libcxx/include/string
@@ -575,6 +575,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
#include <__algorithm/remove_if.h>
#include <__assert>
#include <__config>
+#include <__debug_utils/sanitizers.h>
#include <__format/enable_insertable.h>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
@@ -662,7 +663,6 @@ _LIBCPP_PUSH_MACROS
#else
# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
#endif
-#define _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED false
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -736,22 +736,52 @@ public:
//
// This string implementation doesn't contain any references into itself. It only contains a bit that says whether
// it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
+#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
+ // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
+ // relocatable. Because the object's memory might be poisoned when its content
+ // is kept inside objects memory (short string optimization), instead of in allocated
+ // external memory. In such cases, the destructor is responsible for unpoisoning
+ // the memory to avoid triggering false positives.
+ // Therefore it's crucial to ensure the destructor is called.
+ using __trivially_relocatable = void;
+#else
using __trivially_relocatable = __conditional_t<
__libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value,
basic_string,
void>;
+#endif
+#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {
+ if (__libcpp_is_constant_evaluated())
+ return __ptr;
+
+ pointer volatile __copy_ptr = __ptr;
+
+ return const_cast<pointer&>(__copy_ptr);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer
+ __asan_volatile_wrapper(const_pointer const& __ptr) const {
+ if (__libcpp_is_constant_evaluated())
+ return __ptr;
+
+ const_pointer volatile __copy_ptr = __ptr;
+
+ return const_cast<const_pointer&>(__copy_ptr);
+ }
+# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR)
+#else
+# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR
+#endif
- static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array");
- static_assert((is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout");
- static_assert((is_trivial<value_type>::value), "Character type of basic_string must be trivial");
- static_assert((is_same<_CharT, typename traits_type::char_type>::value),
+ static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");
+ static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");
+ static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial");
+ static_assert(is_same<_CharT, typename traits_type::char_type>::value,
"traits_type::char_type must be the same type as CharT");
- static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ static_assert(is_same<typename allocator_type::value_type, value_type>::value,
"Allocator::value_type must be same type as value_type");
-
- static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
- "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
- "original allocator");
+ static_assert(__check_valid_allocator<allocator_type>::value, "");
#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
typedef pointer iterator;
@@ -840,23 +870,9 @@ private:
static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
- union __ulx {
- __long __lx;
- __short __lxx;
- };
-
- enum { __n_words = sizeof(__ulx) / sizeof(size_type) };
-
- struct __raw {
- size_type __words[__n_words];
- };
-
- struct __rep {
- union {
- __short __s;
- __long __l;
- __raw __r;
- };
+ union __rep {
+ __short __s;
+ __long __l;
};
__compressed_pair<__rep, allocator_type> __r_;
@@ -1083,8 +1099,8 @@ public:
__enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
!__is_same_uncvref<_Tp, basic_string>::value,
int> = 0>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(
- const _Tp& __t, const allocator_type& __a)
+ _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
: __r_(__default_init_tag(), __a) {
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
@@ -1151,8 +1167,8 @@ public:
}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(basic_string&& __str)
- _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
__move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
return *this;
}
@@ -1261,7 +1277,7 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
+ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
return size() == 0;
}
@@ -1335,8 +1351,8 @@ public:
int> = 0>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
- basic_string&
- append(const _Tp& __t, size_type __pos, size_type __n = npos);
+ basic_string&
+ append(const _Tp& __t, size_type __pos, size_type __n = npos);
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);
@@ -1427,8 +1443,8 @@ public:
return *this = __str;
}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(basic_string&& __str)
- _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
+ assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
*this = std::move(__str);
return *this;
}
@@ -1637,7 +1653,7 @@ public:
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
- _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }
@@ -1913,16 +1929,18 @@ private:
__r_.first().__l.__data_ = __p;
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT {
- return __r_.first().__l.__data_;
+ return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_);
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT {
- return __r_.first().__l.__data_;
+ return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_);
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_short_pointer() _NOEXCEPT {
- return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer
+ __get_short_pointer() _NOEXCEPT {
+ return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]));
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_short_pointer() const _NOEXCEPT {
- return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer
+ __get_short_pointer() const _NOEXCEPT {
+ return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]));
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT {
return __is_long() ? __get_long_pointer() : __get_short_pointer();
@@ -1937,29 +1955,21 @@ private:
(void)__old_mid;
(void)__new_mid;
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
- const void* __begin = data();
- const void* __end = data() + capacity() + 1;
- if (__asan_annotate_container_with_allocator<allocator_type>::value && !__libcpp_is_constant_evaluated())
- __sanitizer_annotate_contiguous_container(__begin, __end, __old_mid, __new_mid);
+ std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);
#endif
}
- // ASan: short string is poisoned if and only if this function returns true.
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __asan_short_string_is_annotated() const _NOEXCEPT {
- return _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED && !__libcpp_is_constant_evaluated();
- }
-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {
(void)__current_size;
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
- if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
+ if (!__libcpp_is_constant_evaluated())
__annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
#endif
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
- if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
+ if (!__libcpp_is_constant_evaluated())
__annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
#endif
}
@@ -1967,7 +1977,7 @@ private:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {
(void)__n;
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
- if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
+ if (!__libcpp_is_constant_evaluated())
__annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
#endif
}
@@ -1975,7 +1985,7 @@ private:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
(void)__old_size;
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
- if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
+ if (!__libcpp_is_constant_evaluated())
__annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
#endif
}
@@ -1989,10 +1999,10 @@ private:
if (__s < __min_cap) {
return static_cast<size_type>(__min_cap) - 1;
}
- const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1;
+ const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor;
size_type __guess = __align_it<__boundary>(__s + 1) - 1;
if (__guess == __min_cap)
- ++__guess;
+ __guess += __endian_factor;
return __guess;
}
@@ -2025,15 +2035,15 @@ private:
_LIBCPP_CONSTEXPR_SINCE_CXX20
#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI
#endif
- _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by(
- size_type __old_cap,
- size_type __delta_cap,
- size_type __old_sz,
- size_type __n_copy,
- size_type __n_del,
- size_type __n_add = 0);
+ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by(
+ size_type __old_cap,
+ size_type __delta_cap,
+ size_type __old_sz,
+ size_type __n_copy,
+ size_type __n_del,
+ size_type __n_add = 0);
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __grow_by_without_replace(
size_type __old_cap,
size_type __delta_cap,
@@ -2096,14 +2106,14 @@ private:
__copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {}
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(basic_string& __str, false_type)
- _NOEXCEPT_(__alloc_traits::is_always_equal::value);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
+ __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value);
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
__move_assign(basic_string& __str, true_type)
# if _LIBCPP_STD_VER >= 17
- _NOEXCEPT;
+ noexcept;
# else
- _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+ noexcept(is_nothrow_move_assignable<allocator_type>::value);
# endif
#endif
@@ -2199,8 +2209,8 @@ template <class _CharT,
class _Traits,
class _Allocator = allocator<_CharT>,
class = enable_if_t<__is_allocator<_Allocator>::value> >
-explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
- -> basic_string<_CharT, _Traits, _Allocator>;
+explicit basic_string(basic_string_view<_CharT, _Traits>,
+ const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>;
template <class _CharT,
class _Traits,
@@ -2435,15 +2445,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
template <class _CharT, class _Traits, class _Allocator>
void _LIBCPP_CONSTEXPR_SINCE_CXX20
#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1
- _LIBCPP_HIDE_FROM_ABI
+_LIBCPP_HIDE_FROM_ABI
#endif
- _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by(
- size_type __old_cap,
- size_type __delta_cap,
- size_type __old_sz,
- size_type __n_copy,
- size_type __n_del,
- size_type __n_add) {
+_LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by(
+ size_type __old_cap,
+ size_type __delta_cap,
+ size_type __old_sz,
+ size_type __n_copy,
+ size_type __n_del,
+ size_type __n_add) {
size_type __ms = max_size();
if (__delta_cap > __ms - __old_cap)
__throw_length_error();
@@ -2594,9 +2604,8 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
#ifndef _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
-basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
- _NOEXCEPT_(__alloc_traits::is_always_equal::value) {
+inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(
+ basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) {
if (__alloc() != __str.__alloc())
assign(__str);
else
@@ -2607,9 +2616,9 @@ template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
# if _LIBCPP_STD_VER >= 17
- _NOEXCEPT
+ noexcept
# else
- _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+ noexcept(is_nothrow_move_assignable<allocator_type>::value)
# endif
{
__annotate_delete();
@@ -3352,7 +3361,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
- _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
#endif
{
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
@@ -3748,17 +3757,10 @@ template <class _Allocator>
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT {
- size_t __lhs_sz = __lhs.size();
- if (__lhs_sz != __rhs.size())
+ size_t __sz = __lhs.size();
+ if (__sz != __rhs.size())
return false;
- const char* __lp = __lhs.data();
- const char* __rp = __rhs.data();
- if (__lhs.__is_long())
- return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0;
- for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp)
- if (*__lp != *__rp)
- return false;
- return true;
+ return char_traits<char>::compare(__lhs.data(), __rhs.data(), __sz) == 0;
}
#if _LIBCPP_STD_VER <= 17