From 44b6614333dd611d057d56988c315f13752303f6 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Wed, 18 Sep 2024 07:19:02 -0700 Subject: [PATCH 1/3] 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. --- libcxx/include/__verbose_abort | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort index 244278aec652d2..45a0add493c17d 100644 --- a/libcxx/include/__verbose_abort +++ b/libcxx/include/__verbose_abort @@ -21,7 +21,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_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) +_NOEXCEPT; // _LIBCPP_VERBOSE_ABORT(format, args...) // From 78526c0e081ece04021ec118fdb6bee63a4b5d73 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Wed, 18 Sep 2024 08:04:55 -0700 Subject: [PATCH 2/3] annotate implementations --- libcxx/include/__verbose_abort | 3 +-- libcxx/src/verbose_abort.cpp | 2 +- .../assertions/customize_verbose_abort.link-time.pass.cpp | 4 +--- libcxx/test/support/check_assertion.h | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort index 45a0add493c17d..73295cae426102 100644 --- a/libcxx/include/__verbose_abort +++ b/libcxx/include/__verbose_abort @@ -21,8 +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, ...) -_NOEXCEPT; +_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT; // _LIBCPP_VERBOSE_ABORT(format, args...) // diff --git a/libcxx/src/verbose_abort.cpp b/libcxx/src/verbose_abort.cpp index 719134e2ae554d..0019063405a810 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, ...) { +_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. { diff --git a/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp b/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp index 9298a1e365fca4..2d30a39e37b159 100644 --- a/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp +++ b/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp @@ -15,9 +15,7 @@ #include <__verbose_abort> #include -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"); diff --git a/libcxx/test/support/check_assertion.h b/libcxx/test/support/check_assertion.h index 47ebfeeeefc0f4..a279400d651b48 100644 --- a/libcxx/test/support/check_assertion.h +++ b/libcxx/test/support/check_assertion.h @@ -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); From e8d6586b1a9af791bca07afae2bb693ab2a047b4 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Thu, 19 Sep 2024 09:15:45 -0700 Subject: [PATCH 3/3] Add a release note. --- libcxx/docs/ReleaseNotes/20.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst index 82c8286b69e23c..70e1f56df1b627 100644 --- a/libcxx/docs/ReleaseNotes/20.rst +++ b/libcxx/docs/ReleaseNotes/20.rst @@ -77,6 +77,9 @@ Deprecations and Removals supported as an extension anymore, please migrate any code that uses e.g. ``std::vector`` 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 ----------------------------------