aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__configuration/availability.h38
-rw-r--r--libcxx/include/__exception/exception_ptr.h23
-rw-r--r--libcxx/include/__format/formatter_output.h62
-rw-r--r--libcxx/include/__new/align_val_t.h6
-rw-r--r--libcxx/include/__new/exceptions.h6
-rw-r--r--libcxx/include/string33
6 files changed, 114 insertions, 54 deletions
diff --git a/libcxx/include/__configuration/availability.h b/libcxx/include/__configuration/availability.h
index d0414ec..5433df8 100644
--- a/libcxx/include/__configuration/availability.h
+++ b/libcxx/include/__configuration/availability.h
@@ -118,14 +118,40 @@
# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable))
// LLVM 20
-// TODO: Fill this in
-# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
-# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE __attribute__((unavailable))
+//
+// Note that versions for most Apple OSes were bumped forward and aligned in that release.
+# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 260000) || \
+ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 260000) || \
+ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 260000) || \
+ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 260000) || \
+ (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 100000)
+# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
+# else
+# define _LIBCPP_INTRODUCED_IN_LLVM_20 1
+# endif
+# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE \
+ __attribute__((availability(macos, strict, introduced = 26.0))) \
+ __attribute__((availability(ios, strict, introduced = 26.0))) \
+ __attribute__((availability(tvos, strict, introduced = 26.0))) \
+ __attribute__((availability(watchos, strict, introduced = 26.0))) \
+ __attribute__((availability(bridgeos, strict, introduced = 10.0)))
// LLVM 19
-// TODO: Fill this in
-# define _LIBCPP_INTRODUCED_IN_LLVM_19 0
-# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable))
+# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150400) || \
+ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 180400) || \
+ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 180400) || \
+ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 110400) || \
+ (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90400)
+# define _LIBCPP_INTRODUCED_IN_LLVM_19 0
+# else
+# define _LIBCPP_INTRODUCED_IN_LLVM_19 1
+# endif
+# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE \
+ __attribute__((availability(macos, strict, introduced = 15.4))) \
+ __attribute__((availability(ios, strict, introduced = 18.4))) \
+ __attribute__((availability(tvos, strict, introduced = 18.4))) \
+ __attribute__((availability(watchos, strict, introduced = 11.4))) \
+ __attribute__((availability(bridgeos, strict, introduced = 9.4)))
// LLVM 18
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 796fa92..e78126e 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -16,6 +16,8 @@
#include <__memory/construct_at.h>
#include <__type_traits/decay.h>
#include <__type_traits/is_pointer.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
#include <cstdlib>
#include <typeinfo>
@@ -23,6 +25,9 @@
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
#ifndef _LIBCPP_ABI_MICROSOFT
# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
@@ -57,6 +62,8 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
#ifndef _LIBCPP_ABI_MICROSOFT
+inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT;
+
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
@@ -75,7 +82,15 @@ public:
_LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
exception_ptr(const exception_ptr&) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI exception_ptr(exception_ptr&& __other) _NOEXCEPT : __ptr_(__other.__ptr_) {
+ __other.__ptr_ = nullptr;
+ }
exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI exception_ptr& operator=(exception_ptr&& __other) _NOEXCEPT {
+ exception_ptr __tmp(std::move(__other));
+ std::swap(__tmp, *this);
+ return *this;
+ }
~exception_ptr() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __ptr_ != nullptr; }
@@ -88,10 +103,16 @@ public:
return !(__x == __y);
}
+ friend _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT;
+
friend _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
};
+inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT {
+ std::swap(__x.__ptr_, __y.__ptr_);
+}
+
# if _LIBCPP_HAS_EXCEPTIONS
# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
template <class _Ep>
@@ -201,4 +222,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
#endif // _LIBCPP_ABI_MICROSOFT
_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
diff --git a/libcxx/include/__format/formatter_output.h b/libcxx/include/__format/formatter_output.h
index d53b6ce..63dd7fc 100644
--- a/libcxx/include/__format/formatter_output.h
+++ b/libcxx/include/__format/formatter_output.h
@@ -151,45 +151,41 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value)
}
}
-# if _LIBCPP_HAS_UNICODE
template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
- requires(same_as<_CharT, char>)
_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
- std::size_t __bytes = std::countl_one(static_cast<unsigned char>(__value.__data[0]));
- if (__bytes == 0)
- return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
-
- for (size_t __i = 0; __i < __n; ++__i)
- __out_it = __formatter::__copy(
- std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + __bytes, std::move(__out_it));
- return __out_it;
-}
-
+# if _LIBCPP_HAS_UNICODE
+ if constexpr (same_as<_CharT, char>) {
+ std::size_t __bytes = std::countl_one(static_cast<unsigned char>(__value.__data[0]));
+ if (__bytes == 0)
+ return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
+
+ for (size_t __i = 0; __i < __n; ++__i)
+ __out_it = __formatter::__copy(
+ std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + __bytes, std::move(__out_it));
+ return __out_it;
# if _LIBCPP_HAS_WIDE_CHARACTERS
-template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
- requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)
-_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
- if (!__unicode::__is_high_surrogate(__value.__data[0]))
- return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
-
- for (size_t __i = 0; __i < __n; ++__i)
- __out_it = __formatter::__copy(
- std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + 2, std::move(__out_it));
- return __out_it;
-}
-
-template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
- requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4)
-_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
- return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
-}
+ } else if constexpr (same_as<_CharT, wchar_t>) {
+ if constexpr (sizeof(wchar_t) == 2) {
+ if (!__unicode::__is_high_surrogate(__value.__data[0]))
+ return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
+
+ for (size_t __i = 0; __i < __n; ++__i)
+ __out_it = __formatter::__copy(
+ std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + 2, std::move(__out_it));
+ return __out_it;
+ } else if constexpr (sizeof(wchar_t) == 4) {
+ return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
+ } else {
+ static_assert(false, "expected sizeof(wchar_t) to be 2 or 4");
+ }
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
-# else // _LIBCPP_HAS_UNICODE
-template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
-_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
+ } else {
+ static_assert(false, "Unexpected CharT");
+ }
+# else // _LIBCPP_HAS_UNICODE
return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
+# endif // _LIBCPP_HAS_UNICODE
}
-# endif // _LIBCPP_HAS_UNICODE
/// Writes the input to the output with the required padding.
///
diff --git a/libcxx/include/__new/align_val_t.h b/libcxx/include/__new/align_val_t.h
index 03ab7cb..d8ce528 100644
--- a/libcxx/include/__new/align_val_t.h
+++ b/libcxx/include/__new/align_val_t.h
@@ -16,6 +16,12 @@
# pragma GCC system_header
#endif
+// <vcruntime_exception.h> defines its own std::align_val_t type,
+// which we use in order to be ABI-compatible with other STLs on Windows.
+#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && defined(_LIBCPP_ABI_VCRUNTIME)
+# include <vcruntime_new.h>
+#endif
+
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME)
# ifndef _LIBCPP_CXX03_LANG
diff --git a/libcxx/include/__new/exceptions.h b/libcxx/include/__new/exceptions.h
index 8695181..483e5e3 100644
--- a/libcxx/include/__new/exceptions.h
+++ b/libcxx/include/__new/exceptions.h
@@ -17,6 +17,12 @@
# pragma GCC system_header
#endif
+// <vcruntime_exception.h> defines its own std::bad_alloc type,
+// which we use in order to be ABI-compatible with other STLs on Windows.
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+# include <vcruntime_exception.h>
+#endif
+
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
#if !defined(_LIBCPP_ABI_VCRUNTIME)
diff --git a/libcxx/include/string b/libcxx/include/string
index 8f80afbc..ede4246 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -644,6 +644,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
# include <__utility/forward.h>
# include <__utility/is_pointer_in_range.h>
# include <__utility/move.h>
+# include <__utility/no_destroy.h>
# include <__utility/scope_guard.h>
# include <__utility/swap.h>
# include <climits>
@@ -914,6 +915,11 @@ private:
union __rep {
__short __s;
__long __l;
+
+ __rep() = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__short __r) : __s(__r) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__long __r) : __l(__r) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__uninitialized_tag) {}
};
_LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_);
@@ -1206,7 +1212,10 @@ public:
}
# endif // _LIBCPP_CXX03_LANG
- inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() { __reset_internal_buffer(); }
+ // TODO(boomanaiden154): Once we mark this in destructors as dead on return,
+ // we can use a normal call to __reset_internal_buffer and remove the extra
+ // __rep constructor.
+ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() { __reset_internal_buffer(__rep(__uninitialized_tag())); }
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT {
return __self_view(typename __self_view::__assume_valid(), data(), size());
@@ -2259,18 +2268,12 @@ private:
return __long(__buffer, __capacity);
}
- // Deallocate the long buffer if it exists and clear the short buffer so we are an empty string
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __reset_internal_buffer() {
+ // Replace the current buffer with __new_rep. Deallocate the old long buffer if it exists.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __reset_internal_buffer(__rep __new_rep = __short()) {
__annotate_delete();
if (__is_long())
__alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
- __rep_.__s = __short();
- }
-
- // Replace the current buffer with __alloc; the first __size elements constitute a string
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __replace_internal_buffer(__long __alloc) {
- __reset_internal_buffer();
- __rep_.__l = __alloc;
+ __rep_ = __new_rep;
}
// Initialize the internal buffer to hold __size elements
@@ -2444,7 +2447,7 @@ private:
__annotate_delete();
auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
auto __alloc = __str.__alloc_;
- __replace_internal_buffer(__allocate_long_buffer(__alloc, __str.size()));
+ __reset_internal_buffer(__allocate_long_buffer(__alloc, __str.size()));
__alloc_ = std::move(__alloc);
}
}
@@ -2710,7 +2713,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
__sec_cp_sz);
__buffer.__size_ = __n_copy + __n_add + __sec_cp_sz;
traits_type::assign(__buffer.__data_[__buffer.__size_], value_type());
- __replace_internal_buffer(__buffer);
+ __reset_internal_buffer(__buffer);
}
// __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it
@@ -2746,7 +2749,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait
// This is -1 to make sure the caller sets the size properly, since old versions of this function didn't set the size
// at all.
__buffer.__size_ = -1;
- __replace_internal_buffer(__buffer);
+ __reset_internal_buffer(__buffer);
}
template <class _CharT, class _Traits, class _Allocator>
@@ -3394,7 +3397,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
__long __buffer = __allocate_long_buffer(__alloc_, __requested_capacity);
__buffer.__size_ = size();
traits_type::copy(std::__to_address(__buffer.__data_), data(), __buffer.__size_ + 1);
- __replace_internal_buffer(__buffer);
+ __reset_internal_buffer(__buffer);
}
template <class _CharT, class _Traits, class _Allocator>
@@ -3433,7 +3436,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
}
traits_type::copy(std::__to_address(__buffer.__data_), std::__to_address(__get_long_pointer()), __size + 1);
- __replace_internal_buffer(__buffer);
+ __reset_internal_buffer(__buffer);
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
return;