diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2022-03-08 13:05:55 -0500 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2022-03-11 09:05:29 -0500 |
commit | 611469c5c5426c761cf02bd4bdde31890038b181 (patch) | |
tree | 8bef3a2615e79e0db20e3c7d78d9365248139ff8 /libcxx/include/string_view | |
parent | 237df15c089d4d66ced7c5ba3b91eeda2d9b4fde (diff) | |
download | llvm-611469c5c5426c761cf02bd4bdde31890038b181.zip llvm-611469c5c5426c761cf02bd4bdde31890038b181.tar.gz llvm-611469c5c5426c761cf02bd4bdde31890038b181.tar.bz2 |
[libc++] Remove raw call to debug handler from __char_traits_length_checked
As a fly-by fix, also move it closer to where it is needed, and add a
comment explaining the existence of this weird function.
Differential Revision: https://reviews.llvm.org/D121231
Diffstat (limited to 'libcxx/include/string_view')
-rw-r--r-- | libcxx/include/string_view | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libcxx/include/string_view b/libcxx/include/string_view index dd9239a..5caa4c4 100644 --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -235,6 +235,15 @@ typedef basic_string_view<char32_t> u32string_view; typedef basic_string_view<wchar_t> wstring_view; #endif +// TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in +// string_view constructors. This can be refactored when this exact form isn't needed anymore. +template <class _Traits> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT { + // This needs to be a single statement for C++11 constexpr + return _LIBCPP_ASSERT(__s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"), _Traits::length(__s); +} + template<class _CharT, class _Traits> class _LIBCPP_PREFERRED_NAME(string_view) |