Skip to content

Commit

Permalink
Make __libcpp_verbose_abort() noexcept (it is already noreturn), to
Browse files Browse the repository at this point in the history
match  std::terminate(). Clang's function effect analysis can use this
to ignore such functions as being beyond its scope.
  • Loading branch information
Doug Wyatt committed Sep 25, 2024
1 parent 394f59c commit b99a598
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Deprecations and Removals
supported as an extension anymore, please migrate any code that uses e.g. ``std::vector<const T>`` to be
standards conforming.

- 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.)

Upcoming Deprecations and Removals
----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__verbose_abort
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _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_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;

// _LIBCPP_VERBOSE_ABORT(format, args...)
//
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/verbose_abort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {
_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
// Write message to stderr. We do this before formatting into a
// buffer so that we still get some information out if that fails.
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#include <__verbose_abort>
#include <cstdlib>

void std::__libcpp_verbose_abort(char const*, ...) {
std::exit(EXIT_SUCCESS);
}
void std::__libcpp_verbose_abort(char const*, ...) noexcept { std::exit(EXIT_SUCCESS); }

int main(int, char**) {
std::__libcpp_verbose_abort("%s", "message");
Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/support/check_assertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class DeathTest {
};

#ifdef _LIBCPP_VERSION
void std::__libcpp_verbose_abort(char const* format, ...) {
void std::__libcpp_verbose_abort(char const* format, ...) noexcept {
va_list args;
va_start(args, format);

Expand Down

0 comments on commit b99a598

Please sign in to comment.