[libcxx-commits] [libcxx] [libc++] [libc++abi] Initialize exception directly in make_exception_ptr if __cxa_init_primary_exception is available in ABI-library (PR #65534)
James Y Knight via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 19 07:58:34 PDT 2023
================
@@ -51,11 +69,34 @@ 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)
+ 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>);
----------------
jyknight wrote:
Can't use `typeid` with -fno-rtti, but exceptions can be used with -fno-rtti so the previous impl would work. So this code should all be in a !_LIBCPP_HAS_NO_RTTI ifdef.
https://github.com/llvm/llvm-project/pull/65534
More information about the libcxx-commits
mailing list