[libcxx-commits] [libcxxabi] [libcxx] [libcxxabi] Dont throw in make exception ptr if __cxa_init_primary_exception is available (PR #65534)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 6 14:33:32 PDT 2023
https://github.com/itrofimow created https://github.com/llvm/llvm-project/pull/65534:
None
>From fc0df4204eb4045a2e752fbf1cce8d69f7c8882c 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/11] [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 85cb4b36b8119b..8374eec2ed1c98 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 5a347d8276ebba..96d96adaa64e40 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).
@@ -256,17 +270,10 @@ exception.
void
__cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
__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 534f4a7e1cc968c89ce1d35b8a4bd0b4e86c0033 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/11] + 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 8374eec2ed1c98..f5bf4dec05e4c9 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 96d96adaa64e40..2c50f034be7f0e 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.
@@ -269,11 +268,11 @@ exception.
*/
void
__cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
- __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 140fe91a2dfb004aafc979d208034b4a58f39c7b 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/11] 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 | 352 +-----------------
.../runtime/exception_pointer_cxxabi.ipp | 21 +-
6 files changed, 360 insertions(+), 367 deletions(-)
create mode 100644 libcxx/include/__typeinfo/typeinfo.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 28028955606118..5748b18f3e7df7 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -688,6 +688,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 9c77bfe02ca59a..a6e19a9177864f 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1266,6 +1266,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 0dc9f09b9e25f9..ac0d8b3f6e973b 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -57,362 +57,14 @@ 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
-#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
-
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cstdlib>
# include <exception>
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 e99f726b9c4a5ecf6c2445fffef080e26cff5877 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/11] + 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 ae6a3330b9987db8d677e737cc82752214e090a0 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/11] wip on making the build green
---
libcxx/include/CMakeLists.txt | 2 +-
libcxx/utils/data/ignore_format.txt | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 5748b18f3e7df7..ff88aa5444a445 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -688,7 +688,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
@@ -827,6 +826,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/auto_cast.h
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 20384d1c769e0a..11bce6856de8c2 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -468,6 +468,7 @@ libcxx/include/__tuple/tuple_indices.h
libcxx/include/__tuple/tuple_like_ext.h
libcxx/include/__tuple/tuple_size.h
libcxx/include/__tuple/tuple_types.h
+libcxx/include/__typeinfo/typeinfo.h
libcxx/include/typeindex
libcxx/include/typeinfo
libcxx/include/uchar.h
>From e1d21e3ed408e9843f3d5c49ac3ad55ddce613c5 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/11] 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 a6e19a9177864f..441a3978b20c38 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1266,7 +1266,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 ac0d8b3f6e973b..e869cd5e675078 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 2487cb5d640594..675f844fba3cb3 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -217,6 +217,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 3f211ab8863c7b..2b7841dac486d9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -217,6 +217,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 35701d508e4995..9fec520fd85508 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -217,6 +217,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 35701d508e4995..9fec520fd85508 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -217,6 +217,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 0db9a188bf28df..3807110a32e429 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -224,6 +224,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 50a0bcfbca0c4a..35b879acf3191a 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
@@ -286,6 +288,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 50a0bcfbca0c4a..35b879acf3191a 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
@@ -286,6 +288,7 @@ future ratio
future stdexcept
future string
future thread
+future type_traits
future typeinfo
future version
initializer_list cstddef
>From fdef6f986eff103c6774db45bc3c25c2807d8aca Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 30 Aug 2023 11:48:05 +0300
Subject: [PATCH 07/11] regenerate ignore_format.txt
---
libcxx/utils/data/ignore_format.txt | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 11bce6856de8c2..01626ef852f0a6 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -124,6 +124,7 @@ libcxx/include/__chrono/literals.h
libcxx/include/__chrono/monthday.h
libcxx/include/__chrono/month.h
libcxx/include/__chrono/month_weekday.h
+libcxx/include/__chrono/statically_widen.h
libcxx/include/__chrono/steady_clock.h
libcxx/include/__chrono/system_clock.h
libcxx/include/__chrono/time_point.h
@@ -146,7 +147,9 @@ libcxx/include/__compare/strong_order.h
libcxx/include/__compare/three_way_comparable.h
libcxx/include/__compare/weak_order.h
libcxx/include/complex
+libcxx/include/__concepts/swappable.h
libcxx/include/condition_variable
+libcxx/include/__config
libcxx/include/__coroutine/coroutine_handle.h
libcxx/include/__coroutine/coroutine_traits.h
libcxx/include/__coroutine/noop_coroutine_handle.h
@@ -157,8 +160,10 @@ libcxx/include/cuchar
libcxx/include/__debug_utils/randomize_range.h
libcxx/include/deque
libcxx/include/errno.h
+libcxx/include/__exception/exception_ptr.h
libcxx/include/expected
libcxx/include/__expected/expected.h
+libcxx/include/__expected/unexpected.h
libcxx/include/experimental/__config
libcxx/include/experimental/iterator
libcxx/include/experimental/map
@@ -336,6 +341,7 @@ libcxx/include/mutex
libcxx/include/new
libcxx/include/__node_handle
libcxx/include/numbers
+libcxx/include/numeric
libcxx/include/__numeric/accumulate.h
libcxx/include/__numeric/adjacent_difference.h
libcxx/include/__numeric/exclusive_scan.h
@@ -351,6 +357,7 @@ libcxx/include/__numeric/transform_inclusive_scan.h
libcxx/include/__numeric/transform_reduce.h
libcxx/include/optional
libcxx/include/ostream
+libcxx/include/print
libcxx/include/queue
libcxx/include/__random/bernoulli_distribution.h
libcxx/include/__random/binomial_distribution.h
@@ -414,6 +421,7 @@ libcxx/include/__ranges/single_view.h
libcxx/include/__ranges/size.h
libcxx/include/__ranges/subrange.h
libcxx/include/__ranges/take_view.h
+libcxx/include/__ranges/to.h
libcxx/include/__ranges/transform_view.h
libcxx/include/__ranges/view_interface.h
libcxx/include/__ranges/views.h
@@ -452,8 +460,12 @@ libcxx/include/__support/newlib/xlocale.h
libcxx/include/__support/win32/locale_win32.h
libcxx/include/__support/xlocale/__nop_locale_mgmt.h
libcxx/include/__system_error/errc.h
+libcxx/include/__system_error/error_category.h
+libcxx/include/__system_error/error_code.h
+libcxx/include/__system_error/error_condition.h
libcxx/include/thread
libcxx/include/__thread/formatter.h
+libcxx/include/__thread/id.h
libcxx/include/__threading_support
libcxx/include/__thread/poll_with_backoff.h
libcxx/include/__thread/this_thread.h
@@ -468,9 +480,12 @@ libcxx/include/__tuple/tuple_indices.h
libcxx/include/__tuple/tuple_like_ext.h
libcxx/include/__tuple/tuple_size.h
libcxx/include/__tuple/tuple_types.h
-libcxx/include/__typeinfo/typeinfo.h
libcxx/include/typeindex
-libcxx/include/typeinfo
+libcxx/include/__typeinfo/typeinfo.h
+libcxx/include/type_traits
+libcxx/include/__type_traits/is_nothrow_copy_constructible.h
+libcxx/include/__type_traits/is_nothrow_move_constructible.h
+libcxx/include/__type_traits/promote.h
libcxx/include/uchar.h
libcxx/include/unordered_map
libcxx/include/unordered_set
@@ -484,6 +499,7 @@ libcxx/include/__utility/pair.h
libcxx/include/__utility/piecewise_construct.h
libcxx/include/__utility/priority_tag.h
libcxx/include/__utility/rel_ops.h
+libcxx/include/__utility/terminate_on_exception.h
libcxx/include/__utility/to_underlying.h
libcxx/include/__utility/unreachable.h
libcxx/include/valarray
@@ -533,6 +549,7 @@ libcxx/src/mutex.cpp
libcxx/src/mutex_destructor.cpp
libcxx/src/new.cpp
libcxx/src/optional.cpp
+libcxx/src/print.cpp
libcxx/src/pstl/libdispatch.cpp
libcxx/src/random.cpp
libcxx/src/random_shuffle.cpp
>From 11f356e983ff4920346fa9cddef77bb89e692004 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 08/11] bits of formatting
---
libcxx/include/module.modulemap.in | 4 ++--
.../runtime/exception_pointer_cxxabi.ipp | 2 +-
libcxx/utils/data/ignore_format.txt | 20 +------------------
3 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 441a3978b20c38..9fd39e6e8299d7 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1266,8 +1266,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);
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 01626ef852f0a6..20384d1c769e0a 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -124,7 +124,6 @@ libcxx/include/__chrono/literals.h
libcxx/include/__chrono/monthday.h
libcxx/include/__chrono/month.h
libcxx/include/__chrono/month_weekday.h
-libcxx/include/__chrono/statically_widen.h
libcxx/include/__chrono/steady_clock.h
libcxx/include/__chrono/system_clock.h
libcxx/include/__chrono/time_point.h
@@ -147,9 +146,7 @@ libcxx/include/__compare/strong_order.h
libcxx/include/__compare/three_way_comparable.h
libcxx/include/__compare/weak_order.h
libcxx/include/complex
-libcxx/include/__concepts/swappable.h
libcxx/include/condition_variable
-libcxx/include/__config
libcxx/include/__coroutine/coroutine_handle.h
libcxx/include/__coroutine/coroutine_traits.h
libcxx/include/__coroutine/noop_coroutine_handle.h
@@ -160,10 +157,8 @@ libcxx/include/cuchar
libcxx/include/__debug_utils/randomize_range.h
libcxx/include/deque
libcxx/include/errno.h
-libcxx/include/__exception/exception_ptr.h
libcxx/include/expected
libcxx/include/__expected/expected.h
-libcxx/include/__expected/unexpected.h
libcxx/include/experimental/__config
libcxx/include/experimental/iterator
libcxx/include/experimental/map
@@ -341,7 +336,6 @@ libcxx/include/mutex
libcxx/include/new
libcxx/include/__node_handle
libcxx/include/numbers
-libcxx/include/numeric
libcxx/include/__numeric/accumulate.h
libcxx/include/__numeric/adjacent_difference.h
libcxx/include/__numeric/exclusive_scan.h
@@ -357,7 +351,6 @@ libcxx/include/__numeric/transform_inclusive_scan.h
libcxx/include/__numeric/transform_reduce.h
libcxx/include/optional
libcxx/include/ostream
-libcxx/include/print
libcxx/include/queue
libcxx/include/__random/bernoulli_distribution.h
libcxx/include/__random/binomial_distribution.h
@@ -421,7 +414,6 @@ libcxx/include/__ranges/single_view.h
libcxx/include/__ranges/size.h
libcxx/include/__ranges/subrange.h
libcxx/include/__ranges/take_view.h
-libcxx/include/__ranges/to.h
libcxx/include/__ranges/transform_view.h
libcxx/include/__ranges/view_interface.h
libcxx/include/__ranges/views.h
@@ -460,12 +452,8 @@ libcxx/include/__support/newlib/xlocale.h
libcxx/include/__support/win32/locale_win32.h
libcxx/include/__support/xlocale/__nop_locale_mgmt.h
libcxx/include/__system_error/errc.h
-libcxx/include/__system_error/error_category.h
-libcxx/include/__system_error/error_code.h
-libcxx/include/__system_error/error_condition.h
libcxx/include/thread
libcxx/include/__thread/formatter.h
-libcxx/include/__thread/id.h
libcxx/include/__threading_support
libcxx/include/__thread/poll_with_backoff.h
libcxx/include/__thread/this_thread.h
@@ -481,11 +469,7 @@ libcxx/include/__tuple/tuple_like_ext.h
libcxx/include/__tuple/tuple_size.h
libcxx/include/__tuple/tuple_types.h
libcxx/include/typeindex
-libcxx/include/__typeinfo/typeinfo.h
-libcxx/include/type_traits
-libcxx/include/__type_traits/is_nothrow_copy_constructible.h
-libcxx/include/__type_traits/is_nothrow_move_constructible.h
-libcxx/include/__type_traits/promote.h
+libcxx/include/typeinfo
libcxx/include/uchar.h
libcxx/include/unordered_map
libcxx/include/unordered_set
@@ -499,7 +483,6 @@ libcxx/include/__utility/pair.h
libcxx/include/__utility/piecewise_construct.h
libcxx/include/__utility/priority_tag.h
libcxx/include/__utility/rel_ops.h
-libcxx/include/__utility/terminate_on_exception.h
libcxx/include/__utility/to_underlying.h
libcxx/include/__utility/unreachable.h
libcxx/include/valarray
@@ -549,7 +532,6 @@ libcxx/src/mutex.cpp
libcxx/src/mutex_destructor.cpp
libcxx/src/new.cpp
libcxx/src/optional.cpp
-libcxx/src/print.cpp
libcxx/src/pstl/libdispatch.cpp
libcxx/src/random.cpp
libcxx/src/random_shuffle.cpp
>From fbe75a52a64c9b4eea053f1a8ed7812c227cd8b6 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 30 Aug 2023 14:42:45 +0300
Subject: [PATCH 09/11] wip on making the build green
---
libcxx/utils/data/ignore_format.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 20384d1c769e0a..d4f9f963793c37 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -468,8 +468,8 @@ libcxx/include/__tuple/tuple_indices.h
libcxx/include/__tuple/tuple_like_ext.h
libcxx/include/__tuple/tuple_size.h
libcxx/include/__tuple/tuple_types.h
+libcxx/include/__typeinfo/typeinfo.h
libcxx/include/typeindex
-libcxx/include/typeinfo
libcxx/include/uchar.h
libcxx/include/unordered_map
libcxx/include/unordered_set
>From 6933d582d12d17c321940ae7be36dfb2a7e9a0be Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Wed, 30 Aug 2023 16:37:23 +0300
Subject: [PATCH 10/11] wip on making the build green
---
libcxx/utils/data/ignore_format.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index d4f9f963793c37..8207f569fdc704 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -468,7 +468,6 @@ libcxx/include/__tuple/tuple_indices.h
libcxx/include/__tuple/tuple_like_ext.h
libcxx/include/__tuple/tuple_size.h
libcxx/include/__tuple/tuple_types.h
-libcxx/include/__typeinfo/typeinfo.h
libcxx/include/typeindex
libcxx/include/uchar.h
libcxx/include/unordered_map
>From 969531a31e05c5cd3587b870e7b19896476eb4b2 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 11/11] 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
More information about the libcxx-commits
mailing list