[libcxx-commits] [libcxxabi] [libcxx] [libc++] [libc++abi] Initialize exception directly in make_exception_ptr if __cxa_init_primary_exception is available in ABI-library (PR #65534)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 14 18:01:04 PST 2023
https://github.com/itrofimow updated https://github.com/llvm/llvm-project/pull/65534
>From 154891ffaec8c7302859b05c6efe1fd5a5ffeb2b Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 23 Aug 2023 17:05:14 +0300
Subject: [PATCH 01/66] [libcxx] [libcxxabi] don't throw+catch in
std::make_exception_ptr, if possible
Differential Revision: https://reviews.llvm.org/D158620
---
libcxx/include/__exception/exception_ptr.h | 27 +++++++++++++++++++
.../runtime/exception_pointer_cxxabi.ipp | 18 +++++++++++++
libcxxabi/include/cxxabi.h | 7 +++++
libcxxabi/src/cxa_exception.cpp | 25 ++++++++++-------
4 files changed, 68 insertions(+), 9 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 970d8196724b7c..1db0a24be22802 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -14,6 +14,8 @@
#include <__memory/addressof.h>
#include <cstddef>
#include <cstdlib>
+#include <typeinfo>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -26,6 +28,18 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
+ template <class _Ep>
+ static inline void __dest_thunk(void *__x) {
+ static_cast<_Ep*>(__x)->~_Ep();
+ }
+
+ static void *init_ex(size_t, std::type_info*, void (*)(void *)) _NOEXCEPT;
+ static void free_ex(void *) _NOEXCEPT;
+ static exception_ptr from_ex_ptr(void *__e) _NOEXCEPT;
+
+ template <class _Ep>
+ friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
+
public:
_LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
_LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
@@ -51,11 +65,24 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if defined(LIBCXX_BUILDING_LIBCXXABI)
+ using _Ep2 = typename decay<_Ep>::type;
+ void *__ex = exception_ptr::init_ex(
+ sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
+ try {
+ ::new (__ex) _Ep2(__e);
+ return exception_ptr::from_ex_ptr(__ex);
+ } catch (...) {
+ exception_ptr::free_ex(__ex);
+ return current_exception();
+ }
+# else
try {
throw __e;
} catch (...) {
return current_exception();
}
+# endif
# else
((void)__e);
std::abort();
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 33aa94502b73c9..277c5b867f679a 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -34,6 +34,24 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
+void *exception_ptr::init_ex(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept {
+ void *__ex = __cxa_allocate_exception(size);
+ (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ return __ex;
+}
+
+void exception_ptr::free_ex(void *thrown_object) noexcept {
+ __cxa_free_exception(thrown_object);
+}
+
+exception_ptr exception_ptr::from_ex_ptr(void *__e) noexcept {
+ exception_ptr ptr;
+ ptr.__ptr_ = __e;
+ __cxa_increment_exception_refcount(ptr.__ptr_);
+
+ return ptr;
+}
+
nested_exception::nested_exception() noexcept
: __ptr_(current_exception())
{
diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h
index 6f4f823bc273ff..3fae04e35c39db 100644
--- a/libcxxabi/include/cxxabi.h
+++ b/libcxxabi/include/cxxabi.h
@@ -36,6 +36,9 @@ class type_info; // forward declaration
// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
namespace __cxxabiv1 {
+
+struct __cxa_exception;
+
extern "C" {
// 2.4.2 Allocating the Exception Object
@@ -43,6 +46,10 @@ extern _LIBCXXABI_FUNC_VIS void *
__cxa_allocate_exception(size_t thrown_size) throw();
extern _LIBCXXABI_FUNC_VIS void
__cxa_free_exception(void *thrown_exception) throw();
+// This function is an llvm extension
+extern _LIBCXXABI_FUNC_VIS __cxa_exception *
+__cxa_init_primary_exception(void *object, std::type_info* tinfo,
+ void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) throw();
// 2.4.3 Throwing the Exception Object
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index f723ececfe3327..d3c445f2c10ac8 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -206,6 +206,20 @@ void __cxa_free_exception(void *thrown_object) throw() {
__aligned_free_with_fallback((void *)raw_buffer);
}
+__cxa_exception *__cxa_init_primary_exception(void *object, std::type_info* tinfo,
+ void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) throw() {
+ __cxa_exception* exception_header = cxa_exception_from_thrown_object(object);
+ exception_header->referenceCount = 0;
+ exception_header->unexpectedHandler = std::get_unexpected();
+ exception_header->terminateHandler = std::get_terminate();
+ exception_header->exceptionType = tinfo;
+ exception_header->exceptionDestructor = dest;
+ setOurExceptionClass(&exception_header->unwindHeader);
+ exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
+
+ return exception_header;
+}
+
// This function shall allocate a __cxa_dependent_exception and
// return a pointer to it. (Really to the object, not past its' end).
@@ -261,17 +275,10 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_F
__cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
#endif
__cxa_eh_globals *globals = __cxa_get_globals();
- __cxa_exception* exception_header = cxa_exception_from_thrown_object(thrown_object);
-
- exception_header->unexpectedHandler = std::get_unexpected();
- exception_header->terminateHandler = std::get_terminate();
- exception_header->exceptionType = tinfo;
- exception_header->exceptionDestructor = dest;
- setOurExceptionClass(&exception_header->unwindHeader);
- exception_header->referenceCount = 1; // This is a newly allocated exception, no need for thread safety.
globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local
- exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
+ __cxa_exception *exception_header = __cxa_init_primary_exception(thrown_object, tinfo, dest);
+ exception_header->referenceCount = 1; // This is a newly allocated exception, no need for thread safety.
#if __has_feature(address_sanitizer)
// Inform the ASan runtime that now might be a good time to clean stuff up.
>From 5e74f1ed074035e8084f44907d2c28d565696b52 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 23 Aug 2023 17:53:38 +0300
Subject: [PATCH 02/66] + clang-format
---
libcxx/include/__exception/exception_ptr.h | 22 +++++++++++-----------
libcxxabi/include/cxxabi.h | 5 ++---
libcxxabi/src/cxa_exception.cpp | 13 ++++++-------
3 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 1db0a24be22802..6ca4e9314f1bd1 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -14,8 +14,8 @@
#include <__memory/addressof.h>
#include <cstddef>
#include <cstdlib>
-#include <typeinfo>
#include <type_traits>
+#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -29,13 +29,13 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
template <class _Ep>
- static inline void __dest_thunk(void *__x) {
- static_cast<_Ep*>(__x)->~_Ep();
+ static inline void __dest_thunk(void* __x) {
+ static_cast<_Ep*>(__x)->~_Ep();
}
- static void *init_ex(size_t, std::type_info*, void (*)(void *)) _NOEXCEPT;
- static void free_ex(void *) _NOEXCEPT;
- static exception_ptr from_ex_ptr(void *__e) _NOEXCEPT;
+ static void* init_ex(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
+ static void free_ex(void*) _NOEXCEPT;
+ static exception_ptr from_ex_ptr(void* __e) _NOEXCEPT;
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
@@ -65,10 +65,10 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if defined(LIBCXX_BUILDING_LIBCXXABI)
+# if defined(LIBCXX_BUILDING_LIBCXXABI)
using _Ep2 = typename decay<_Ep>::type;
- void *__ex = exception_ptr::init_ex(
- sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
+ void* __ex =
+ exception_ptr::init_ex(sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
try {
::new (__ex) _Ep2(__e);
return exception_ptr::from_ex_ptr(__ex);
@@ -76,13 +76,13 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
exception_ptr::free_ex(__ex);
return current_exception();
}
-# else
+# else
try {
throw __e;
} catch (...) {
return current_exception();
}
-# endif
+# endif
# else
((void)__e);
std::abort();
diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h
index 3fae04e35c39db..03ec7986e20912 100644
--- a/libcxxabi/include/cxxabi.h
+++ b/libcxxabi/include/cxxabi.h
@@ -47,9 +47,8 @@ __cxa_allocate_exception(size_t thrown_size) throw();
extern _LIBCXXABI_FUNC_VIS void
__cxa_free_exception(void *thrown_exception) throw();
// This function is an llvm extension
-extern _LIBCXXABI_FUNC_VIS __cxa_exception *
-__cxa_init_primary_exception(void *object, std::type_info* tinfo,
- void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) throw();
+extern _LIBCXXABI_FUNC_VIS __cxa_exception*
+__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
// 2.4.3 Throwing the Exception Object
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index d3c445f2c10ac8..1e72d7f34f26a2 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -206,12 +206,12 @@ void __cxa_free_exception(void *thrown_object) throw() {
__aligned_free_with_fallback((void *)raw_buffer);
}
-__cxa_exception *__cxa_init_primary_exception(void *object, std::type_info* tinfo,
- void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) throw() {
+__cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo,
+ void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
__cxa_exception* exception_header = cxa_exception_from_thrown_object(object);
exception_header->referenceCount = 0;
exception_header->unexpectedHandler = std::get_unexpected();
- exception_header->terminateHandler = std::get_terminate();
+ exception_header->terminateHandler = std::get_terminate();
exception_header->exceptionType = tinfo;
exception_header->exceptionDestructor = dest;
setOurExceptionClass(&exception_header->unwindHeader);
@@ -220,7 +220,6 @@ __cxa_exception *__cxa_init_primary_exception(void *object, std::type_info* tinf
return exception_header;
}
-
// This function shall allocate a __cxa_dependent_exception and
// return a pointer to it. (Really to the object, not past its' end).
// Otherwise, it will work like __cxa_allocate_exception.
@@ -274,11 +273,11 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_F
#else
__cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
#endif
- __cxa_eh_globals *globals = __cxa_get_globals();
+ __cxa_eh_globals* globals = __cxa_get_globals();
globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local
- __cxa_exception *exception_header = __cxa_init_primary_exception(thrown_object, tinfo, dest);
- exception_header->referenceCount = 1; // This is a newly allocated exception, no need for thread safety.
+ __cxa_exception* exception_header = __cxa_init_primary_exception(thrown_object, tinfo, dest);
+ exception_header->referenceCount = 1; // This is a newly allocated exception, no need for thread safety.
#if __has_feature(address_sanitizer)
// Inform the ASan runtime that now might be a good time to clean stuff up.
>From 918a51437131ca19dfa5f100e64a45134c7e501a Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 23 Aug 2023 20:18:45 +0300
Subject: [PATCH 03/66] cleanup
---
libcxx/include/CMakeLists.txt | 1 +
libcxx/include/__exception/exception_ptr.h | 18 +-
libcxx/include/__typeinfo/typeinfo.h | 333 ++++++++++++++++++
libcxx/include/module.modulemap.in | 2 +
libcxx/include/typeinfo | 9 +-
.../runtime/exception_pointer_cxxabi.ipp | 21 +-
6 files changed, 361 insertions(+), 23 deletions(-)
create mode 100644 libcxx/include/__typeinfo/typeinfo.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 533b7ac9103ab0..5e1c606bde6b86 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -698,6 +698,7 @@ set(files
__tuple/tuple_like_ext.h
__tuple/tuple_size.h
__tuple/tuple_types.h
+ __typeinfo/typeinfo.h
__type_traits/add_const.h
__type_traits/add_cv.h
__type_traits/add_lvalue_reference.h
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 6ca4e9314f1bd1..0e5310c767cbe9 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -12,10 +12,10 @@
#include <__config>
#include <__exception/operations.h>
#include <__memory/addressof.h>
+#include <__typeinfo/typeinfo.h>
#include <cstddef>
#include <cstdlib>
#include <type_traits>
-#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,17 +28,19 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
+# if defined(LIBCXX_BUILDING_LIBCXXABI)
template <class _Ep>
static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
}
- static void* init_ex(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
- static void free_ex(void*) _NOEXCEPT;
- static exception_ptr from_ex_ptr(void* __e) _NOEXCEPT;
+ static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
+ static void __free_native_exception(void*) _NOEXCEPT;
+ static exception_ptr __from_native_exception_pointer(void* __e) _NOEXCEPT;
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
+# endif
public:
_LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
@@ -67,13 +69,13 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if defined(LIBCXX_BUILDING_LIBCXXABI)
using _Ep2 = typename decay<_Ep>::type;
- void* __ex =
- exception_ptr::init_ex(sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
+ void* __ex = exception_ptr::__init_native_exception(
+ sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
try {
::new (__ex) _Ep2(__e);
- return exception_ptr::from_ex_ptr(__ex);
+ return exception_ptr::__from_native_exception_pointer(__ex);
} catch (...) {
- exception_ptr::free_ex(__ex);
+ exception_ptr::__free_native_exception(__ex);
return current_exception();
}
# else
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
new file mode 100644
index 00000000000000..64b50711bbfd4e
--- /dev/null
+++ b/libcxx/include/__typeinfo/typeinfo.h
@@ -0,0 +1,333 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPEINFO_TYPEINFO_H
+#define _LIBCPP___TYPEINFO_TYPEINFO_H
+
+#include <__availability>
+#include <__config>
+#include <__exception/exception.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__verbose_abort>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+# include <vcruntime_typeinfo.h>
+#else
+
+namespace std // purposefully not using versioning namespace
+{
+
+# if defined(_LIBCPP_ABI_MICROSOFT)
+
+class _LIBCPP_EXPORTED_FROM_ABI type_info {
+ type_info& operator=(const type_info&);
+ type_info(const type_info&);
+
+ mutable struct {
+ const char* __undecorated_name;
+ const char __decorated_name[1];
+ } __data;
+
+ int __compare(const type_info& __rhs) const _NOEXCEPT;
+
+public:
+ _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+ virtual ~type_info();
+
+ const char* name() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY bool before(const type_info& __arg) const _NOEXCEPT { return __compare(__arg) < 0; }
+
+ size_t hash_code() const _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
+ // When evaluated in a constant expression, both type infos simply can't come
+ // from different translation units, so it is sufficient to compare their addresses.
+ if (__libcpp_is_constant_evaluated()) {
+ return this == &__arg;
+ }
+ return __compare(__arg) == 0;
+ }
+
+# if _LIBCPP_STD_VER <= 17
+ _LIBCPP_INLINE_VISIBILITY bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }
+# endif
+};
+
+# else // !defined(_LIBCPP_ABI_MICROSOFT)
+
+// ========================================================================== //
+// Implementations
+// ========================================================================== //
+// ------------------------------------------------------------------------- //
+// Unique
+// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1)
+// ------------------------------------------------------------------------- //
+// This implementation of type_info assumes a unique copy of the RTTI for a
+// given type inside a program. This is a valid assumption when abiding to the
+// Itanium ABI (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-components).
+// Under this assumption, we can always compare the addresses of the type names
+// to implement equality-comparison of type_infos instead of having to perform
+// a deep string comparison.
+// -------------------------------------------------------------------------- //
+// NonUnique
+// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2)
+// -------------------------------------------------------------------------- //
+// This implementation of type_info does not assume there is always a unique
+// copy of the RTTI for a given type inside a program. For various reasons
+// the linker may have failed to merge every copy of a types RTTI
+// (For example: -Bsymbolic or llvm.org/PR37398). Under this assumption, two
+// type_infos are equal if their addresses are equal or if a deep string
+// comparison is equal.
+// -------------------------------------------------------------------------- //
+// NonUniqueARMRTTIBit
+// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)
+// -------------------------------------------------------------------------- //
+// This implementation is specific to ARM64 on Apple platforms.
+//
+// This implementation of type_info does not assume always a unique copy of
+// the RTTI for a given type inside a program. When constructing the type_info,
+// the compiler packs the pointer to the type name into a uintptr_t and reserves
+// the high bit of that pointer, which is assumed to be free for use under that
+// ABI. If that high bit is set, that specific copy of the RTTI can't be assumed
+// to be unique within the program. If the high bit is unset, then the RTTI can
+// be assumed to be unique within the program.
+//
+// When comparing type_infos, if both RTTIs can be assumed to be unique, it
+// suffices to compare their addresses. If both the RTTIs can't be assumed to
+// be unique, we must perform a deep string comparison of the type names.
+// However, if one of the RTTIs is guaranteed unique and the other one isn't,
+// then both RTTIs are necessarily not to be considered equal.
+//
+// The intent of this design is to remove the need for weak symbols. Specifically,
+// if a type would normally have a default-visibility RTTI emitted as a weak
+// symbol, it is given hidden visibility instead and the non-unique bit is set.
+// Otherwise, types declared with hidden visibility are always considered to have
+// a unique RTTI: the RTTI is emitted with linkonce_odr linkage and is assumed
+// to be deduplicated by the linker within the linked image. Across linked image
+// boundaries, such types are thus considered different types.
+
+// This value can be overriden in the __config_site. When it's not overriden,
+// we pick a default implementation based on the platform here.
+# ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
+
+// Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.
+# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
+
+// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
+# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3
+
+// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
+# else
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
+# endif
+# endif
+
+struct __type_info_implementations {
+ struct __string_impl_base {
+ typedef const char* __type_name_t;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char*
+ __type_name_to_string(__type_name_t __v) _NOEXCEPT {
+ return __v;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t
+ __string_to_type_name(const char* __v) _NOEXCEPT {
+ return __v;
+ }
+ };
+
+ struct __unique_impl : __string_impl_base {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
+ return reinterpret_cast<size_t>(__v);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
+ __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __lhs == __rhs;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
+ __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __lhs < __rhs;
+ }
+ };
+
+ struct __non_unique_impl : __string_impl_base {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT {
+ size_t __hash = 5381;
+ while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
+ __hash = (__hash * 33) ^ __c;
+ return __hash;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
+ __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
+ __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ return __builtin_strcmp(__lhs, __rhs) < 0;
+ }
+ };
+
+ struct __non_unique_arm_rtti_bit_impl {
+ typedef uintptr_t __type_name_t;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static const char*
+ __type_name_to_string(__type_name_t __v) _NOEXCEPT {
+ return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static __type_name_t
+ __string_to_type_name(const char* __v) _NOEXCEPT {
+ return reinterpret_cast<__type_name_t>(__v);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
+ if (__is_type_name_unique(__v))
+ return __v;
+ return __non_unique_impl::__hash(__type_name_to_string(__v));
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
+ __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ if (__lhs == __rhs)
+ return true;
+ if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
+ // Either both are unique and have a different address, or one of them
+ // is unique and the other one isn't. In both cases they are unequal.
+ return false;
+ return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
+ __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
+ if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
+ return __lhs < __rhs;
+ return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;
+ }
+
+ private:
+ // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
+ // this implementation is actually used.
+ typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))>
+ __non_unique_rtti_bit;
+
+ _LIBCPP_INLINE_VISIBILITY static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
+ return !(__lhs & __non_unique_rtti_bit::value);
+ }
+ };
+
+ typedef
+# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
+ __unique_impl
+# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
+ __non_unique_impl
+# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
+ __non_unique_arm_rtti_bit_impl
+# else
+# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
+# endif
+ __impl;
+};
+
+class _LIBCPP_EXPORTED_FROM_ABI type_info {
+ type_info& operator=(const type_info&);
+ type_info(const type_info&);
+
+protected:
+ typedef __type_info_implementations::__impl __impl;
+
+ __impl::__type_name_t __type_name;
+
+ _LIBCPP_INLINE_VISIBILITY explicit type_info(const char* __n) : __type_name(__impl::__string_to_type_name(__n)) {}
+
+public:
+ _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
+ virtual ~type_info();
+
+ _LIBCPP_INLINE_VISIBILITY const char* name() const _NOEXCEPT { return __impl::__type_name_to_string(__type_name); }
+
+ _LIBCPP_INLINE_VISIBILITY bool before(const type_info& __arg) const _NOEXCEPT {
+ return __impl::__lt(__type_name, __arg.__type_name);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
+ // When evaluated in a constant expression, both type infos simply can't come
+ // from different translation units, so it is sufficient to compare their addresses.
+ if (__libcpp_is_constant_evaluated()) {
+ return this == &__arg;
+ }
+ return __impl::__eq(__type_name, __arg.__type_name);
+ }
+
+# if _LIBCPP_STD_VER <= 17
+ _LIBCPP_INLINE_VISIBILITY bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }
+# endif
+};
+# endif // defined(_LIBCPP_ABI_MICROSOFT)
+
+class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
+public:
+ bad_cast() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
+ ~bad_cast() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
+};
+
+class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
+public:
+ bad_typeid() _NOEXCEPT;
+ ~bad_typeid() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
+};
+
+} // namespace std
+
+#endif // defined(_LIBCPP_ABI_VCRUNTIME)
+
+#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
+
+namespace std {
+
+class bad_cast : public exception {
+public:
+ bad_cast() _NOEXCEPT : exception("bad cast") {}
+
+private:
+ bad_cast(const char* const __message) _NOEXCEPT : exception(__message) {}
+};
+
+class bad_typeid : public exception {
+public:
+ bad_typeid() _NOEXCEPT : exception("bad typeid") {}
+
+private:
+ bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}
+};
+
+} // namespace std
+
+#endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_bad_cast() {
+#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+ throw bad_cast();
+#else
+ _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode");
+#endif
+}
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___TYPEINFO_TYPEINFO_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 7e93e0a155033d..b56e695e09b3d1 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1250,6 +1250,8 @@ module std_private_debug_utils_strict_weak_ordering_check [system] {
export std_private_type_traits_is_constant_evaluated
}
+module std_private_typeinfo_typeinfo [system] { header "__typeinfo/typeinfo.h" }
+
module std_private_exception_exception [system] { header "__exception/exception.h" }
module std_private_exception_exception_ptr [system] {
header "__exception/exception_ptr.h"
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index e8b75734f2ecd7..b4e629112f1729 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -57,18 +57,15 @@ public:
*/
#include <__assert> // all public C++ headers provide the assertion handler
-#include <__availability>
#include <__config>
-#include <__exception/exception.h>
-#include <__type_traits/is_constant_evaluated.h>
-#include <__verbose_abort>
-#include <cstddef>
-#include <cstdint>
+#include <__typeinfo/typeinfo.h>
+#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+<<<<<<< HEAD
#if defined(_LIBCPP_ABI_VCRUNTIME)
#include <vcruntime_typeinfo.h>
#else
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 277c5b867f679a..f8ad08c11b736b 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -13,8 +13,9 @@
namespace std {
-exception_ptr::~exception_ptr() noexcept {
- __cxa_decrement_exception_refcount(__ptr_);
+exception_ptr::~exception_ptr() noexcept
+{
+ __cxa_decrement_exception_refcount(__ptr_);
}
exception_ptr::exception_ptr(const exception_ptr& other) noexcept
@@ -34,17 +35,19 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-void *exception_ptr::init_ex(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept {
- void *__ex = __cxa_allocate_exception(size);
- (void)__cxa_init_primary_exception(__ex, tinfo, dest);
- return __ex;
+void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
+{
+ void *__ex = __cxa_allocate_exception(size);
+ (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ return __ex;
}
-void exception_ptr::free_ex(void *thrown_object) noexcept {
- __cxa_free_exception(thrown_object);
+void exception_ptr::__free_native_exception(void *thrown_object) noexcept
+{
+ __cxa_free_exception(thrown_object);
}
-exception_ptr exception_ptr::from_ex_ptr(void *__e) noexcept {
+exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {
exception_ptr ptr;
ptr.__ptr_ = __e;
__cxa_increment_exception_refcount(ptr.__ptr_);
>From dd5e10e119d62d8550df89d0e0d4204a2a4c0b42 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 23 Aug 2023 22:37:40 +0300
Subject: [PATCH 04/66] + clang-format, fix libcxx.imp
---
libcxx/include/__typeinfo/typeinfo.h | 2 +-
libcxx/include/libcxx.imp | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
index 64b50711bbfd4e..ac3550be0842e5 100644
--- a/libcxx/include/__typeinfo/typeinfo.h
+++ b/libcxx/include/__typeinfo/typeinfo.h
@@ -294,7 +294,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
} // namespace std
-#endif // defined(_LIBCPP_ABI_VCRUNTIME)
+#endif // defined(_LIBCPP_ABI_VCRUNTIME)
#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp
index 3eb2aa84931482..f7e906e024f33a 100644
--- a/libcxx/include/libcxx.imp
+++ b/libcxx/include/libcxx.imp
@@ -48,6 +48,7 @@
{ include: [ "@<__thread/.*>", "private", "<thread>", "public" ] },
{ include: [ "@<__tuple/.*>", "private", "<tuple>", "public" ] },
{ include: [ "@<__type_traits/.*>", "private", "<type_traits>", "public" ] },
+ { include: [ "@<__typeinfo/.*>", "private", "<typeinfo>", "public" ] },
{ include: [ "@<__utility/.*>", "private", "<utility>", "public" ] },
{ include: [ "@<__variant/.*>", "private", "<variant>", "public" ] },
]
>From 2bf9b303caf06b27bd7479c97b266d2ed43c0043 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 29 Aug 2023 14:36:53 +0300
Subject: [PATCH 05/66] wip on making the build green
---
libcxx/include/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 5e1c606bde6b86..978708ced598ad 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -698,7 +698,6 @@ set(files
__tuple/tuple_like_ext.h
__tuple/tuple_size.h
__tuple/tuple_types.h
- __typeinfo/typeinfo.h
__type_traits/add_const.h
__type_traits/add_cv.h
__type_traits/add_lvalue_reference.h
@@ -836,6 +835,7 @@ set(files
__type_traits/underlying_type.h
__type_traits/unwrap_ref.h
__type_traits/void_t.h
+ __typeinfo/typeinfo.h
__undef_macros
__utility/as_const.h
__utility/as_lvalue.h
>From 167a1b7fad4592c99aaa9fd1a6fc8b99de123534 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 29 Aug 2023 19:25:34 +0300
Subject: [PATCH 06/66] wip on making the build green
---
libcxx/include/module.modulemap.in | 5 ++++-
libcxx/include/typeinfo | 1 -
libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx23.csv | 3 +++
libcxx/test/libcxx/transitive_includes/cxx26.csv | 3 +++
9 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index b56e695e09b3d1..04d2a68deb7286 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1250,7 +1250,10 @@ module std_private_debug_utils_strict_weak_ordering_check [system] {
export std_private_type_traits_is_constant_evaluated
}
-module std_private_typeinfo_typeinfo [system] { header "__typeinfo/typeinfo.h" }
+module std_private_typeinfo_typeinfo [system] {
+ header "__typeinfo/typeinfo.h"
+ export *
+}
module std_private_exception_exception [system] { header "__exception/exception.h" }
module std_private_exception_exception_ptr [system] {
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index b4e629112f1729..831dc18a5530e4 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -59,7 +59,6 @@ public:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__typeinfo/typeinfo.h>
-#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 7066de65a91372..3f7a3f3af6a8e6 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -220,6 +220,7 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
+exception cstdint
exception cstdlib
exception type_traits
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index c4dc664d6ca817..affed3e503684d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -221,6 +221,7 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
+exception cstdint
exception cstdlib
exception type_traits
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 20ee43722d894b..af53a0686379be 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -221,6 +221,7 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
+exception cstdint
exception cstdlib
exception type_traits
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 20ee43722d894b..af53a0686379be 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -221,6 +221,7 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
+exception cstdint
exception cstdlib
exception type_traits
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index d256370aac4a4a..d15ba4520c0ec3 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -227,6 +227,7 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
+exception cstdint
exception cstdlib
exception type_traits
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 9edc283236480e..dbcef522ea2e97 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -152,7 +152,9 @@ deque stdexcept
deque tuple
deque version
exception cstddef
+exception cstdint
exception cstdlib
+exception type_traits
exception version
execution cstddef
execution version
@@ -251,6 +253,7 @@ future ratio
future stdexcept
future string
future thread
+future type_traits
future typeinfo
future version
initializer_list cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 9edc283236480e..dbcef522ea2e97 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -152,7 +152,9 @@ deque stdexcept
deque tuple
deque version
exception cstddef
+exception cstdint
exception cstdlib
+exception type_traits
exception version
execution cstddef
execution version
@@ -251,6 +253,7 @@ future ratio
future stdexcept
future string
future thread
+future type_traits
future typeinfo
future version
initializer_list cstddef
>From 143412f2ce6253698d2e4fbc891ecffaa9d8ce51 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 30 Aug 2023 13:13:14 +0300
Subject: [PATCH 07/66] bits of formatting
---
libcxx/include/module.modulemap.in | 4 ++--
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 04d2a68deb7286..a0fae99b9e2904 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1250,8 +1250,8 @@ module std_private_debug_utils_strict_weak_ordering_check [system] {
export std_private_type_traits_is_constant_evaluated
}
-module std_private_typeinfo_typeinfo [system] {
- header "__typeinfo/typeinfo.h"
+module std_private_typeinfo_typeinfo [system] {
+ header "__typeinfo/typeinfo.h"
export *
}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index f8ad08c11b736b..93e08dba3cd9bd 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -35,7 +35,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
+void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
void *__ex = __cxa_allocate_exception(size);
(void)__cxa_init_primary_exception(__ex, tinfo, dest);
>From 4d5e1dea5c3ea19bcc469b79652f898ffc756582 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 7 Sep 2023 00:25:28 +0300
Subject: [PATCH 08/66] ABI fixes
---
libcxx/include/__exception/exception_ptr.h | 6 +++---
libcxxabi/lib/exceptions.exp | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 0e5310c767cbe9..bcb84d8bc06e59 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -34,9 +34,9 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
static_cast<_Ep*>(__x)->~_Ep();
}
- static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
- static void __free_native_exception(void*) _NOEXCEPT;
- static exception_ptr __from_native_exception_pointer(void* __e) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI static void __free_native_exception(void*) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI static exception_ptr __from_native_exception_pointer(void* __e) _NOEXCEPT;
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
diff --git a/libcxxabi/lib/exceptions.exp b/libcxxabi/lib/exceptions.exp
index c3780d2974903c..9dcfbdbd3598e1 100644
--- a/libcxxabi/lib/exceptions.exp
+++ b/libcxxabi/lib/exceptions.exp
@@ -7,5 +7,6 @@ ___cxa_end_catch
___cxa_free_dependent_exception
___cxa_free_exception
___cxa_get_exception_ptr
+___cxa_init_primary_exception
___cxa_rethrow
___cxa_throw
>From f7c84740b3739196b1194ff27da8851c56bdd85b Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 25 Sep 2023 16:46:25 +0300
Subject: [PATCH 09/66] rebase fix
---
libcxx/include/typeinfo | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index 831dc18a5530e4..f82191bf2189f4 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -64,7 +64,6 @@ public:
# pragma GCC system_header
#endif
-<<<<<<< HEAD
#if defined(_LIBCPP_ABI_VCRUNTIME)
#include <vcruntime_typeinfo.h>
#else
>From 547470af654e86c498a5c544736d76ab1fd46a25 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 27 Sep 2023 17:25:23 +0300
Subject: [PATCH 10/66] rebase fix
---
libcxx/include/__typeinfo/typeinfo.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
index ac3550be0842e5..394cac5967870a 100644
--- a/libcxx/include/__typeinfo/typeinfo.h
+++ b/libcxx/include/__typeinfo/typeinfo.h
@@ -281,6 +281,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
public:
bad_cast() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;
~bad_cast() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
@@ -288,6 +289,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
public:
bad_typeid() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;
~bad_typeid() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
>From 469eba8e22e5ca3f18f76101ab0ee3f4ebe7e44a Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 27 Sep 2023 18:05:49 +0300
Subject: [PATCH 11/66] + clang-format
---
libcxx/include/__typeinfo/typeinfo.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
index 394cac5967870a..07b53af2b47858 100644
--- a/libcxx/include/__typeinfo/typeinfo.h
+++ b/libcxx/include/__typeinfo/typeinfo.h
@@ -280,7 +280,7 @@ class _LIBCPP_EXPORTED_FROM_ABI type_info {
class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
public:
bad_cast() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;
~bad_cast() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
@@ -289,7 +289,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
public:
bad_typeid() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;
~bad_typeid() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
>From 5fdfe5512ec397a04f21a78a4d71afa1187d66bc Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 27 Sep 2023 23:55:46 +0300
Subject: [PATCH 12/66] + generate-cxx-abilist
---
...nknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
index 49e3579614ee8c..478a615eb61cbc 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -54,6 +54,7 @@
{'is_defined': False, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_guard_release', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
+{'is_defined': False, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
>From 87983b8990a2c259a5e4adb421c67385d6de5eec Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 2 Oct 2023 16:29:26 +0300
Subject: [PATCH 13/66] fix compilcation under gcc
---
libcxx/include/__exception/exception_ptr.h | 6 +++---
...n-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index bcb84d8bc06e59..0e5310c767cbe9 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -34,9 +34,9 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
static_cast<_Ep*>(__x)->~_Ep();
}
- _LIBCPP_HIDE_FROM_ABI static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI static void __free_native_exception(void*) _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI static exception_ptr __from_native_exception_pointer(void* __e) _NOEXCEPT;
+ static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
+ static void __free_native_exception(void*) _NOEXCEPT;
+ static exception_ptr __from_native_exception_pointer(void* __e) _NOEXCEPT;
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
index 478a615eb61cbc..71c492deced3c6 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -522,6 +522,9 @@
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
>From 0fb50a2f68d7cded8b53ff15a69e2160d297b285 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 6 Oct 2023 18:02:39 +0300
Subject: [PATCH 14/66] some more ifdefs
---
libcxx/include/__exception/exception_ptr.h | 4 +++-
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 0e5310c767cbe9..ecc82d0ba905f5 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -28,7 +28,8 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
-# if defined(LIBCXX_BUILDING_LIBCXXABI)
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if defined(LIBCXX_BUILDING_LIBCXXABI)
template <class _Ep>
static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
@@ -41,6 +42,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
# endif
+# endif
public:
_LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 93e08dba3cd9bd..d51031977e2dcb 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -35,6 +35,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
void *__ex = __cxa_allocate_exception(size);
@@ -54,6 +55,7 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept
return ptr;
}
+# endif
nested_exception::nested_exception() noexcept
: __ptr_(current_exception())
>From 7e9d7747b1446f0ca59a519bec24197d57c18ab9 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 9 Oct 2023 02:44:07 +0300
Subject: [PATCH 15/66] + clang-format
---
libcxx/include/__exception/exception_ptr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index ecc82d0ba905f5..e435da65cc5d2b 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -41,7 +41,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
-# endif
+# endif
# endif
public:
>From ee06cd9d182b3dff616156b04b91f44f7e10bd3c Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 9 Oct 2023 03:20:25 +0300
Subject: [PATCH 16/66] + clang-format
---
libcxx/include/__typeinfo/typeinfo.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
index 07b53af2b47858..2af157a5bf76f6 100644
--- a/libcxx/include/__typeinfo/typeinfo.h
+++ b/libcxx/include/__typeinfo/typeinfo.h
@@ -297,7 +297,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
} // namespace std
-#endif // defined(_LIBCPP_ABI_VCRUNTIME)
+#endif // defined(_LIBCPP_ABI_VCRUNTIME)
#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
>From ba2cceee35a36678a6e633c619ac7b00c8b7a1e1 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 9 Oct 2023 03:37:52 +0300
Subject: [PATCH 17/66] + clang-format, 17.0.2
---
libcxx/include/__typeinfo/typeinfo.h | 2 +-
libcxxabi/src/cxa_exception.cpp | 30 ++++++++++++++--------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
index 2af157a5bf76f6..07b53af2b47858 100644
--- a/libcxx/include/__typeinfo/typeinfo.h
+++ b/libcxx/include/__typeinfo/typeinfo.h
@@ -297,7 +297,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
} // namespace std
-#endif // defined(_LIBCPP_ABI_VCRUNTIME)
+#endif // defined(_LIBCPP_ABI_VCRUNTIME)
#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index 1e72d7f34f26a2..65e9f4504ddade 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -208,16 +208,16 @@ void __cxa_free_exception(void *thrown_object) throw() {
__cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo,
void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
- __cxa_exception* exception_header = cxa_exception_from_thrown_object(object);
- exception_header->referenceCount = 0;
- exception_header->unexpectedHandler = std::get_unexpected();
- exception_header->terminateHandler = std::get_terminate();
- exception_header->exceptionType = tinfo;
- exception_header->exceptionDestructor = dest;
- setOurExceptionClass(&exception_header->unwindHeader);
- exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
+ __cxa_exception* exception_header = cxa_exception_from_thrown_object(object);
+ exception_header->referenceCount = 0;
+ exception_header->unexpectedHandler = std::get_unexpected();
+ exception_header->terminateHandler = std::get_terminate();
+ exception_header->exceptionType = tinfo;
+ exception_header->exceptionDestructor = dest;
+ setOurExceptionClass(&exception_header->unwindHeader);
+ exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
- return exception_header;
+ return exception_header;
}
// This function shall allocate a __cxa_dependent_exception and
@@ -273,15 +273,15 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_F
#else
__cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
#endif
- __cxa_eh_globals* globals = __cxa_get_globals();
- globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local
+ __cxa_eh_globals* globals = __cxa_get_globals();
+ globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local
- __cxa_exception* exception_header = __cxa_init_primary_exception(thrown_object, tinfo, dest);
- exception_header->referenceCount = 1; // This is a newly allocated exception, no need for thread safety.
+ __cxa_exception* exception_header = __cxa_init_primary_exception(thrown_object, tinfo, dest);
+ exception_header->referenceCount = 1; // This is a newly allocated exception, no need for thread safety.
#if __has_feature(address_sanitizer)
- // Inform the ASan runtime that now might be a good time to clean stuff up.
- __asan_handle_no_return();
+ // Inform the ASan runtime that now might be a good time to clean stuff up.
+ __asan_handle_no_return();
#endif
#ifdef __USING_SJLJ_EXCEPTIONS__
>From dbec12c6be08fd3c569cd3260de960792114427a Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 12 Oct 2023 05:18:00 +0300
Subject: [PATCH 18/66] code review fixes
---
libcxx/include/__exception/exception_ptr.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index e435da65cc5d2b..5c14eab00b0098 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -12,10 +12,10 @@
#include <__config>
#include <__exception/operations.h>
#include <__memory/addressof.h>
+#include <__type_traits/decay.h>
#include <__typeinfo/typeinfo.h>
#include <cstddef>
#include <cstdlib>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -70,7 +70,7 @@ template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if defined(LIBCXX_BUILDING_LIBCXXABI)
- using _Ep2 = typename decay<_Ep>::type;
+ using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
try {
>From 2b2eb9c733860b6f7a8ec2378edbf1896fe90292 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 12 Oct 2023 10:29:02 +0300
Subject: [PATCH 19/66] fix transitive_includes tests
---
libcxx/test/libcxx/transitive_includes/cxx23.csv | 2 --
libcxx/test/libcxx/transitive_includes/cxx26.csv | 2 --
2 files changed, 4 deletions(-)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index dbcef522ea2e97..3346e106a1e5f8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -154,7 +154,6 @@ deque version
exception cstddef
exception cstdint
exception cstdlib
-exception type_traits
exception version
execution cstddef
execution version
@@ -253,7 +252,6 @@ future ratio
future stdexcept
future string
future thread
-future type_traits
future typeinfo
future version
initializer_list cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index dbcef522ea2e97..3346e106a1e5f8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -154,7 +154,6 @@ deque version
exception cstddef
exception cstdint
exception cstdlib
-exception type_traits
exception version
execution cstddef
execution version
@@ -253,7 +252,6 @@ future ratio
future stdexcept
future string
future thread
-future type_traits
future typeinfo
future version
initializer_list cstddef
>From 481e40a84da79a103bb57693995daf668c4d8bb0 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 14 Oct 2023 16:08:33 +0300
Subject: [PATCH 20/66] runtime lookup of __cxa_init_primary_exception
---
libcxx/include/__exception/exception_ptr.h | 8 ++++++++
.../src/support/runtime/exception_pointer_cxxabi.ipp | 12 +++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 5c14eab00b0098..17894eeeed5818 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -73,6 +73,14 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
+ if (__ex == nullptr) {
+ try {
+ throw __e;
+ } catch (...) {
+ return current_exception();
+ }
+ }
+
try {
::new (__ex) _Ep2(__e);
return exception_ptr::__from_native_exception_pointer(__ex);
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index d51031977e2dcb..73aa30e6ca893a 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -11,6 +11,8 @@
#error this header may only be used with libc++abi or libcxxrt
#endif
+#include <dlfcn.h>
+
namespace std {
exception_ptr::~exception_ptr() noexcept
@@ -38,8 +40,16 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
+ using CxaInitPrimaryExceptionPrototype = void *(*)(void *, type_info *, void(*)(void *));
+ static CxaInitPrimaryExceptionPrototype cxa_init_primary_exception_fn = reinterpret_cast<CxaInitPrimaryExceptionPrototype>(
+ dlsym(RTLD_DEFAULT, "__cxa_init_primary_exception"));
+
+ if (cxa_init_primary_exception_fn == nullptr) {
+ return nullptr;
+ }
+
void *__ex = __cxa_allocate_exception(size);
- (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ (void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
return __ex;
}
>From b9fb80dc657d2114764b0d84d1f8e9b47b3d6e83 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 14 Oct 2023 18:23:46 +0300
Subject: [PATCH 21/66] regenerate cxx-abilist
---
...nknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
index 71c492deced3c6..a391ac9be3c513 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -54,7 +54,6 @@
{'is_defined': False, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_guard_release', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
-{'is_defined': False, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
>From 6ff32ad80529dfff29e0f6cee3686e81232f1221 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 14 Oct 2023 22:03:35 +0300
Subject: [PATCH 22/66] add exception_ptr.bench
---
libcxx/benchmarks/CMakeLists.txt | 1 +
libcxx/benchmarks/exception_ptr.bench.cpp | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
create mode 100644 libcxx/benchmarks/exception_ptr.bench.cpp
diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt
index 4307f6b57831f2..4f07ab48d28956 100644
--- a/libcxx/benchmarks/CMakeLists.txt
+++ b/libcxx/benchmarks/CMakeLists.txt
@@ -201,6 +201,7 @@ set(BENCHMARK_TESTS
allocation.bench.cpp
deque.bench.cpp
deque_iterator.bench.cpp
+ exception_ptr.bench.cpp
filesystem.bench.cpp
format_to_n.bench.cpp
format_to.bench.cpp
diff --git a/libcxx/benchmarks/exception_ptr.bench.cpp b/libcxx/benchmarks/exception_ptr.bench.cpp
new file mode 100644
index 00000000000000..c28d11ba0ed392
--- /dev/null
+++ b/libcxx/benchmarks/exception_ptr.bench.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <benchmark/benchmark.h>
+#include <exception>
+#include <stdexcept>
+
+void bm_make_exception_ptr(benchmark::State& state) {
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(std::make_exception_ptr(std::runtime_error{"Some error"}));
+ }
+}
+BENCHMARK(bm_make_exception_ptr);
+
+BENCHMARK_MAIN();
>From ce34b012abc526db73ea6dfe98db5c2ed9708196 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 14 Oct 2023 22:40:47 +0300
Subject: [PATCH 23/66] add threaded benchmark
---
libcxx/benchmarks/exception_ptr.bench.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/benchmarks/exception_ptr.bench.cpp b/libcxx/benchmarks/exception_ptr.bench.cpp
index c28d11ba0ed392..4933d4b22babeb 100644
--- a/libcxx/benchmarks/exception_ptr.bench.cpp
+++ b/libcxx/benchmarks/exception_ptr.bench.cpp
@@ -16,5 +16,6 @@ void bm_make_exception_ptr(benchmark::State& state) {
}
}
BENCHMARK(bm_make_exception_ptr);
+BENCHMARK(bm_make_exception_ptr)->Threads(8)->UseRealTime();
BENCHMARK_MAIN();
>From 921275a7c9b60e85d40e26c6726dbdf06b0157a5 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 14 Oct 2023 23:21:35 +0300
Subject: [PATCH 24/66] better measurements in benchmark
---
libcxx/benchmarks/exception_ptr.bench.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libcxx/benchmarks/exception_ptr.bench.cpp b/libcxx/benchmarks/exception_ptr.bench.cpp
index 4933d4b22babeb..95a59e5bd647e0 100644
--- a/libcxx/benchmarks/exception_ptr.bench.cpp
+++ b/libcxx/benchmarks/exception_ptr.bench.cpp
@@ -15,7 +15,6 @@ void bm_make_exception_ptr(benchmark::State& state) {
benchmark::DoNotOptimize(std::make_exception_ptr(std::runtime_error{"Some error"}));
}
}
-BENCHMARK(bm_make_exception_ptr);
-BENCHMARK(bm_make_exception_ptr)->Threads(8)->UseRealTime();
+BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8);
BENCHMARK_MAIN();
>From 83fc3771dfa648785f9788b9f2ca120449bc6126 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sun, 15 Oct 2023 00:38:26 +0300
Subject: [PATCH 25/66] add cxx-abilist for other architectures, some ifdefs
for windows
---
...c64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist | 3 +++
...pple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist | 5 +++++
...own-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist | 3 +++
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 6 ++++++
4 files changed, 17 insertions(+)
diff --git a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
index 8a98d42a2a1aa0..09a1d45ef89701 100644
--- a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -249,6 +249,9 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
diff --git a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
index 0c06b5097b83f8..204b3cbfc97828 100644
--- a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -300,6 +300,7 @@
{'is_defined': False, 'name': '___cxa_guard_acquire', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_guard_release', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_increment_exception_refcount', 'type': 'U'}
+{'is_defined': False, 'name': '___cxa_init_primary_exception', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_pure_virtual', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_rethrow', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_rethrow_primary_exception', 'type': 'U'}
@@ -811,6 +812,9 @@
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -2542,6 +2546,7 @@
{'is_defined': True, 'name': '___cxa_guard_abort', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_guard_acquire', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_guard_release', 'type': 'I'}
+{'is_defined': True, 'name': '___cxa_init_primary_exception', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_pure_virtual', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_rethrow', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_throw', 'type': 'I'}
diff --git a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
index 16658fdff54932..7387f6102b2d69 100644
--- a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -523,6 +523,9 @@
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 73aa30e6ca893a..dbac19d84516c4 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -11,7 +11,9 @@
#error this header may only be used with libc++abi or libcxxrt
#endif
+#if !defined(_WIN32)
#include <dlfcn.h>
+#endif
namespace std {
@@ -40,6 +42,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
+ #if !defined(_WIN32)
using CxaInitPrimaryExceptionPrototype = void *(*)(void *, type_info *, void(*)(void *));
static CxaInitPrimaryExceptionPrototype cxa_init_primary_exception_fn = reinterpret_cast<CxaInitPrimaryExceptionPrototype>(
dlsym(RTLD_DEFAULT, "__cxa_init_primary_exception"));
@@ -51,6 +54,9 @@ void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void
void *__ex = __cxa_allocate_exception(size);
(void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
return __ex;
+ #else
+ return nullptr;
+ #endif
}
void exception_ptr::__free_native_exception(void *thrown_object) noexcept
>From d89a05ddbdcbcef277ba80a146fba2378b63c004 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sun, 15 Oct 2023 01:09:59 +0300
Subject: [PATCH 26/66] support libcxxrt as well
---
libcxx/include/__exception/exception_ptr.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 17894eeeed5818..52affe6c5d360d 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -29,7 +29,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if defined(LIBCXX_BUILDING_LIBCXXABI)
+# if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
template <class _Ep>
static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
@@ -69,7 +69,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if defined(LIBCXX_BUILDING_LIBCXXABI)
+# if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
>From 2eb447378a6a0caea2bff736f84fb26eeae52a4f Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sun, 15 Oct 2023 05:00:59 +0300
Subject: [PATCH 27/66] add remaining cxx-abilists
---
...apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist | 5 +++++
...erpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist | 3 +++
2 files changed, 8 insertions(+)
diff --git a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
index 8daad89f52e6f7..86c75369306fba 100644
--- a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -300,6 +300,7 @@
{'is_defined': False, 'name': '___cxa_guard_acquire', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_guard_release', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_increment_exception_refcount', 'type': 'U'}
+{'is_defined': False, 'name': '___cxa_init_primary_exception', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_pure_virtual', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_rethrow', 'type': 'U'}
{'is_defined': False, 'name': '___cxa_rethrow_primary_exception', 'type': 'U'}
@@ -811,6 +812,9 @@
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -2508,6 +2512,7 @@
{'is_defined': True, 'name': '___cxa_guard_abort', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_guard_acquire', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_guard_release', 'type': 'I'}
+{'is_defined': True, 'name': '___cxa_init_primary_exception', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_pure_virtual', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_rethrow', 'type': 'I'}
{'is_defined': True, 'name': '___cxa_throw', 'type': 'I'}
diff --git a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
index 91976f500539da..a7145024d95e22 100644
--- a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -249,6 +249,9 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
>From 41ed5ff9555cb02ee549cc39347b924c00607040 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sun, 15 Oct 2023 18:28:32 +0300
Subject: [PATCH 28/66] fix the build for older versions of libcxxrt, add some
comments
---
libcxx/include/__exception/exception_ptr.h | 2 ++
.../support/runtime/exception_pointer_cxxabi.ipp | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 52affe6c5d360d..8008fc84c72704 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -73,6 +73,8 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
+ // This could happen with older versions of libcxxrt/libcxxabi,
+ // which don't yet support direct exception initialization.
if (__ex == nullptr) {
try {
throw __e;
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index dbac19d84516c4..f759f21787dabe 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -15,6 +15,15 @@
#include <dlfcn.h>
#endif
+#if defined(LIBCXXRT)
+extern "C" {
+ // Although libcxxrt defines these two (as an ABI-library should),
+ // it doesn't declare them in some versions.
+ void *__cxa_allocate_exception(size_t thrown_size);
+ void __cxa_free_exception(void* thrown_exception);
+}
+#endif
+
namespace std {
exception_ptr::~exception_ptr() noexcept
@@ -43,6 +52,10 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
#if !defined(_WIN32)
+ // We perform a runtime lookup of __cxa_init_primary_exception to
+ // preserve compability with older versions of libcxxrt/libcxxabi.
+ // If the function is not present we return nullptr because no meaningful work can be done,
+ // and the caller knows how to handle this (it fallbacks to throw + catch).
using CxaInitPrimaryExceptionPrototype = void *(*)(void *, type_info *, void(*)(void *));
static CxaInitPrimaryExceptionPrototype cxa_init_primary_exception_fn = reinterpret_cast<CxaInitPrimaryExceptionPrototype>(
dlsym(RTLD_DEFAULT, "__cxa_init_primary_exception"));
>From 72698d10b28630f3c2d7ea8407f9cc9e6a8c6eac Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sun, 15 Oct 2023 20:38:20 +0300
Subject: [PATCH 29/66] cleaner benchmark
---
libcxx/benchmarks/exception_ptr.bench.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libcxx/benchmarks/exception_ptr.bench.cpp b/libcxx/benchmarks/exception_ptr.bench.cpp
index 95a59e5bd647e0..1292ad7935e375 100644
--- a/libcxx/benchmarks/exception_ptr.bench.cpp
+++ b/libcxx/benchmarks/exception_ptr.bench.cpp
@@ -8,11 +8,10 @@
#include <benchmark/benchmark.h>
#include <exception>
-#include <stdexcept>
void bm_make_exception_ptr(benchmark::State& state) {
for (auto _ : state) {
- benchmark::DoNotOptimize(std::make_exception_ptr(std::runtime_error{"Some error"}));
+ benchmark::DoNotOptimize(std::make_exception_ptr(42));
}
}
BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8);
>From 3904feb76fe8a7aac61e623fa1cc29507f895111 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 01:07:14 +0300
Subject: [PATCH 30/66] revert the typeinfo header split, make exception
dependent on typeinfo instead
---
libcxx/include/CMakeLists.txt | 1 -
libcxx/include/__exception/exception_ptr.h | 4 +-
libcxx/include/__typeinfo/typeinfo.h | 336 ---------------------
libcxx/include/libcxx.imp | 1 -
libcxx/include/module.modulemap.in | 5 -
libcxx/include/typeinfo | 8 +-
6 files changed, 8 insertions(+), 347 deletions(-)
delete mode 100644 libcxx/include/__typeinfo/typeinfo.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 978708ced598ad..533b7ac9103ab0 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -835,7 +835,6 @@ set(files
__type_traits/underlying_type.h
__type_traits/unwrap_ref.h
__type_traits/void_t.h
- __typeinfo/typeinfo.h
__undef_macros
__utility/as_const.h
__utility/as_lvalue.h
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 8008fc84c72704..e6b0876cc8e4f0 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -13,7 +13,7 @@
#include <__exception/operations.h>
#include <__memory/addressof.h>
#include <__type_traits/decay.h>
-#include <__typeinfo/typeinfo.h>
+#include <typeinfo>
#include <cstddef>
#include <cstdlib>
@@ -69,7 +69,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
+# if !defined(_LIBCPP_HAS_NO_RTTI) && (defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI))
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
diff --git a/libcxx/include/__typeinfo/typeinfo.h b/libcxx/include/__typeinfo/typeinfo.h
deleted file mode 100644
index 07b53af2b47858..00000000000000
--- a/libcxx/include/__typeinfo/typeinfo.h
+++ /dev/null
@@ -1,336 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPEINFO_TYPEINFO_H
-#define _LIBCPP___TYPEINFO_TYPEINFO_H
-
-#include <__availability>
-#include <__config>
-#include <__exception/exception.h>
-#include <__type_traits/is_constant_evaluated.h>
-#include <__verbose_abort>
-#include <cstddef>
-#include <cstdint>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-#if defined(_LIBCPP_ABI_VCRUNTIME)
-# include <vcruntime_typeinfo.h>
-#else
-
-namespace std // purposefully not using versioning namespace
-{
-
-# if defined(_LIBCPP_ABI_MICROSOFT)
-
-class _LIBCPP_EXPORTED_FROM_ABI type_info {
- type_info& operator=(const type_info&);
- type_info(const type_info&);
-
- mutable struct {
- const char* __undecorated_name;
- const char __decorated_name[1];
- } __data;
-
- int __compare(const type_info& __rhs) const _NOEXCEPT;
-
-public:
- _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
- virtual ~type_info();
-
- const char* name() const _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY bool before(const type_info& __arg) const _NOEXCEPT { return __compare(__arg) < 0; }
-
- size_t hash_code() const _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
- // When evaluated in a constant expression, both type infos simply can't come
- // from different translation units, so it is sufficient to compare their addresses.
- if (__libcpp_is_constant_evaluated()) {
- return this == &__arg;
- }
- return __compare(__arg) == 0;
- }
-
-# if _LIBCPP_STD_VER <= 17
- _LIBCPP_INLINE_VISIBILITY bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }
-# endif
-};
-
-# else // !defined(_LIBCPP_ABI_MICROSOFT)
-
-// ========================================================================== //
-// Implementations
-// ========================================================================== //
-// ------------------------------------------------------------------------- //
-// Unique
-// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1)
-// ------------------------------------------------------------------------- //
-// This implementation of type_info assumes a unique copy of the RTTI for a
-// given type inside a program. This is a valid assumption when abiding to the
-// Itanium ABI (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-components).
-// Under this assumption, we can always compare the addresses of the type names
-// to implement equality-comparison of type_infos instead of having to perform
-// a deep string comparison.
-// -------------------------------------------------------------------------- //
-// NonUnique
-// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2)
-// -------------------------------------------------------------------------- //
-// This implementation of type_info does not assume there is always a unique
-// copy of the RTTI for a given type inside a program. For various reasons
-// the linker may have failed to merge every copy of a types RTTI
-// (For example: -Bsymbolic or llvm.org/PR37398). Under this assumption, two
-// type_infos are equal if their addresses are equal or if a deep string
-// comparison is equal.
-// -------------------------------------------------------------------------- //
-// NonUniqueARMRTTIBit
-// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)
-// -------------------------------------------------------------------------- //
-// This implementation is specific to ARM64 on Apple platforms.
-//
-// This implementation of type_info does not assume always a unique copy of
-// the RTTI for a given type inside a program. When constructing the type_info,
-// the compiler packs the pointer to the type name into a uintptr_t and reserves
-// the high bit of that pointer, which is assumed to be free for use under that
-// ABI. If that high bit is set, that specific copy of the RTTI can't be assumed
-// to be unique within the program. If the high bit is unset, then the RTTI can
-// be assumed to be unique within the program.
-//
-// When comparing type_infos, if both RTTIs can be assumed to be unique, it
-// suffices to compare their addresses. If both the RTTIs can't be assumed to
-// be unique, we must perform a deep string comparison of the type names.
-// However, if one of the RTTIs is guaranteed unique and the other one isn't,
-// then both RTTIs are necessarily not to be considered equal.
-//
-// The intent of this design is to remove the need for weak symbols. Specifically,
-// if a type would normally have a default-visibility RTTI emitted as a weak
-// symbol, it is given hidden visibility instead and the non-unique bit is set.
-// Otherwise, types declared with hidden visibility are always considered to have
-// a unique RTTI: the RTTI is emitted with linkonce_odr linkage and is assumed
-// to be deduplicated by the linker within the linked image. Across linked image
-// boundaries, such types are thus considered different types.
-
-// This value can be overriden in the __config_site. When it's not overriden,
-// we pick a default implementation based on the platform here.
-# ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
-
-// Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.
-# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)
-# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
-
-// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
-# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
-# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3
-
-// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
-# else
-# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
-# endif
-# endif
-
-struct __type_info_implementations {
- struct __string_impl_base {
- typedef const char* __type_name_t;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char*
- __type_name_to_string(__type_name_t __v) _NOEXCEPT {
- return __v;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t
- __string_to_type_name(const char* __v) _NOEXCEPT {
- return __v;
- }
- };
-
- struct __unique_impl : __string_impl_base {
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
- return reinterpret_cast<size_t>(__v);
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
- __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- return __lhs == __rhs;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
- __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- return __lhs < __rhs;
- }
- };
-
- struct __non_unique_impl : __string_impl_base {
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT {
- size_t __hash = 5381;
- while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
- __hash = (__hash * 33) ^ __c;
- return __hash;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
- __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
- __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- return __builtin_strcmp(__lhs, __rhs) < 0;
- }
- };
-
- struct __non_unique_arm_rtti_bit_impl {
- typedef uintptr_t __type_name_t;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static const char*
- __type_name_to_string(__type_name_t __v) _NOEXCEPT {
- return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value);
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static __type_name_t
- __string_to_type_name(const char* __v) _NOEXCEPT {
- return reinterpret_cast<__type_name_t>(__v);
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
- if (__is_type_name_unique(__v))
- return __v;
- return __non_unique_impl::__hash(__type_name_to_string(__v));
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
- __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- if (__lhs == __rhs)
- return true;
- if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
- // Either both are unique and have a different address, or one of them
- // is unique and the other one isn't. In both cases they are unequal.
- return false;
- return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE static bool
- __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
- return __lhs < __rhs;
- return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;
- }
-
- private:
- // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
- // this implementation is actually used.
- typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))>
- __non_unique_rtti_bit;
-
- _LIBCPP_INLINE_VISIBILITY static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
- return !(__lhs & __non_unique_rtti_bit::value);
- }
- };
-
- typedef
-# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
- __unique_impl
-# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
- __non_unique_impl
-# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
- __non_unique_arm_rtti_bit_impl
-# else
-# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
-# endif
- __impl;
-};
-
-class _LIBCPP_EXPORTED_FROM_ABI type_info {
- type_info& operator=(const type_info&);
- type_info(const type_info&);
-
-protected:
- typedef __type_info_implementations::__impl __impl;
-
- __impl::__type_name_t __type_name;
-
- _LIBCPP_INLINE_VISIBILITY explicit type_info(const char* __n) : __type_name(__impl::__string_to_type_name(__n)) {}
-
-public:
- _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
- virtual ~type_info();
-
- _LIBCPP_INLINE_VISIBILITY const char* name() const _NOEXCEPT { return __impl::__type_name_to_string(__type_name); }
-
- _LIBCPP_INLINE_VISIBILITY bool before(const type_info& __arg) const _NOEXCEPT {
- return __impl::__lt(__type_name, __arg.__type_name);
- }
-
- _LIBCPP_INLINE_VISIBILITY size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
- // When evaluated in a constant expression, both type infos simply can't come
- // from different translation units, so it is sufficient to compare their addresses.
- if (__libcpp_is_constant_evaluated()) {
- return this == &__arg;
- }
- return __impl::__eq(__type_name, __arg.__type_name);
- }
-
-# if _LIBCPP_STD_VER <= 17
- _LIBCPP_INLINE_VISIBILITY bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }
-# endif
-};
-# endif // defined(_LIBCPP_ABI_MICROSOFT)
-
-class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
-public:
- bad_cast() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
- _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;
- ~bad_cast() _NOEXCEPT override;
- const char* what() const _NOEXCEPT override;
-};
-
-class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {
-public:
- bad_typeid() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;
- _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;
- ~bad_typeid() _NOEXCEPT override;
- const char* what() const _NOEXCEPT override;
-};
-
-} // namespace std
-
-#endif // defined(_LIBCPP_ABI_VCRUNTIME)
-
-#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
-
-namespace std {
-
-class bad_cast : public exception {
-public:
- bad_cast() _NOEXCEPT : exception("bad cast") {}
-
-private:
- bad_cast(const char* const __message) _NOEXCEPT : exception(__message) {}
-};
-
-class bad_typeid : public exception {
-public:
- bad_typeid() _NOEXCEPT : exception("bad typeid") {}
-
-private:
- bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}
-};
-
-} // namespace std
-
-#endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_bad_cast() {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- throw bad_cast();
-#else
- _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode");
-#endif
-}
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPEINFO_TYPEINFO_H
diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp
index f7e906e024f33a..3eb2aa84931482 100644
--- a/libcxx/include/libcxx.imp
+++ b/libcxx/include/libcxx.imp
@@ -48,7 +48,6 @@
{ include: [ "@<__thread/.*>", "private", "<thread>", "public" ] },
{ include: [ "@<__tuple/.*>", "private", "<tuple>", "public" ] },
{ include: [ "@<__type_traits/.*>", "private", "<type_traits>", "public" ] },
- { include: [ "@<__typeinfo/.*>", "private", "<typeinfo>", "public" ] },
{ include: [ "@<__utility/.*>", "private", "<utility>", "public" ] },
{ include: [ "@<__variant/.*>", "private", "<variant>", "public" ] },
]
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index a0fae99b9e2904..7e93e0a155033d 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1250,11 +1250,6 @@ module std_private_debug_utils_strict_weak_ordering_check [system] {
export std_private_type_traits_is_constant_evaluated
}
-module std_private_typeinfo_typeinfo [system] {
- header "__typeinfo/typeinfo.h"
- export *
-}
-
module std_private_exception_exception [system] { header "__exception/exception.h" }
module std_private_exception_exception_ptr [system] {
header "__exception/exception_ptr.h"
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index f82191bf2189f4..afd866b4eff3a6 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -57,8 +57,13 @@ public:
*/
#include <__assert> // all public C++ headers provide the assertion handler
+#include <__availability>
#include <__config>
-#include <__typeinfo/typeinfo.h>
+#include <__exception/exception.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__verbose_abort>
+#include <cstddef>
+#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -411,7 +416,6 @@ _LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cstdlib>
-# include <exception>
# include <type_traits>
#endif
>From 52a826eae3199b81667c93c05fc433a116a87b47 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 02:22:51 +0300
Subject: [PATCH 31/66] use weak linkage instead of dlsym
---
.../runtime/exception_pointer_cxxabi.ipp | 35 ++++++++-----------
libcxxabi/include/cxxabi.h | 2 +-
2 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index f759f21787dabe..71a6eae90c7ae0 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -11,16 +11,20 @@
#error this header may only be used with libc++abi or libcxxrt
#endif
-#if !defined(_WIN32)
-#include <dlfcn.h>
-#endif
-
#if defined(LIBCXXRT)
extern "C" {
// Although libcxxrt defines these two (as an ABI-library should),
// it doesn't declare them in some versions.
void *__cxa_allocate_exception(size_t thrown_size);
void __cxa_free_exception(void* thrown_exception);
+
+ __attribute__((weak))
+ __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*));
+}
+#else
+extern "C" {
+ __attribute__((weak))
+ __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
}
#endif
@@ -51,25 +55,14 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- #if !defined(_WIN32)
- // We perform a runtime lookup of __cxa_init_primary_exception to
- // preserve compability with older versions of libcxxrt/libcxxabi.
- // If the function is not present we return nullptr because no meaningful work can be done,
- // and the caller knows how to handle this (it fallbacks to throw + catch).
- using CxaInitPrimaryExceptionPrototype = void *(*)(void *, type_info *, void(*)(void *));
- static CxaInitPrimaryExceptionPrototype cxa_init_primary_exception_fn = reinterpret_cast<CxaInitPrimaryExceptionPrototype>(
- dlsym(RTLD_DEFAULT, "__cxa_init_primary_exception"));
-
- if (cxa_init_primary_exception_fn == nullptr) {
+ if (__cxa_init_primary_exception != nullptr) {
+ void *__ex = __cxa_allocate_exception(size);
+ (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ return __ex;
+ }
+ else {
return nullptr;
}
-
- void *__ex = __cxa_allocate_exception(size);
- (void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
- return __ex;
- #else
- return nullptr;
- #endif
}
void exception_ptr::__free_native_exception(void *thrown_object) noexcept
diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h
index 03ec7986e20912..0ae9aebcee5c93 100644
--- a/libcxxabi/include/cxxabi.h
+++ b/libcxxabi/include/cxxabi.h
@@ -46,7 +46,7 @@ extern _LIBCXXABI_FUNC_VIS void *
__cxa_allocate_exception(size_t thrown_size) throw();
extern _LIBCXXABI_FUNC_VIS void
__cxa_free_exception(void *thrown_exception) throw();
-// This function is an llvm extension
+// This function is an LLVM extension, which mirros the same extension in libsupc++ and libcxxrt
extern _LIBCXXABI_FUNC_VIS __cxa_exception*
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
>From 275e5a114a34d2776b9c749faab7a5ca4d9583b1 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 02:25:07 +0300
Subject: [PATCH 32/66] + clang-format
---
libcxx/include/__exception/exception_ptr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index e6b0876cc8e4f0..d9ca69290c9db0 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -13,9 +13,9 @@
#include <__exception/operations.h>
#include <__memory/addressof.h>
#include <__type_traits/decay.h>
-#include <typeinfo>
#include <cstddef>
#include <cstdlib>
+#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
>From ad0297f1e7d0d296a3e7cc5ab56ca1ea3d9e9631 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 03:23:49 +0300
Subject: [PATCH 33/66] fix transitive_includes
---
libcxx/test/libcxx/transitive_includes/cxx03.csv | 3 +--
libcxx/test/libcxx/transitive_includes/cxx11.csv | 3 +--
libcxx/test/libcxx/transitive_includes/cxx14.csv | 3 +--
libcxx/test/libcxx/transitive_includes/cxx17.csv | 3 +--
libcxx/test/libcxx/transitive_includes/cxx20.csv | 3 +--
libcxx/test/libcxx/transitive_includes/cxx23.csv | 2 +-
libcxx/test/libcxx/transitive_includes/cxx26.csv | 2 +-
7 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 3f7a3f3af6a8e6..530899e6c97859 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -220,9 +220,9 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
-exception cstdint
exception cstdlib
exception type_traits
+exception typeinfo
exception version
execution cstddef
execution version
@@ -879,7 +879,6 @@ typeindex version
typeinfo cstddef
typeinfo cstdint
typeinfo cstdlib
-typeinfo exception
typeinfo type_traits
unordered_map algorithm
unordered_map bit
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index affed3e503684d..114e94d7a42e07 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -221,9 +221,9 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
-exception cstdint
exception cstdlib
exception type_traits
+exception typeinfo
exception version
execution cstddef
execution version
@@ -885,7 +885,6 @@ typeindex version
typeinfo cstddef
typeinfo cstdint
typeinfo cstdlib
-typeinfo exception
typeinfo type_traits
unordered_map algorithm
unordered_map bit
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index af53a0686379be..4852c3e5a7234c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -221,9 +221,9 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
-exception cstdint
exception cstdlib
exception type_traits
+exception typeinfo
exception version
execution cstddef
execution version
@@ -887,7 +887,6 @@ typeindex version
typeinfo cstddef
typeinfo cstdint
typeinfo cstdlib
-typeinfo exception
typeinfo type_traits
unordered_map algorithm
unordered_map bit
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index af53a0686379be..4852c3e5a7234c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -221,9 +221,9 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
-exception cstdint
exception cstdlib
exception type_traits
+exception typeinfo
exception version
execution cstddef
execution version
@@ -887,7 +887,6 @@ typeindex version
typeinfo cstddef
typeinfo cstdint
typeinfo cstdlib
-typeinfo exception
typeinfo type_traits
unordered_map algorithm
unordered_map bit
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index d15ba4520c0ec3..b0cd8d25acdc9d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -227,9 +227,9 @@ deque type_traits
deque typeinfo
deque version
exception cstddef
-exception cstdint
exception cstdlib
exception type_traits
+exception typeinfo
exception version
execution cstddef
execution version
@@ -891,7 +891,6 @@ typeindex version
typeinfo cstddef
typeinfo cstdint
typeinfo cstdlib
-typeinfo exception
typeinfo type_traits
unordered_map algorithm
unordered_map bit
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 3346e106a1e5f8..bf4501e40af0d4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -152,8 +152,8 @@ deque stdexcept
deque tuple
deque version
exception cstddef
-exception cstdint
exception cstdlib
+exception typeinfo
exception version
execution cstddef
execution version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 3346e106a1e5f8..bf4501e40af0d4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -152,8 +152,8 @@ deque stdexcept
deque tuple
deque version
exception cstddef
-exception cstdint
exception cstdlib
+exception typeinfo
exception version
execution cstddef
execution version
>From 7b71e9ad5c97ed22cc865a6d4bb37914752d4f6c Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 04:35:32 +0300
Subject: [PATCH 34/66] some formatting again
---
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 71a6eae90c7ae0..580363ccc0833d 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -18,13 +18,11 @@ extern "C" {
void *__cxa_allocate_exception(size_t thrown_size);
void __cxa_free_exception(void* thrown_exception);
- __attribute__((weak))
- __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*));
+ __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*));
}
#else
extern "C" {
- __attribute__((weak))
- __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
+ __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
}
#endif
>From 0be32740afc2aa7bc7a75f67f84d8bd90b741e6f Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 06:49:00 +0300
Subject: [PATCH 35/66] add libsupc++ support
---
libcxx/include/__exception/exception_ptr.h | 4 +--
.../runtime/exception_pointer_cxxabi.ipp | 2 ++
.../runtime/exception_pointer_glibcxx.ipp | 31 +++++++++++++++++++
3 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index d9ca69290c9db0..25f534c3449fe2 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -29,7 +29,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
+# if !defined(_LIBCPP_HAS_NO_RTTI)
template <class _Ep>
static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
@@ -69,7 +69,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if !defined(_LIBCPP_HAS_NO_RTTI) && (defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI))
+# if !defined(_LIBCPP_HAS_NO_RTTI)
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 580363ccc0833d..dedb5293c18886 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -51,6 +51,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
}
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if !defined(_LIBCPP_HAS_NO_RTTI)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
if (__cxa_init_primary_exception != nullptr) {
@@ -75,6 +76,7 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept
return ptr;
}
+# endif
# endif
nested_exception::nested_exception() noexcept
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 983a08808dccb7..225edcd24f968a 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -16,6 +16,13 @@
// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
// function.
+extern "C" {
+ void* __cxa_allocate_exception(size_t) throw();
+ void __cxa_free_exception(void*) throw();
+
+ void* __cxa_init_primary_exception(void*, std::type_info*, void(*)(void*)) throw();
+}
+
namespace std {
namespace __exception_ptr
@@ -25,6 +32,7 @@ struct exception_ptr
{
void* __ptr_;
+ exception_ptr(void* obj) noexcept;
exception_ptr(const exception_ptr&) noexcept;
exception_ptr& operator=(const exception_ptr&) noexcept;
~exception_ptr() noexcept;
@@ -53,6 +61,29 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if !defined(_LIBCPP_HAS_NO_RTTI)
+void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
+{
+ void *__ex = __cxa_allocate_exception(size);
+ (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ return __ex;
+}
+
+void exception_ptr::__free_native_exception(void *thrown_object) noexcept
+{
+ __cxa_free_exception(thrown_object);
+}
+
+exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {
+ exception_ptr ptr{};
+ new (reinterpret_cast<void*>(&ptr)) __exception_ptr::exception_ptr(__e);
+
+ return ptr;
+}
+# endif
+# endif
+
nested_exception::nested_exception() noexcept
: __ptr_(current_exception())
{
>From 2825b1eb808a52a56f5d572f1da76774432353fa Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 20 Oct 2023 21:47:48 +0300
Subject: [PATCH 36/66] make tidy happy: + _LIBCPP_HIDE_FROM_ABI
---
libcxx/include/__exception/exception_ptr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 25f534c3449fe2..a2264b03559ec0 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -31,7 +31,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if !defined(_LIBCPP_HAS_NO_RTTI)
template <class _Ep>
- static inline void __dest_thunk(void* __x) {
+ _LIBCPP_HIDE_FROM_ABI static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
}
>From 9505e1ea4b05b8f0c2900988cb05d8a7f591934e Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 04:01:55 +0300
Subject: [PATCH 37/66] include new explicitly
---
libcxx/include/__exception/exception_ptr.h | 1 +
libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx23.csv | 1 +
libcxx/test/libcxx/transitive_includes/cxx26.csv | 1 +
8 files changed, 8 insertions(+)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index a2264b03559ec0..94e1c01f8b224e 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -15,6 +15,7 @@
#include <__type_traits/decay.h>
#include <cstddef>
#include <cstdlib>
+#include <new>
#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 530899e6c97859..f51e41a7488d4d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -221,6 +221,7 @@ deque typeinfo
deque version
exception cstddef
exception cstdlib
+exception new
exception type_traits
exception typeinfo
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 114e94d7a42e07..5c341b0a734202 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -222,6 +222,7 @@ deque typeinfo
deque version
exception cstddef
exception cstdlib
+exception new
exception type_traits
exception typeinfo
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 4852c3e5a7234c..af0d5ed4d44e9c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -222,6 +222,7 @@ deque typeinfo
deque version
exception cstddef
exception cstdlib
+exception new
exception type_traits
exception typeinfo
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 4852c3e5a7234c..af0d5ed4d44e9c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -222,6 +222,7 @@ deque typeinfo
deque version
exception cstddef
exception cstdlib
+exception new
exception type_traits
exception typeinfo
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index b0cd8d25acdc9d..499535fed3b20a 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -228,6 +228,7 @@ deque typeinfo
deque version
exception cstddef
exception cstdlib
+exception new
exception type_traits
exception typeinfo
exception version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index bf4501e40af0d4..955f5956a02329 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -153,6 +153,7 @@ deque tuple
deque version
exception cstddef
exception cstdlib
+exception new
exception typeinfo
exception version
execution cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index bf4501e40af0d4..955f5956a02329 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -153,6 +153,7 @@ deque tuple
deque version
exception cstddef
exception cstdlib
+exception new
exception typeinfo
exception version
execution cstddef
>From f8656cb4eab2733f0025c800d51750a15b07bdce Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 04:25:29 +0300
Subject: [PATCH 38/66] regenerate cxx-abilist
---
...nknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
index a391ac9be3c513..71c492deced3c6 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -54,6 +54,7 @@
{'is_defined': False, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_guard_release', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
+{'is_defined': False, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
>From 62688baaa24725e54e9ffc83a7597b234db753d6 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 05:31:34 +0300
Subject: [PATCH 39/66] drop new -> exception include dependency
---
libcxx/include/new | 1 -
libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 -
6 files changed, 6 deletions(-)
diff --git a/libcxx/include/new b/libcxx/include/new
index 18f397219c1469..2f745a9b4a563a 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -368,7 +368,6 @@ _LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cstdlib>
-# include <exception>
# include <type_traits>
#endif
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index f51e41a7488d4d..a07ffa8d36aad8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -538,7 +538,6 @@ mutex typeinfo
mutex version
new cstddef
new cstdlib
-new exception
new type_traits
new version
numbers concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 5c341b0a734202..fec1f3cfd2b69e 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -543,7 +543,6 @@ mutex typeinfo
mutex version
new cstddef
new cstdlib
-new exception
new type_traits
new version
numbers concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index af0d5ed4d44e9c..2b962b61a1e029 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -545,7 +545,6 @@ mutex typeinfo
mutex version
new cstddef
new cstdlib
-new exception
new type_traits
new version
numbers concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index af0d5ed4d44e9c..2b962b61a1e029 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -545,7 +545,6 @@ mutex typeinfo
mutex version
new cstddef
new cstdlib
-new exception
new type_traits
new version
numbers concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 499535fed3b20a..95d00ab8107ff8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -550,7 +550,6 @@ mutex typeinfo
mutex version
new cstddef
new cstdlib
-new exception
new type_traits
new version
numbers concepts
>From 96d059f0aee6633a95a22261d84c0e4ae21d7131 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 06:14:06 +0300
Subject: [PATCH 40/66] oops
---
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index dedb5293c18886..bdfda2a47d46f5 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -54,7 +54,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if !defined(_LIBCPP_HAS_NO_RTTI)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- if (__cxa_init_primary_exception != nullptr) {
+ if (__cxa_init_primary_exception) {
void *__ex = __cxa_allocate_exception(size);
(void)__cxa_init_primary_exception(__ex, tinfo, dest);
return __ex;
>From 82e367eaa0e2e4f879bdc7c7d98bdecc9fa1c834 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 06:33:42 +0300
Subject: [PATCH 41/66] oops[2]
---
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index bdfda2a47d46f5..beac03f7d45a6a 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -54,7 +54,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if !defined(_LIBCPP_HAS_NO_RTTI)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- if (__cxa_init_primary_exception) {
+ if (&__cxa_init_primary_exception != nullptr) {
void *__ex = __cxa_allocate_exception(size);
(void)__cxa_init_primary_exception(__ex, tinfo, dest);
return __ex;
>From 2d7d84e4031316086c47b75e8122a2f6b5c221b4 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 06:58:17 +0300
Subject: [PATCH 42/66] fixing gcc errors hopefully
---
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index beac03f7d45a6a..c95d1861ddec0e 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -54,9 +54,10 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if !defined(_LIBCPP_HAS_NO_RTTI)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- if (&__cxa_init_primary_exception != nullptr) {
+ __cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
+ if (cxa_init_primary_exception_fn != nullptr) {
void *__ex = __cxa_allocate_exception(size);
- (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ (void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
return __ex;
}
else {
>From da258335d3974baa9fc242e50189348ded8da0f4 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 08:26:26 +0300
Subject: [PATCH 43/66] fix windows build, add fix powerpc abilists
---
...powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
...werpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
index a7145024d95e22..6fb06a77ab112c 100644
--- a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -1113,6 +1113,7 @@
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_acquire', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_release', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_init_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_pure_virtual', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
diff --git a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
index 09a1d45ef89701..0dcc370f7d81e6 100644
--- a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -1113,6 +1113,7 @@
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_acquire', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_release', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
+{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_init_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_pure_virtual', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index c95d1861ddec0e..92485353142f75 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -22,7 +22,7 @@ extern "C" {
}
#else
extern "C" {
- __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
+ __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(_LIBCXXABI_DTOR_FUNC*)(void*)) throw();
}
#endif
>From 114db76fe7e4ead41377085b2dc6397f5d83b49e Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Sat, 21 Oct 2023 09:15:48 +0300
Subject: [PATCH 44/66] fix mingw build once again
---
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 92485353142f75..e06b4b7f83245b 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -54,7 +54,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if !defined(_LIBCPP_HAS_NO_RTTI)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- __cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
+ __cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(_LIBCXXABI_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
if (cxa_init_primary_exception_fn != nullptr) {
void *__ex = __cxa_allocate_exception(size);
(void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
>From 41f419b819a56712f7a81c8c3e67c7c1eec7612a Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 24 Oct 2023 01:19:39 +0300
Subject: [PATCH 45/66] fix abilist for freebsd, reset mingw shenanigans
---
...known-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
index 7387f6102b2d69..4302ae8fba4585 100644
--- a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -56,6 +56,7 @@
{'is_defined': False, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_guard_release', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
+{'is_defined': False, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow', 'type': 'FUNC'}
{'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index e06b4b7f83245b..c95d1861ddec0e 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -22,7 +22,7 @@ extern "C" {
}
#else
extern "C" {
- __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(_LIBCXXABI_DTOR_FUNC*)(void*)) throw();
+ __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
}
#endif
@@ -54,7 +54,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if !defined(_LIBCPP_HAS_NO_RTTI)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- __cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(_LIBCXXABI_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
+ __cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
if (cxa_init_primary_exception_fn != nullptr) {
void *__ex = __cxa_allocate_exception(size);
(void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
>From 292d95bcfb49fadf3406429e9a7de5a2dc0ebe91 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 24 Oct 2023 03:57:48 +0300
Subject: [PATCH 46/66] disable for apple and windows, move define to config
---
libcxx/include/__config | 4 ++++
libcxx/include/__exception/exception_ptr.h | 14 ++++++-------
.../runtime/exception_pointer_cxxabi.ipp | 16 +++++++-------
.../runtime/exception_pointer_glibcxx.ipp | 21 ++++++++++++-------
4 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 7f66042f90256d..494ea5e86a7609 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1023,6 +1023,10 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
# define _LIBCPP_HAS_NO_RTTI
# endif
+# if !defined(_LIBCPP_HAS_NO_EXCEPTIONS) && !defined(_LIBCPP_HAS_NO_RTTI) && !defined(__APPLE__) && !defined(_WIN32)
+# define _LIBCPP_EXCEPTION_PTR_DIRECT_INIT
+# endif
+
# ifndef _LIBCPP_WEAK
# define _LIBCPP_WEAK __attribute__((__weak__))
# endif
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 94e1c01f8b224e..85a98b0f2ecc27 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -29,8 +29,7 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if !defined(_LIBCPP_HAS_NO_RTTI)
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
@@ -42,7 +41,6 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
-# endif
# endif
public:
@@ -69,8 +67,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if !defined(_LIBCPP_HAS_NO_RTTI)
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
@@ -91,16 +88,17 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
exception_ptr::__free_native_exception(__ex);
return current_exception();
}
-# else
+# else
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
throw __e;
} catch (...) {
return current_exception();
}
-# endif
-# else
+# else
((void)__e);
std::abort();
+# endif
# endif
}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index c95d1861ddec0e..e47185810aef8e 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -11,20 +11,22 @@
#error this header may only be used with libc++abi or libcxxrt
#endif
-#if defined(LIBCXXRT)
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if defined(LIBCXXRT)
extern "C" {
// Although libcxxrt defines these two (as an ABI-library should),
// it doesn't declare them in some versions.
void *__cxa_allocate_exception(size_t thrown_size);
void __cxa_free_exception(void* thrown_exception);
- __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*));
+ _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*));
}
-#else
+# else
extern "C" {
- __attribute__((weak)) __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
+ _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
}
-#endif
+# endif
+# endif
namespace std {
@@ -50,8 +52,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if !defined(_LIBCPP_HAS_NO_RTTI)
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
__cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
@@ -77,7 +78,6 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept
return ptr;
}
-# endif
# endif
nested_exception::nested_exception() noexcept
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 225edcd24f968a..dd8d3c757192ec 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -16,12 +16,15 @@
// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
// function.
+
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
extern "C" {
void* __cxa_allocate_exception(size_t) throw();
void __cxa_free_exception(void*) throw();
- void* __cxa_init_primary_exception(void*, std::type_info*, void(*)(void*)) throw();
+ _LIBCPP_WEAK void* __cxa_init_primary_exception(void*, std::type_info*, void(*)(void*)) throw();
}
+# endif
namespace std {
@@ -61,13 +64,18 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if !defined(_LIBCPP_HAS_NO_RTTI)
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
{
- void *__ex = __cxa_allocate_exception(size);
- (void)__cxa_init_primary_exception(__ex, tinfo, dest);
- return __ex;
+ void *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
+ if (cxa_init_primary_exception_fn != nullptr) {
+ void *__ex = __cxa_allocate_exception(size);
+ (void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
+ return __ex;
+ }
+ else {
+ return nullptr;
+ }
}
void exception_ptr::__free_native_exception(void *thrown_object) noexcept
@@ -81,7 +89,6 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept
return ptr;
}
-# endif
# endif
nested_exception::nested_exception() noexcept
>From fbeaf124ffc68104d4a523c30302ef981bf74d52 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 24 Oct 2023 04:15:50 +0300
Subject: [PATCH 47/66] + clang-format
---
libcxx/include/__exception/exception_ptr.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 85a98b0f2ecc27..cb83d9c7a4a79d 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -67,7 +67,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
@@ -88,8 +88,8 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
exception_ptr::__free_native_exception(__ex);
return current_exception();
}
-# else
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# else
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
throw __e;
} catch (...) {
>From f7d759618e03560a387d4f77e82ddcd72dee0f36 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 24 Oct 2023 17:04:06 +0300
Subject: [PATCH 48/66] fix abilists for apple
---
...4-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist | 3 ---
...4-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist | 3 ---
2 files changed, 6 deletions(-)
diff --git a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
index 86c75369306fba..55ee06a8788f47 100644
--- a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -812,9 +812,6 @@
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
-{'is_defined': True, 'name': '__ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
-{'is_defined': True, 'name': '__ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
-{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
diff --git a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
index 204b3cbfc97828..6ad3ad9a29e56e 100644
--- a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -812,9 +812,6 @@
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
-{'is_defined': True, 'name': '__ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
-{'is_defined': True, 'name': '__ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
-{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
>From d828925054be1d447d3e2061b94a78554e7ad28b Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 25 Oct 2023 10:30:05 +0300
Subject: [PATCH 49/66] bits of cleanup
---
libcxx/include/__exception/exception_ptr.h | 2 +-
.../runtime/exception_pointer_cxxabi.ipp | 33 +++++++++++--------
.../runtime/exception_pointer_glibcxx.ipp | 24 +++++++++-----
3 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index cb83d9c7a4a79d..9572d770bf08a9 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -37,7 +37,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
static void __free_native_exception(void*) _NOEXCEPT;
- static exception_ptr __from_native_exception_pointer(void* __e) _NOEXCEPT;
+ static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index e47185810aef8e..535e8ca9e8cd2a 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -13,17 +13,21 @@
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
# if defined(LIBCXXRT)
-extern "C" {
+extern "C"
+{
// Although libcxxrt defines these two (as an ABI-library should),
// it doesn't declare them in some versions.
- void *__cxa_allocate_exception(size_t thrown_size);
- void __cxa_free_exception(void* thrown_exception);
+ void *__cxa_allocate_exception(size_t);
+ void __cxa_free_exception(void*);
- _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*));
+ // In libcxxrt this function is not marked as noexcept
+ _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(*)(void*));
}
# else
-extern "C" {
- _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void *, std::type_info *, void(*)(void*)) throw();
+extern "C"
+{
+ // In libcxxabi this function IS noexcept
+ _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(*)(void*)) throw();
}
# endif
# endif
@@ -53,25 +57,28 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
}
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
-void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
+void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (*dest)(void*)) noexcept
{
- __cxa_exception *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
- if (cxa_init_primary_exception_fn != nullptr) {
- void *__ex = __cxa_allocate_exception(size);
+ decltype(__cxa_init_primary_exception)* cxa_init_primary_exception_fn = __cxa_init_primary_exception;
+ if (cxa_init_primary_exception_fn != nullptr)
+ {
+ void* __ex = __cxa_allocate_exception(size);
(void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
return __ex;
}
- else {
+ else
+ {
return nullptr;
}
}
-void exception_ptr::__free_native_exception(void *thrown_object) noexcept
+void exception_ptr::__free_native_exception(void* thrown_object) noexcept
{
__cxa_free_exception(thrown_object);
}
-exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {
+exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
+{
exception_ptr ptr;
ptr.__ptr_ = __e;
__cxa_increment_exception_refcount(ptr.__ptr_);
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index dd8d3c757192ec..844f9e83e4f501 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -18,7 +18,8 @@
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
-extern "C" {
+extern "C"
+{
void* __cxa_allocate_exception(size_t) throw();
void __cxa_free_exception(void*) throw();
@@ -35,7 +36,9 @@ struct exception_ptr
{
void* __ptr_;
- exception_ptr(void* obj) noexcept;
+# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+ exception_ptr(void*) noexcept;
+# endif
exception_ptr(const exception_ptr&) noexcept;
exception_ptr& operator=(const exception_ptr&) noexcept;
~exception_ptr() noexcept;
@@ -65,25 +68,28 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
}
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
-void *exception_ptr::__init_native_exception(size_t size, type_info *tinfo, void (*dest)(void *)) noexcept
+void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (*dest)(void*)) noexcept
{
- void *(*cxa_init_primary_exception_fn)(void *, std::type_info *, void(*)(void*)) = __cxa_init_primary_exception;
- if (cxa_init_primary_exception_fn != nullptr) {
- void *__ex = __cxa_allocate_exception(size);
+ decltype(__cxa_init_primary_exception)* cxa_init_primary_exception_fn = __cxa_init_primary_exception;
+ if (cxa_init_primary_exception_fn != nullptr)
+ {
+ void* __ex = __cxa_allocate_exception(size);
(void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
return __ex;
}
- else {
+ else
+ {
return nullptr;
}
}
-void exception_ptr::__free_native_exception(void *thrown_object) noexcept
+void exception_ptr::__free_native_exception(void* thrown_object) noexcept
{
__cxa_free_exception(thrown_object);
}
-exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {
+exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
+{
exception_ptr ptr{};
new (reinterpret_cast<void*>(&ptr)) __exception_ptr::exception_ptr(__e);
>From 04a63680734831f92efe10dc44c2960346c97ca2 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 25 Oct 2023 11:57:24 +0300
Subject: [PATCH 50/66] gcc build fix
---
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 2 +-
libcxx/src/support/runtime/exception_pointer_glibcxx.ipp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 535e8ca9e8cd2a..e083882d39ec40 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -59,7 +59,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (*dest)(void*)) noexcept
{
- decltype(__cxa_init_primary_exception)* cxa_init_primary_exception_fn = __cxa_init_primary_exception;
+ __cxa_exception *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(*)(void*)) = __cxa_init_primary_exception;
if (cxa_init_primary_exception_fn != nullptr)
{
void* __ex = __cxa_allocate_exception(size);
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 844f9e83e4f501..580be7206d3374 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -70,7 +70,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (*dest)(void*)) noexcept
{
- decltype(__cxa_init_primary_exception)* cxa_init_primary_exception_fn = __cxa_init_primary_exception;
+ void *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(*)(void*)) = __cxa_init_primary_exception;
if (cxa_init_primary_exception_fn != nullptr)
{
void* __ex = __cxa_allocate_exception(size);
>From cf916fe6325f308d056585dd0804a5d14fe9159f Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 27 Oct 2023 11:43:59 +0300
Subject: [PATCH 51/66] cr fixes
---
libcxx/include/__exception/exception_ptr.h | 2 ++
libcxx/src/support/runtime/exception_pointer_glibcxx.ipp | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 9572d770bf08a9..55704377058982 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -13,6 +13,7 @@
#include <__exception/operations.h>
#include <__memory/addressof.h>
#include <__type_traits/decay.h>
+#include <__utility/unreachable.h>
#include <cstddef>
#include <cstdlib>
#include <new>
@@ -79,6 +80,7 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
} catch (...) {
return current_exception();
}
+ __libcpp_unreachable();
}
try {
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 580be7206d3374..946b8441bd76ba 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -37,7 +37,7 @@ struct exception_ptr
void* __ptr_;
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
- exception_ptr(void*) noexcept;
+ explicit exception_ptr(void*) noexcept;
# endif
exception_ptr(const exception_ptr&) noexcept;
exception_ptr& operator=(const exception_ptr&) noexcept;
>From 5a9b4e6dcc6c8c51859fd09b37663b49ba9f0dd9 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 30 Oct 2023 17:58:49 +0300
Subject: [PATCH 52/66] support mingw
---
libcxx/include/__config | 9 ++++++++-
libcxx/include/__exception/exception_ptr.h | 4 ++--
libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 8 ++++----
libcxx/src/support/runtime/exception_pointer_glibcxx.ipp | 6 +++---
4 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 494ea5e86a7609..85c462e35b278d 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1023,7 +1023,14 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
# define _LIBCPP_HAS_NO_RTTI
# endif
-# if !defined(_LIBCPP_HAS_NO_EXCEPTIONS) && !defined(_LIBCPP_HAS_NO_RTTI) && !defined(__APPLE__) && !defined(_WIN32)
+// Same as _LIBCXXABI_DTOR_FUNC in libcxxabi, we need this when working with ABI in exceptions code
+# if defined(_WIN32)
+# define _LIBCXX_DTOR_FUNC __thiscall
+# else
+# define _LIBCXX_DTOR_FUNC
+# endif
+
+# if !defined(_LIBCPP_HAS_NO_EXCEPTIONS) && !defined(_LIBCPP_HAS_NO_RTTI) && !defined(__APPLE__)
# define _LIBCPP_EXCEPTION_PTR_DIRECT_INIT
# endif
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 55704377058982..12c1f8065d5958 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -32,11 +32,11 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
template <class _Ep>
- _LIBCPP_HIDE_FROM_ABI static inline void __dest_thunk(void* __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCXX_DTOR_FUNC static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
}
- static void* __init_native_exception(size_t, std::type_info*, void (*)(void*)) _NOEXCEPT;
+ static void* __init_native_exception(size_t, std::type_info*, void (_LIBCXX_DTOR_FUNC*)(void*)) _NOEXCEPT;
static void __free_native_exception(void*) _NOEXCEPT;
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index e083882d39ec40..610eca73b06cb6 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -21,13 +21,13 @@ extern "C"
void __cxa_free_exception(void*);
// In libcxxrt this function is not marked as noexcept
- _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(*)(void*));
+ _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC *)(void*));
}
# else
extern "C"
{
// In libcxxabi this function IS noexcept
- _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(*)(void*)) throw();
+ _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC *)(void*)) throw();
}
# endif
# endif
@@ -57,9 +57,9 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
}
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
-void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (*dest)(void*)) noexcept
+void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
- __cxa_exception *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(*)(void*)) = __cxa_init_primary_exception;
+ __cxa_exception *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
if (cxa_init_primary_exception_fn != nullptr)
{
void* __ex = __cxa_allocate_exception(size);
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 946b8441bd76ba..bbbcd22a1fe57c 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -23,7 +23,7 @@ extern "C"
void* __cxa_allocate_exception(size_t) throw();
void __cxa_free_exception(void*) throw();
- _LIBCPP_WEAK void* __cxa_init_primary_exception(void*, std::type_info*, void(*)(void*)) throw();
+ _LIBCPP_WEAK void* __cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) throw();
}
# endif
@@ -68,9 +68,9 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
}
# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
-void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (*dest)(void*)) noexcept
+void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
- void *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(*)(void*)) = __cxa_init_primary_exception;
+ void *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
if (cxa_init_primary_exception_fn != nullptr)
{
void* __ex = __cxa_allocate_exception(size);
>From 89a5f3d23b6ef7b2bcf530bc1685901286734946 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 30 Oct 2023 18:06:08 +0300
Subject: [PATCH 53/66] + clang-format
---
libcxx/include/__exception/exception_ptr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 12c1f8065d5958..6c2e322e5a500c 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -36,7 +36,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
static_cast<_Ep*>(__x)->~_Ep();
}
- static void* __init_native_exception(size_t, std::type_info*, void (_LIBCXX_DTOR_FUNC*)(void*)) _NOEXCEPT;
+ static void* __init_native_exception(size_t, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) _NOEXCEPT;
static void __free_native_exception(void*) _NOEXCEPT;
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
>From 99003b4d4c269d43522b144e2062bc64ff27d2ca Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 22 Nov 2023 04:24:08 +0300
Subject: [PATCH 54/66] cleanup runtime lookup mess, switch to an availability
macros instead
---
libcxx/include/__config | 4 --
libcxx/include/__exception/exception_ptr.h | 13 ++++---
.../runtime/exception_pointer_cxxabi.ipp | 37 ++-----------------
.../runtime/exception_pointer_glibcxx.ipp | 8 ++--
4 files changed, 15 insertions(+), 47 deletions(-)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 85c462e35b278d..d462e6405833b2 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1030,10 +1030,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
# define _LIBCXX_DTOR_FUNC
# endif
-# if !defined(_LIBCPP_HAS_NO_EXCEPTIONS) && !defined(_LIBCPP_HAS_NO_RTTI) && !defined(__APPLE__)
-# define _LIBCPP_EXCEPTION_PTR_DIRECT_INIT
-# endif
-
# ifndef _LIBCPP_WEAK
# define _LIBCPP_WEAK __attribute__((__weak__))
# endif
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 6c2e322e5a500c..9772278cf89848 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
+#include <__availability>
#include <__config>
#include <__exception/operations.h>
#include <__memory/addressof.h>
@@ -30,7 +31,7 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI _LIBCXX_DTOR_FUNC static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
@@ -68,7 +69,8 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
@@ -90,17 +92,16 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
exception_ptr::__free_native_exception(__ex);
return current_exception();
}
-# else
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# else
try {
throw __e;
} catch (...) {
return current_exception();
}
-# else
+# endif
+# else
((void)__e);
std::abort();
-# endif
# endif
}
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 610eca73b06cb6..67f906f369871b 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -11,27 +11,6 @@
#error this header may only be used with libc++abi or libcxxrt
#endif
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
-# if defined(LIBCXXRT)
-extern "C"
-{
- // Although libcxxrt defines these two (as an ABI-library should),
- // it doesn't declare them in some versions.
- void *__cxa_allocate_exception(size_t);
- void __cxa_free_exception(void*);
-
- // In libcxxrt this function is not marked as noexcept
- _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC *)(void*));
-}
-# else
-extern "C"
-{
- // In libcxxabi this function IS noexcept
- _LIBCPP_WEAK __cxa_exception *__cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC *)(void*)) throw();
-}
-# endif
-# endif
-
namespace std {
exception_ptr::~exception_ptr() noexcept
@@ -56,20 +35,12 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
- __cxa_exception *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
- if (cxa_init_primary_exception_fn != nullptr)
- {
- void* __ex = __cxa_allocate_exception(size);
- (void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
- return __ex;
- }
- else
- {
- return nullptr;
- }
+ void* __ex = __cxa_allocate_exception(size);
+ (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ return __ex;
}
void exception_ptr::__free_native_exception(void* thrown_object) noexcept
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index bbbcd22a1fe57c..8dbac5fee66ef7 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -17,13 +17,13 @@
// function.
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
extern "C"
{
void* __cxa_allocate_exception(size_t) throw();
void __cxa_free_exception(void*) throw();
- _LIBCPP_WEAK void* __cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) throw();
+ void* __cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) throw();
}
# endif
@@ -36,7 +36,7 @@ struct exception_ptr
{
void* __ptr_;
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
explicit exception_ptr(void*) noexcept;
# endif
exception_ptr(const exception_ptr&) noexcept;
@@ -67,7 +67,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# if defined(_LIBCPP_EXCEPTION_PTR_DIRECT_INIT)
+# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
void *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
>From 0c7a4fc16df7ae61b15309c4921d962cf92b0d13 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 22 Nov 2023 04:30:13 +0300
Subject: [PATCH 55/66] cleanup exception_pointer_glibcxx
---
.../support/runtime/exception_pointer_glibcxx.ipp | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 8dbac5fee66ef7..d89c00a439a079 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -70,17 +70,9 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
- void *(*cxa_init_primary_exception_fn)(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) = __cxa_init_primary_exception;
- if (cxa_init_primary_exception_fn != nullptr)
- {
- void* __ex = __cxa_allocate_exception(size);
- (void)cxa_init_primary_exception_fn(__ex, tinfo, dest);
- return __ex;
- }
- else
- {
- return nullptr;
- }
+ void* __ex = __cxa_allocate_exception(size);
+ (void)__cxa_init_primary_exception(__ex, tinfo, dest);
+ return __ex;
}
void exception_ptr::__free_native_exception(void* thrown_object) noexcept
>From 870e9246013ec7c27220d020595251b80886e2d5 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 27 Nov 2023 08:40:15 +0300
Subject: [PATCH 56/66] rebase fix
---
libcxx/include/__availability | 18 ++++++++++++++++++
libcxx/include/__exception/exception_ptr.h | 5 +++--
.../runtime/exception_pointer_cxxabi.ipp | 2 +-
.../runtime/exception_pointer_glibcxx.ipp | 6 +++---
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/libcxx/include/__availability b/libcxx/include/__availability
index b5230b3f56b8d8..9f8ca5951a9bf3 100644
--- a/libcxx/include/__availability
+++ b/libcxx/include/__availability
@@ -104,6 +104,12 @@
# define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST 1
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
+// These macros controls the availability of __cxa_init_primary_exception
+// in shared library, which std::make_exception_ptr might use
+// (see libcxx/include/__exception/exception_ptr.h).
+# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1
+# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
+
// These macros control the availability of all parts of <filesystem> that
// depend on something in the dylib.
# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1
@@ -164,6 +170,11 @@
# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
+// TODO: Update once this is released
+# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
+# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION \
+ __attribute__((unavailable))
+
// <filesystem>
// clang-format off
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
@@ -293,4 +304,11 @@
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
+// Define availability attributes that depend on both
+// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI.
+#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI)
+# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
+# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
+#endif
+
#endif // _LIBCPP___AVAILABILITY
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 9772278cf89848..d4a49e3f201180 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -31,12 +31,13 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
-# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI _LIBCXX_DTOR_FUNC static inline void __dest_thunk(void* __x) {
static_cast<_Ep*>(__x)->~_Ep();
}
+ _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
static void* __init_native_exception(size_t, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) _NOEXCEPT;
static void __free_native_exception(void*) _NOEXCEPT;
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
@@ -70,7 +71,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 67f906f369871b..94e0199a27d838 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -35,7 +35,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
void* __ex = __cxa_allocate_exception(size);
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index d89c00a439a079..69da6914cecf9e 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -17,7 +17,7 @@
// function.
-# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
extern "C"
{
void* __cxa_allocate_exception(size_t) throw();
@@ -36,7 +36,7 @@ struct exception_ptr
{
void* __ptr_;
-# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
explicit exception_ptr(void*) noexcept;
# endif
exception_ptr(const exception_ptr&) noexcept;
@@ -67,7 +67,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_INIT_PRIMARY_EXCEPTION)
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
{
void* __ex = __cxa_allocate_exception(size);
>From 0602721f3cfd7b50ae1966f2499da28626608853 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 5 Dec 2023 03:37:32 +0300
Subject: [PATCH 57/66] remove nullptr branch, as __init_native_exception can't
return nullptr anymore
---
libcxx/include/__exception/exception_ptr.h | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index d4a49e3f201180..542f84f9482e84 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -75,16 +75,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
using _Ep2 = __decay_t<_Ep>;
void* __ex = exception_ptr::__init_native_exception(
sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
- // This could happen with older versions of libcxxrt/libcxxabi,
- // which don't yet support direct exception initialization.
- if (__ex == nullptr) {
- try {
- throw __e;
- } catch (...) {
- return current_exception();
- }
- __libcpp_unreachable();
- }
try {
::new (__ex) _Ep2(__e);
>From 268588200bed562202e1a59c1b70a9297fe0e903 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 14 Dec 2023 19:38:46 +0300
Subject: [PATCH 58/66] cr fixes, simplify: call __cxa_* directly from headers
---
libcxx/include/__availability | 2 +-
libcxx/include/__config | 7 ----
libcxx/include/__exception/exception_ptr.h | 32 +++++++++++--------
.../runtime/exception_pointer_cxxabi.ipp | 19 ++---------
.../runtime/exception_pointer_glibcxx.ipp | 27 ----------------
libcxxabi/include/cxxabi.h | 2 +-
6 files changed, 23 insertions(+), 66 deletions(-)
diff --git a/libcxx/include/__availability b/libcxx/include/__availability
index 9f8ca5951a9bf3..eb7bd7eb28030d 100644
--- a/libcxx/include/__availability
+++ b/libcxx/include/__availability
@@ -105,7 +105,7 @@
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
// These macros controls the availability of __cxa_init_primary_exception
-// in shared library, which std::make_exception_ptr might use
+// in the built library, which std::make_exception_ptr might use
// (see libcxx/include/__exception/exception_ptr.h).
# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
diff --git a/libcxx/include/__config b/libcxx/include/__config
index d462e6405833b2..7f66042f90256d 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1023,13 +1023,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
# define _LIBCPP_HAS_NO_RTTI
# endif
-// Same as _LIBCXXABI_DTOR_FUNC in libcxxabi, we need this when working with ABI in exceptions code
-# if defined(_WIN32)
-# define _LIBCXX_DTOR_FUNC __thiscall
-# else
-# define _LIBCXX_DTOR_FUNC
-# endif
-
# ifndef _LIBCPP_WEAK
# define _LIBCPP_WEAK __attribute__((__weak__))
# endif
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 542f84f9482e84..c33845937af923 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -13,6 +13,7 @@
#include <__config>
#include <__exception/operations.h>
#include <__memory/addressof.h>
+#include <__memory/construct_at.h>
#include <__type_traits/decay.h>
#include <__utility/unreachable.h>
#include <cstddef>
@@ -24,6 +25,18 @@
# pragma GCC system_header
#endif
+namespace __cxxabiv1 {
+
+extern "C" {
+void* __cxa_allocate_exception(size_t) throw();
+void __cxa_free_exception(void*) throw();
+
+struct __cxa_exception;
+__cxa_exception* __cxa_init_primary_exception(void*, std::type_info*, void (*)(void*)) throw();
+}
+
+} // namespace __cxxabiv1
+
namespace std { // purposefully not using versioning namespace
#ifndef _LIBCPP_ABI_MICROSOFT
@@ -31,20 +44,10 @@ namespace std { // purposefully not using versioning namespace
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
- template <class _Ep>
- _LIBCPP_HIDE_FROM_ABI _LIBCXX_DTOR_FUNC static inline void __dest_thunk(void* __x) {
- static_cast<_Ep*>(__x)->~_Ep();
- }
-
- _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
- static void* __init_native_exception(size_t, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) _NOEXCEPT;
- static void __free_native_exception(void*) _NOEXCEPT;
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
template <class _Ep>
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
-# endif
public:
_LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
@@ -73,14 +76,17 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
using _Ep2 = __decay_t<_Ep>;
- void* __ex = exception_ptr::__init_native_exception(
- sizeof(_Ep), const_cast<std::type_info*>(&typeid(_Ep)), exception_ptr::__dest_thunk<_Ep2>);
+
+ void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
+ (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {
+ std::__destroy_at(static_cast<_Ep2*>(__p));
+ });
try {
::new (__ex) _Ep2(__e);
return exception_ptr::__from_native_exception_pointer(__ex);
} catch (...) {
- exception_ptr::__free_native_exception(__ex);
+ __cxxabiv1::__cxa_free_exception(__ex);
return current_exception();
}
# else
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 94e0199a27d838..ef1de9f31b3867 100644
--- a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -13,9 +13,8 @@
namespace std {
-exception_ptr::~exception_ptr() noexcept
-{
- __cxa_decrement_exception_refcount(__ptr_);
+exception_ptr::~exception_ptr() noexcept {
+ __cxa_decrement_exception_refcount(__ptr_);
}
exception_ptr::exception_ptr(const exception_ptr& other) noexcept
@@ -35,19 +34,6 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
-void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
-{
- void* __ex = __cxa_allocate_exception(size);
- (void)__cxa_init_primary_exception(__ex, tinfo, dest);
- return __ex;
-}
-
-void exception_ptr::__free_native_exception(void* thrown_object) noexcept
-{
- __cxa_free_exception(thrown_object);
-}
-
exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
{
exception_ptr ptr;
@@ -56,7 +42,6 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
return ptr;
}
-# endif
nested_exception::nested_exception() noexcept
: __ptr_(current_exception())
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 69da6914cecf9e..41c55197bbf06e 100644
--- a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -16,17 +16,6 @@
// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
// function.
-
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
-extern "C"
-{
- void* __cxa_allocate_exception(size_t) throw();
- void __cxa_free_exception(void*) throw();
-
- void* __cxa_init_primary_exception(void*, std::type_info*, void(_LIBCXX_DTOR_FUNC*)(void*)) throw();
-}
-# endif
-
namespace std {
namespace __exception_ptr
@@ -36,9 +25,7 @@ struct exception_ptr
{
void* __ptr_;
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
explicit exception_ptr(void*) noexcept;
-# endif
exception_ptr(const exception_ptr&) noexcept;
exception_ptr& operator=(const exception_ptr&) noexcept;
~exception_ptr() noexcept;
@@ -67,19 +54,6 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
return *this;
}
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
-void *exception_ptr::__init_native_exception(size_t size, type_info* tinfo, void (_LIBCXX_DTOR_FUNC* dest)(void*)) noexcept
-{
- void* __ex = __cxa_allocate_exception(size);
- (void)__cxa_init_primary_exception(__ex, tinfo, dest);
- return __ex;
-}
-
-void exception_ptr::__free_native_exception(void* thrown_object) noexcept
-{
- __cxa_free_exception(thrown_object);
-}
-
exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
{
exception_ptr ptr{};
@@ -87,7 +61,6 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
return ptr;
}
-# endif
nested_exception::nested_exception() noexcept
: __ptr_(current_exception())
diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h
index 0ae9aebcee5c93..d0701181751c50 100644
--- a/libcxxabi/include/cxxabi.h
+++ b/libcxxabi/include/cxxabi.h
@@ -46,7 +46,7 @@ extern _LIBCXXABI_FUNC_VIS void *
__cxa_allocate_exception(size_t thrown_size) throw();
extern _LIBCXXABI_FUNC_VIS void
__cxa_free_exception(void *thrown_exception) throw();
-// This function is an LLVM extension, which mirros the same extension in libsupc++ and libcxxrt
+// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
extern _LIBCXXABI_FUNC_VIS __cxa_exception*
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
>From eb9778b3069afe9c590dd65876cc9c12e0042527 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 14 Dec 2023 19:59:55 +0300
Subject: [PATCH 59/66] fix abi-list for unknown-linux-gnu
---
...known-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist | 2 --
1 file changed, 2 deletions(-)
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
index 71c492deced3c6..dcae4549f6d623 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -522,8 +522,6 @@
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
-{'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
-{'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
>From e2a88526cda7ae7b11e85756fa2467fd78278b04 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 14 Dec 2023 21:07:32 +0300
Subject: [PATCH 60/66] fix the build for C++03
---
libcxx/include/__exception/exception_ptr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index c33845937af923..d9514124ad4dcf 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -74,7 +74,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && _LIBCPP_STD_VER >= 11
using _Ep2 = __decay_t<_Ep>;
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
>From ce8881fd5014e81a670e61227dede94f7da8b0b4 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Thu, 14 Dec 2023 23:22:25 +0300
Subject: [PATCH 61/66] fix the build for C++03, attempt 2
---
libcxx/include/__exception/exception_ptr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index d9514124ad4dcf..ea71b0359ef952 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -74,7 +74,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && _LIBCPP_STD_VER >= 11
+# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L
using _Ep2 = __decay_t<_Ep>;
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
>From e108f13cdb1ea2f4f6e7bab8b6f7cec6ebb8894b Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 15 Dec 2023 00:16:21 +0300
Subject: [PATCH 62/66] fix transitive includes for cxx03
---
libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index a07ffa8d36aad8..61dbb384d36ac4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -648,7 +648,6 @@ ranges initializer_list
ranges iosfwd
ranges iterator
ranges limits
-ranges new
ranges optional
ranges span
ranges tuple
>From 7588693386e486fd85eabba53e2071155daacf8e Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 15 Dec 2023 01:00:20 +0300
Subject: [PATCH 63/66] fix transitive includes for cxx11,14,17,20
---
libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 -
4 files changed, 4 deletions(-)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index fec1f3cfd2b69e..3d207362d9b68b 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -653,7 +653,6 @@ ranges initializer_list
ranges iosfwd
ranges iterator
ranges limits
-ranges new
ranges optional
ranges span
ranges tuple
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 2b962b61a1e029..fc3a1932110bb9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -655,7 +655,6 @@ ranges initializer_list
ranges iosfwd
ranges iterator
ranges limits
-ranges new
ranges optional
ranges span
ranges tuple
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 2b962b61a1e029..fc3a1932110bb9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -655,7 +655,6 @@ ranges initializer_list
ranges iosfwd
ranges iterator
ranges limits
-ranges new
ranges optional
ranges span
ranges tuple
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 95d00ab8107ff8..d8ae6d8ceadb0c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -660,7 +660,6 @@ ranges initializer_list
ranges iosfwd
ranges iterator
ranges limits
-ranges new
ranges optional
ranges span
ranges tuple
>From 14aed0439d0a0b2d0bedd2a06733e323801fdde3 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 15 Dec 2023 03:00:13 +0300
Subject: [PATCH 64/66] adjust abi-lists for other platforms
---
...64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
...powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist | 2 --
...werpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist | 2 --
...64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist | 1 +
4 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
index 55ee06a8788f47..679b624af03956 100644
--- a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -812,6 +812,7 @@
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
diff --git a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
index 6fb06a77ab112c..fc52c17ae86f51 100644
--- a/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -249,8 +249,6 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
-{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
-{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
diff --git a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
index 0dcc370f7d81e6..dcda854e40614e 100644
--- a/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -249,8 +249,6 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
-{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
-{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
diff --git a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
index 6ad3ad9a29e56e..340337f52df1a3 100644
--- a/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -812,6 +812,7 @@
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
+{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
>From 18d3e63fca7d2dd3262aa4fc06ef05697acf025a Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 15 Dec 2023 03:02:01 +0300
Subject: [PATCH 65/66] adjust abi-list for freebsd
---
...unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist | 2 --
1 file changed, 2 deletions(-)
diff --git a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
index 4302ae8fba4585..4bdf18811464e7 100644
--- a/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist
@@ -524,8 +524,6 @@
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
-{'is_defined': True, 'name': '_ZNSt13exception_ptr23__free_native_exceptionEPv', 'type': 'FUNC'}
-{'is_defined': True, 'name': '_ZNSt13exception_ptr23__init_native_exceptionEmPSt9type_infoPFvPvE', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
>From fc10a48df8812cebff0dc17b6158245a330584f5 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Fri, 15 Dec 2023 04:59:55 +0300
Subject: [PATCH 66/66] adjust the abi-list for noexceptions
---
...wn-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist
index 764e7c37daacb7..58a7307b311437 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist
@@ -493,6 +493,7 @@
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
+{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -1998,4 +1999,4 @@
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD0Ev', 'type': 'FUNC'}
-{'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD1Ev', 'type': 'FUNC'}
\ No newline at end of file
+{'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD1Ev', 'type': 'FUNC'}
More information about the libcxx-commits
mailing list