[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)

James Y Knight via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 19 07:58:37 PDT 2023


================
@@ -36,13 +36,19 @@ 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
 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();
----------------
jyknight wrote:

Coordinating to avoid divergence/ABI incompatibility with GCC is important, so that we're implementing a pre-existing GCC ABI extension is very important to mention!

The context that this is an extension that GCC already implements, and that LLVM is now implementing compatibly, should to be mentioned in the PR description and in the comments for this function. (Presuming that our implementation _is_ ABI-compatible -- which it of course needs to be!)

Given that, IMO, it's fine to make this ABI extension.

https://github.com/llvm/llvm-project/pull/65534


More information about the libcxx-commits mailing list