[libcxx-commits] [libcxx] [libc++] Add a escape hatch for making __libcpp_verbose_abort non-noexcept again (PR #113310)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 22 05:57:43 PDT 2024
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/113310
>From 7630669e70cde979138f155d8e64400a3ce2f2e6 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 22 Oct 2024 08:48:23 -0400
Subject: [PATCH 1/2] [libc++] Add a escape hatch for making
__libcpp_verbose_abort non-noexcept again
---
libcxx/docs/ReleaseNotes/20.rst | 7 ++++++-
libcxx/include/__verbose_abort | 8 +++++++-
libcxx/src/verbose_abort.cpp | 2 +-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 44912d2ddafac6..39546493ae8d6f 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -83,7 +83,9 @@ Deprecations and Removals
ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in LLVM 20.
- The function ``__libcpp_verbose_abort()`` is now ``noexcept``, to match ``std::terminate()``. (The combination of
- ``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.)
+ ``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.) For backwards compatibility,
+ the ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro can be defined to make the function non-``noexcept``. That macro
+ will be removed in LLVM 21.
Upcoming Deprecations and Removals
----------------------------------
@@ -106,6 +108,9 @@ LLVM 21
If you are using C++03 in your project, you should consider moving to a newer version of the Standard to get the most
out of libc++.
+- The ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro will be removed in LLVM 21, making ``std::__libcpp_verbose_abort``
+ unconditionally ``noexcept``.
+
ABI Affecting Changes
---------------------
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index 73295cae426102..c975ea7f91c919 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -18,10 +18,16 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT)
+# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
+#else
+# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT
+#endif
+
// This function should never be called directly from the code -- it should only be called through
// the _LIBCPP_VERBOSE_ABORT macro.
[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
-_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
+_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
// _LIBCPP_VERBOSE_ABORT(format, args...)
//
diff --git a/libcxx/src/verbose_abort.cpp b/libcxx/src/verbose_abort.cpp
index 0019063405a810..6704709d247ca1 100644
--- a/libcxx/src/verbose_abort.cpp
+++ b/libcxx/src/verbose_abort.cpp
@@ -28,7 +28,7 @@ extern "C" void android_set_abort_message(const char* msg);
_LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
+_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
// Write message to stderr. We do this before formatting into a
// buffer so that we still get some information out if that fails.
{
>From fdf4be83c35fb4530b696a2e3550d031fc120c41 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 22 Oct 2024 08:57:33 -0400
Subject: [PATCH 2/2] Format
---
libcxx/include/__verbose_abort | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index c975ea7f91c919..2d45cd0eb7f5d3 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -26,8 +26,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// This function should never be called directly from the code -- it should only be called through
// the _LIBCPP_VERBOSE_ABORT macro.
-[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
-_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
+[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
+ __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
// _LIBCPP_VERBOSE_ABORT(format, args...)
//
More information about the libcxx-commits
mailing list