Skip to content

Commit d269ec3

Browse files
authored
[libc++] Add a escape hatch for making __libcpp_verbose_abort non-noexcept again (#113310)
This allows a slightly smoother transition for people after #109151, as requested on that PR.
1 parent e2766b2 commit d269ec3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

libcxx/docs/ReleaseNotes/20.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ Deprecations and Removals
8383
ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in LLVM 20.
8484

8585
- The function ``__libcpp_verbose_abort()`` is now ``noexcept``, to match ``std::terminate()``. (The combination of
86-
``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.)
86+
``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.) For backwards compatibility,
87+
the ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro can be defined to make the function non-``noexcept``. That macro
88+
will be removed in LLVM 21.
8789

8890
Upcoming Deprecations and Removals
8991
----------------------------------
@@ -106,6 +108,9 @@ LLVM 21
106108
If you are using C++03 in your project, you should consider moving to a newer version of the Standard to get the most
107109
out of libc++.
108110

111+
- The ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro will be removed in LLVM 21, making ``std::__libcpp_verbose_abort``
112+
unconditionally ``noexcept``.
113+
109114

110115
ABI Affecting Changes
111116
---------------------

libcxx/include/__verbose_abort

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@
1818

1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

21+
#if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT)
22+
# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
23+
#else
24+
# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT
25+
#endif
26+
2127
// This function should never be called directly from the code -- it should only be called through
2228
// the _LIBCPP_VERBOSE_ABORT macro.
23-
[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
24-
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
29+
[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
30+
__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
2531

2632
// _LIBCPP_VERBOSE_ABORT(format, args...)
2733
//

libcxx/src/verbose_abort.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C" void android_set_abort_message(const char* msg);
2828

2929
_LIBCPP_BEGIN_NAMESPACE_STD
3030

31-
_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
31+
_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
3232
// Write message to stderr. We do this before formatting into a
3333
// buffer so that we still get some information out if that fails.
3434
{

0 commit comments

Comments
 (0)