diff --git a/libcxx/include/__string/extern_template_lists.h b/libcxx/include/__string/extern_template_lists.h --- a/libcxx/include/__string/extern_template_lists.h +++ b/libcxx/include/__string/extern_template_lists.h @@ -28,34 +28,34 @@ // functions supporting new c++ version / API changes. Typically entries // must never be removed from the stable list. #define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const* _Nullable, size_type)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const* _Nonnull, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const* _Null_unspecified, size_type, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const* _Nonnull)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const* _Nonnull, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const* _Nonnull, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ + _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const* _Null_unspecified, size_type)) \ _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const* _Null_unspecified, size_type)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const* _Nonnull, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const* _Nullable, size_type)) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const* _Nullable, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type* _Null_unspecified, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const* _Nonnull)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const* _Nonnull, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ + _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const* _Null_unspecified)) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ @@ -63,15 +63,15 @@ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ + _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const* _Nonnull) const) \ + _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const* _Nonnull) const) \ _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const* _Nonnull)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const* _Nonnull, size_type, size_type) const) \ _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ + _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const* _Nullable, size_type) const) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ + _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const* _Nonnull)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -610,7 +610,7 @@ template _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); +operator+(const _CharT* _Null_unspecified __x, const basic_string<_CharT,_Traits,_Allocator>& __y); template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -620,14 +620,14 @@ template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); +operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* _Null_unspecified __y); template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); -extern template _LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&); +extern template _LIBCPP_FUNC_VIS string operator+, allocator >(char const* _Nonnull, string const&); template struct __string_is_trivial_iterator : public false_type {}; @@ -875,7 +875,7 @@ #endif // _LIBCPP_CXX03_LANG template ::value, nullptr_t> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _Nonnull __s) : __r_(__default_init_tag(), __default_init_tag()) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); @@ -883,13 +883,13 @@ } template ::value, nullptr_t> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _Nonnull __s, const _Allocator& __a); #if _LIBCPP_STD_VER > 20 basic_string(nullptr_t) = delete; #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _Nullable __s, size_type __n) : __r_(__default_init_tag(), __default_init_tag()) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); @@ -897,7 +897,7 @@ } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) + basic_string(const _CharT* _Nullable __s, size_type __n, const _Allocator& __a) : __r_(__default_init_tag(), __a) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); @@ -995,7 +995,7 @@ basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());} #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string& operator=(const value_type* __s) {return assign(__s);} + basic_string& operator=(const value_type* _Nonnull __s) {return assign(__s);} #if _LIBCPP_STD_VER > 20 basic_string& operator=(nullptr_t) = delete; #endif @@ -1094,7 +1094,7 @@ __self_view __sv = __t; return append(__sv); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* __s) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* _Nonnull __s) { return append(__s); } @@ -1130,8 +1130,8 @@ 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); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _Nullable __s, size_type __n); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _Nonnull __s); _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1198,8 +1198,8 @@ basic_string& > assign(const _Tp & __t, size_type __pos, size_type __n=npos); - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n); - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* _Nullable __s, size_type __n); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* _Nonnull __s); _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1245,8 +1245,8 @@ insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* _Nullable __s, size_type __n); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* _Nonnull __s); _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1301,8 +1301,8 @@ > replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); + basic_string& replace(size_type __pos, size_type __n1, const value_type* _Nullable __s, size_type __n2); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, const value_type* _Nonnull __s); _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); @@ -1317,9 +1317,9 @@ replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); + basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* _Null_unspecified __s, size_type __n); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); + basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* _Null_unspecified __s); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); template @@ -1336,7 +1336,7 @@ {return replace(__i1, __i2, __il.begin(), __il.end());} #endif // _LIBCPP_CXX03_LANG - _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; + _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* _Null_unspecified __s, size_type __n, size_type __pos = 0) const; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string substr(size_type __pos = 0, size_type __n = npos) const; @@ -1350,12 +1350,12 @@ #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - const value_type* c_str() const _NOEXCEPT {return data();} + const value_type* _Nonnull c_str() const _NOEXCEPT {return data();} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());} + const value_type* _Nonnull data() const _NOEXCEPT {return std::__to_address(__get_pointer());} #if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());} + value_type* _Nonnull data() _NOEXCEPT {return std::__to_address(__get_pointer());} #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1373,9 +1373,9 @@ > find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + size_type find(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + size_type find(const value_type* _Nonnull __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1390,9 +1390,9 @@ > rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + size_type rfind(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + size_type rfind(const value_type* _Nonnull __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1407,9 +1407,9 @@ > find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + size_type find_first_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + size_type find_first_of(const value_type* _Nonnull __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; @@ -1425,9 +1425,9 @@ > find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + size_type find_last_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + size_type find_last_of(const value_type* _Nonnull __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; @@ -1443,9 +1443,9 @@ > find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + size_type find_first_not_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + size_type find_first_not_of(const value_type* _Nonnull __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; @@ -1461,9 +1461,9 @@ > find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + size_type find_last_not_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + size_type find_last_not_of(const value_type* _Nonnull __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; @@ -1502,10 +1502,10 @@ int > compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; - _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const; + _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* _Nonnull __s) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* _Nonnull __s) const; _LIBCPP_CONSTEXPR_SINCE_CXX20 - int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; + int compare(size_type __pos1, size_type __n1, const value_type* _Nullable __s, size_type __n2) const; #if _LIBCPP_STD_VER > 17 constexpr _LIBCPP_HIDE_FROM_ABI @@ -1517,7 +1517,7 @@ { return !empty() && _Traits::eq(front(), __c); } constexpr _LIBCPP_HIDE_FROM_ABI - bool starts_with(const value_type* __s) const noexcept + bool starts_with(const value_type* _Nonnull __s) const noexcept { return starts_with(__self_view(__s)); } constexpr _LIBCPP_HIDE_FROM_ABI @@ -1529,7 +1529,7 @@ { return !empty() && _Traits::eq(back(), __c); } constexpr _LIBCPP_HIDE_FROM_ABI - bool ends_with(const value_type* __s) const noexcept + bool ends_with(const value_type* _Nonnull __s) const noexcept { return ends_with(__self_view(__s)); } #endif @@ -1543,7 +1543,7 @@ { return __self_view(data(), size()).contains(__c); } constexpr _LIBCPP_HIDE_FROM_ABI - bool contains(const value_type* __s) const + bool contains(const value_type* _Nonnull __s) const { return __self_view(data(), size()).contains(__s); } #endif @@ -1716,9 +1716,9 @@ } inline _LIBCPP_CONSTEXPR_SINCE_CXX20 - void __init(const value_type* __s, size_type __sz, size_type __reserve); + void __init(const value_type* _Null_unspecified __s, size_type __sz, size_type __reserve); inline _LIBCPP_CONSTEXPR_SINCE_CXX20 - void __init(const value_type* __s, size_type __sz); + void __init(const value_type* _Null_unspecified __s, size_type __sz); inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c); @@ -1730,7 +1730,7 @@ // to call the __init() functions as those are marked as inline which may // result in over-aggressive inlining by the compiler, where our aim is // to only inline the fast path code directly in the ctor. - _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init_copy_ctor_external(const value_type* __s, size_type __sz); + _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init_copy_ctor_external(const value_type* _Nonnull __s, size_type __sz); template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -1754,13 +1754,13 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, - size_type __n_add, const value_type* __p_new_stuff); + size_type __n_add, const value_type* _Null_unspecified __p_new_stuff); // __assign_no_alias is invoked for assignment operations where we // have proof that the input does not alias the current instance. // For example, operator=(basic_string) performs a 'self' check. template - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_no_alias(const value_type* __s, size_type __n); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_no_alias(const value_type* _Null_unspecified __s, size_type __n); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos); @@ -1838,11 +1838,11 @@ _NOEXCEPT {} - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s); - _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s, size_type __n); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* _Null_unspecified __s); + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* _Null_unspecified __s, size_type __n); // Assigns the value in __s, guaranteed to be __n < __min_cap in length. - inline basic_string& __assign_short(const value_type* __s, size_type __n) { + inline basic_string& __assign_short(const value_type* _Null_unspecified __s, size_type __n) { pointer __p = __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer()); @@ -1852,7 +1852,7 @@ } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string& __null_terminate_at(value_type* __p, size_type __newsz) { + basic_string& __null_terminate_at(value_type* _Nonnull __p, size_type __newsz) { __set_size(__newsz); __invalidate_iterators_past(__newsz); traits_type::assign(__p[__newsz], value_type()); @@ -1882,9 +1882,9 @@ } friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const basic_string&); - friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const value_type*, const basic_string&); + friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const value_type* _Null_unspecified, const basic_string&); friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(value_type, const basic_string&); - friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const value_type*); + friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const value_type* _Null_unspecified); friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, value_type); }; @@ -1965,7 +1965,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 -void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, +void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* _Null_unspecified __s, size_type __sz, size_type __reserve) { @@ -1995,7 +1995,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 void -basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) +basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* _Null_unspecified __s, size_type __sz) { if (__libcpp_is_constant_evaluated()) __r_.first() = __rep(); @@ -2023,7 +2023,7 @@ template template _LIBCPP_CONSTEXPR_SINCE_CXX20 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) +basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* _Nonnull __s, const _Allocator& __a) : __r_(__default_init_tag(), __a) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); @@ -2061,7 +2061,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( - const value_type* __s, size_type __sz) { + const value_type* _Nonnull __s, size_type __sz) { if (__libcpp_is_constant_evaluated()) __r_.first() = __rep(); @@ -2259,7 +2259,7 @@ void basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace (size_type __old_cap, size_type __delta_cap, size_type __old_sz, - size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff) + size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* _Null_unspecified __p_new_stuff) { size_type __ms = max_size(); if (__delta_cap > __ms - __old_cap - 1) @@ -2328,7 +2328,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( - const value_type* __s, size_type __n) { + const value_type* _Null_unspecified __s, size_type __n) { size_type __cap = __is_short ? static_cast(__min_cap) : __get_long_cap(); if (__n < __cap) { pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); @@ -2347,7 +2347,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_external( - const value_type* __s, size_type __n) { + const value_type* _Null_unspecified __s, size_type __n) { size_type __cap = capacity(); if (__cap >= __n) { value_type* __p = std::__to_address(__get_pointer()); @@ -2363,7 +2363,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) +basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* _Nullable __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); return (__builtin_constant_p(__n) && __fits_in_sso(__n)) @@ -2571,14 +2571,14 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { +basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* _Null_unspecified __s) { return __assign_external(__s, traits_type::length(__s)); } template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) +basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* _Nonnull __s) { _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); return __builtin_constant_p(*__s) @@ -2592,7 +2592,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) +basic_string<_CharT, _Traits, _Allocator>::append(const value_type* _Nullable __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); size_type __cap = capacity(); @@ -2763,7 +2763,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) +basic_string<_CharT, _Traits, _Allocator>::append(const value_type* _Nonnull __s) { _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); return append(__s, traits_type::length(__s)); @@ -2774,7 +2774,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* _Nullable __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); size_type __sz = size(); @@ -2930,7 +2930,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* _Nonnull __s) { _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); return insert(__pos, __s, traits_type::length(__s)); @@ -2985,7 +2985,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) +basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* _Nullable __s, size_type __n2) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); @@ -3122,7 +3122,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) +basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* _Nonnull __s) { _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s)); @@ -3140,7 +3140,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) +basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* _Null_unspecified __s, size_type __n) { return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s, __n); } @@ -3148,7 +3148,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) +basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* _Null_unspecified __s) { return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s); } @@ -3475,7 +3475,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const +basic_string<_CharT, _Traits, _Allocator>::copy(value_type* _Null_unspecified __s, size_type __n, size_type __pos) const { size_type __sz = size(); if (__pos > __sz) @@ -3532,7 +3532,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3570,7 +3570,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find(const value_type* _Nonnull __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); @@ -3593,7 +3593,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3631,7 +3631,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* _Nonnull __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); @@ -3654,7 +3654,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3692,7 +3692,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* _Nonnull __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); @@ -3714,7 +3714,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3752,7 +3752,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* _Nonnull __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); @@ -3774,7 +3774,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3812,7 +3812,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _Nonnull __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); @@ -3835,7 +3835,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* _Nullable __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3873,7 +3873,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* _Nonnull __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); @@ -3930,7 +3930,7 @@ int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, - const value_type* __s, + const value_type* _Nullable __s, size_type __n2) const { _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); @@ -4009,7 +4009,7 @@ template _LIBCPP_CONSTEXPR_SINCE_CXX20 int -basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT +basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* _Nonnull __s) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(0, npos, __s, traits_type::length(__s)); @@ -4020,7 +4020,7 @@ int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, - const value_type* __s) const + const value_type* _Nonnull __s) const { _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s)); @@ -4115,7 +4115,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT + const _CharT* _Nonnull __rhs) _NOEXCEPT { #if _LIBCPP_STD_VER > 17 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs); @@ -4139,7 +4139,7 @@ template _LIBCPP_HIDE_FROM_ABI constexpr auto -operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { +operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* _Nonnull __rhs) { return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs); } @@ -4313,7 +4313,7 @@ template _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) +operator+(const _CharT* _Null_unspecified __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; auto __lhs_sz = _Traits::length(__lhs); @@ -4348,7 +4348,7 @@ template inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* _Null_unspecified __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; typename _String::size_type __lhs_sz = __lhs.size(); @@ -4409,7 +4409,7 @@ template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) +operator+(const _CharT* _Null_unspecified __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) { return std::move(__rhs.insert(0, __lhs)); } @@ -4426,7 +4426,7 @@ template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* _Null_unspecified __rhs) { return std::move(__lhs.append(__rhs)); } @@ -4454,15 +4454,15 @@ __lhs.swap(__rhs); } -_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* _Nullable __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = nullptr); -_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr); -_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr); +_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* _Nullable __idx = nullptr); +_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* _Nullable __idx = nullptr); +_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* _Nullable __idx = nullptr); _LIBCPP_FUNC_VIS string to_string(int __val); _LIBCPP_FUNC_VIS string to_string(unsigned __val); @@ -4475,15 +4475,15 @@ _LIBCPP_FUNC_VIS string to_string(long double __val); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* _Nullable __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* _Nullable __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = nullptr); -_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr); -_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr); +_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* _Nullable __idx = nullptr); +_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* _Nullable __idx = nullptr); +_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* _Nullable __idx = nullptr); _LIBCPP_FUNC_VIS wstring to_wstring(int __val); _LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); @@ -4626,14 +4626,14 @@ inline namespace string_literals { inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string operator "" s( const char *__str, size_t __len ) + basic_string operator "" s( const char* _Nullable __str, size_t __len ) { return basic_string (__str, __len); } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string operator "" s( const wchar_t *__str, size_t __len ) + basic_string operator "" s( const wchar_t* _Nullable __str, size_t __len ) { return basic_string (__str, __len); } @@ -4641,20 +4641,20 @@ #ifndef _LIBCPP_HAS_NO_CHAR8_T inline _LIBCPP_HIDE_FROM_ABI constexpr - basic_string operator "" s(const char8_t *__str, size_t __len) + basic_string operator "" s(const char8_t* _Nullable __str, size_t __len) { return basic_string (__str, __len); } #endif inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string operator "" s( const char16_t *__str, size_t __len ) + basic_string operator "" s( const char16_t* _Nullable __str, size_t __len ) { return basic_string (__str, __len); } inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 - basic_string operator "" s( const char32_t *__str, size_t __len ) + basic_string operator "" s( const char32_t* _Nullable __str, size_t __len ) { return basic_string (__str, __len); } diff --git a/libcxx/test/libcxx/strings/basic.string/string.cons/ptr.nonnull.verify.cpp b/libcxx/test/libcxx/strings/basic.string/string.cons/ptr.nonnull.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/strings/basic.string/string.cons/ptr.nonnull.verify.cpp @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +#include + +void func() { + std::string s(static_cast(nullptr)); // Null passed to a callee that requires a non-null argument +} diff --git a/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp @@ -52,6 +52,7 @@ { typedef test_allocator A; + test(static_cast(nullptr), 0); test("", 0); test("", 0, A(2));