aboutsummaryrefslogtreecommitdiff
path: root/lib/libcxx/src/string.cpp
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-02-05 10:50:09 +0100
committerAlex Rønne Petersen <alex@alexrp.com>2025-04-04 06:08:09 +0200
commit156ab8750056c3ff440af0937806d8cdb2623816 (patch)
tree26956c58e4d169279885ab94d479f8b9f4285872 /lib/libcxx/src/string.cpp
parent7ab01c9a42fa0262d67d9ff1a0ecde24fb7031e7 (diff)
downloadzig-156ab8750056c3ff440af0937806d8cdb2623816.tar.gz
zig-156ab8750056c3ff440af0937806d8cdb2623816.zip
libcxx: Update to Clang 20.
See: * https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319 * https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701 We're dropping support for C++03 for Zig due to the first change; it would be insane to ship 1018 duplicate header files just for this outdated use case. As a result of the second change, I had to bring in a subset of the headers from llvm-libc since libc++ now depends on these. Hopefully we can continue to get away with not copying the entirety of llvm-libc.
Diffstat (limited to 'lib/libcxx/src/string.cpp')
-rw-r--r--lib/libcxx/src/string.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/libcxx/src/string.cpp b/lib/libcxx/src/string.cpp
index cf07b3ef1e..dc16ce781f 100644
--- a/lib/libcxx/src/string.cpp
+++ b/lib/libcxx/src/string.cpp
@@ -14,7 +14,7 @@
#include <stdexcept>
#include <string>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -28,8 +28,8 @@ struct __basic_string_common;
// The struct isn't declared anymore in the headers. It's only here for ABI compatibility.
template <>
struct __basic_string_common<true> {
- _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
- _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
+ [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
+ [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
};
void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); }
@@ -40,12 +40,12 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou
#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# if _LIBCPP_HAS_WIDE_CHARACTERS
_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
# endif
#else
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# if _LIBCPP_HAS_WIDE_CHARACTERS
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
# endif
#endif
@@ -115,7 +115,7 @@ inline unsigned long long as_integer(const string& func, const string& s, size_t
return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
// wstring
template <>
inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) {
@@ -145,7 +145,7 @@ template <>
inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);
}
-#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#endif // _LIBCPP_HAS_WIDE_CHARACTERS
// as_float
@@ -184,7 +184,7 @@ inline long double as_float(const string& func, const string& s, size_t* idx) {
return as_float_helper<long double>(func, s, idx, strtold);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
template <>
inline float as_float(const string& func, const wstring& s, size_t* idx) {
return as_float_helper<float>(func, s, idx, wcstof);
@@ -199,7 +199,7 @@ template <>
inline long double as_float(const string& func, const wstring& s, size_t* idx) {
return as_float_helper<long double>(func, s, idx, wcstold);
}
-#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#endif // _LIBCPP_HAS_WIDE_CHARACTERS
} // unnamed namespace
@@ -223,7 +223,7 @@ double stod(const string& str, size_t* idx) { return as_float<double>("stod", st
long double stold(const string& str, size_t* idx) { return as_float<long double>("stold", str, idx); }
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
int stoi(const wstring& str, size_t* idx, int base) { return as_integer<int>("stoi", str, idx, base); }
long stol(const wstring& str, size_t* idx, int base) { return as_integer<long>("stol", str, idx, base); }
@@ -243,7 +243,7 @@ float stof(const wstring& str, size_t* idx) { return as_float<float>("stof", str
double stod(const wstring& str, size_t* idx) { return as_float<double>("stod", str, idx); }
long double stold(const wstring& str, size_t* idx) { return as_float<long double>("stold", str, idx); }
-#endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS
+#endif // _LIBCPP_HAS_WIDE_CHARACTERS
// to_string
@@ -283,7 +283,7 @@ struct initial_string<string> {
}
};
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
template <>
struct initial_string<wstring> {
wstring operator()() const {
@@ -302,7 +302,7 @@ inline wide_printf get_swprintf() {
return static_cast<int(__cdecl*)(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...)>(_snwprintf);
# endif
}
-#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#endif // _LIBCPP_HAS_WIDE_CHARACTERS
template <typename S, typename V>
S i_to_string(V v) {
@@ -325,7 +325,7 @@ string to_string(unsigned val) { return i_to_string< string>(val); }
string to_string(unsigned long val) { return i_to_string< string>(val); }
string to_string(unsigned long long val) { return i_to_string< string>(val); }
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
wstring to_wstring(int val) { return i_to_string<wstring>(val); }
wstring to_wstring(long val) { return i_to_string<wstring>(val); }
wstring to_wstring(long long val) { return i_to_string<wstring>(val); }
@@ -338,7 +338,7 @@ string to_string(float val) { return as_string(snprintf, initial_string< string>
string to_string(double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
string to_string(long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#if _LIBCPP_HAS_WIDE_CHARACTERS
wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); }