[libcxx-commits] [libcxxabi] [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
Wed Oct 25 15:57:37 PDT 2023
================
@@ -50,15 +67,38 @@ 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_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>);
+ // 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();
+ }
+ }
----------------
EricWF wrote:
We should have an unreachable annotation at the bottom of this block.
https://github.com/llvm/llvm-project/pull/65534
More information about the libcxx-commits
mailing list