[libcxx-commits] [libcxx] [libc++] NFC: only forward-declare ABI-functions in exception_ptr.h if the are meant to be used (PR #84707)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 10 19:23:40 PDT 2024


https://github.com/itrofimow updated https://github.com/llvm/llvm-project/pull/84707

>From 9daa1b31a30a87805d6faa1c1b3887badfa6bc8c Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Mon, 11 Mar 2024 05:02:22 +0300
Subject: [PATCH] [libc++] NFC: only fwd-declare ABI-functions in
 exception_ptr.h conditionally

This patch fixes the unconditional fodward-declarations of ABI-functions in
exception_ptr.h, and makes it dependendent on the availability macro, as it
should've been from the beginning.
The declarations being unconditional break the build with libcxxrt
before 045c52ce821388f4ae4d119fe4fb75f1eb547b85, now the are opt-out.

* libcxx/include/__exception/exception_ptr.h
  Only forward-declare ABI-functions if they are meant to be used.
---
 libcxx/include/__exception/exception_ptr.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 53e2f718bc1b35..c9027de9238cdd 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -26,6 +26,8 @@
 
 #ifndef _LIBCPP_ABI_MICROSOFT
 
+#  if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
+
 namespace __cxxabiv1 {
 
 extern "C" {
@@ -37,14 +39,16 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
     void*,
     std::type_info*,
     void(
-#  if defined(_WIN32)
+#    if defined(_WIN32)
         __thiscall
-#  endif
+#    endif
             *)(void*)) throw();
 }
 
 } // namespace __cxxabiv1
 
+#  endif
+
 #endif
 
 namespace std { // purposefully not using versioning namespace



More information about the libcxx-commits mailing list