[libcxx-commits] [libcxx] 9548366 - [libc++] Make __libcpp_verbose_abort() noexcept like std::terminate() (#109151)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 17 07:38:33 PDT 2024
Author: Doug Wyatt
Date: 2024-10-17T10:38:29-04:00
New Revision: 954836634abb446f18719b14120c386a929a42d1
URL: https://github.com/llvm/llvm-project/commit/954836634abb446f18719b14120c386a929a42d1
DIFF: https://github.com/llvm/llvm-project/commit/954836634abb446f18719b14120c386a929a42d1.diff
LOG: [libc++] Make __libcpp_verbose_abort() noexcept like std::terminate() (#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
https://github.com/llvm/llvm-project/pull/99656).
Added:
Modified:
libcxx/docs/ReleaseNotes/20.rst
libcxx/include/__verbose_abort
libcxx/src/verbose_abort.cpp
libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp
libcxx/test/support/check_assertion.h
Removed:
################################################################################
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 3a66aecaf57cb2..abd6764579e52a 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -82,6 +82,9 @@ Deprecations and Removals
were private but could cause 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.)
+
Upcoming Deprecations and Removals
----------------------------------
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index 244278aec652d2..73295cae426102 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -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...)
//
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..21e9003c30b704 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 <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");
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);
More information about the libcxx-commits
mailing list