Skip to content

Commit 9548366

Browse files
authored
[libc++] Make __libcpp_verbose_abort() noexcept like std::terminate() (llvm#109151)
Make __libcpp_verbose_abort() noexcept (it is already noreturn), to match std::terminate(). Clang's function effect analysis can use this to ignore such functions as being beyond its scope. (See llvm#99656).
1 parent a1ac5a5 commit 9548366

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ Deprecations and Removals
8282
were private but could cause ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in
8383
LLVM 20.
8484

85+
- 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.)
87+
8588
Upcoming Deprecations and Removals
8689
----------------------------------
8790

libcxx/include/__verbose_abort

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
// This function should never be called directly from the code -- it should only be called through
2222
// the _LIBCPP_VERBOSE_ABORT macro.
2323
[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
24-
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...);
24+
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
2525

2626
// _LIBCPP_VERBOSE_ABORT(format, args...)
2727
//

libcxx/src/verbose_abort.cpp

Lines changed: 1 addition & 1 deletion
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, ...) {
31+
_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) 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
{

libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
#include <__verbose_abort>
1616
#include <cstdlib>
1717

18-
void std::__libcpp_verbose_abort(char const*, ...) {
19-
std::exit(EXIT_SUCCESS);
20-
}
18+
void std::__libcpp_verbose_abort(char const*, ...) _NOEXCEPT { std::exit(EXIT_SUCCESS); }
2119

2220
int main(int, char**) {
2321
std::__libcpp_verbose_abort("%s", "message");

libcxx/test/support/check_assertion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class DeathTest {
334334
};
335335

336336
#ifdef _LIBCPP_VERSION
337-
void std::__libcpp_verbose_abort(char const* format, ...) {
337+
void std::__libcpp_verbose_abort(char const* format, ...) noexcept {
338338
va_list args;
339339
va_start(args, format);
340340

0 commit comments

Comments
 (0)