[libcxx-commits] [libcxx] [libc++] fix std::make_exception_ptr interaction with ObjC (PR #135386)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 14 12:05:08 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: None (itrofimow)
<details>
<summary>Changes</summary>
Clang treats throwing/catching ObjC types differently from C++ types, and omitting the `throw` in `std::make_exception_ptr` breaks ObjC invariants about how types are thrown/caught
---
Full diff: https://github.com/llvm/llvm-project/pull/135386.diff
1 Files Affected:
- (modified) libcxx/include/__exception/exception_ptr.h (+2-1)
``````````diff
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index dac5b00b57fe3..167aa4d9b367a 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -92,7 +92,8 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
template <class _Ep>
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
# if _LIBCPP_HAS_EXCEPTIONS
-# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L
+ // Clang treats throwing ObjC types differently, and we have to preserve original throw-ing behavior
+# if !defined(__OBJC__) && _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L
using _Ep2 = __decay_t<_Ep>;
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
``````````
</details>
https://github.com/llvm/llvm-project/pull/135386
More information about the libcxx-commits
mailing list