aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2024-09-19 23:07:27 -0700
committerGitHub <noreply@github.com>2024-09-19 23:07:27 -0700
commit5e7810882c8b58431358cd8da3a329a3c505de2c (patch)
tree16355c366b4a833ca06e9edea8bf7cae6c0147a8 /libcxx/src
parentd2d78e584b7489066772638d1c48db9d61f5a3f7 (diff)
downloadllvm-5e7810882c8b58431358cd8da3a329a3c505de2c.zip
llvm-5e7810882c8b58431358cd8da3a329a3c505de2c.tar.gz
llvm-5e7810882c8b58431358cd8da3a329a3c505de2c.tar.bz2
[libcxx] Use __libcpp_verbose_abort for error messages (#108873)
Rather than using the following sequence of calls: ``` fprintf(stderr, "..."); ::abort(); ``` We should use the following: ``` __libcpp_verbose_abort("...") ``` This simplifies the code and ensures the behavior is consistent across all call sites.
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/support/runtime/exception_fallback.ipp11
-rw-r--r--libcxx/src/support/runtime/exception_msvc.ipp9
-rw-r--r--libcxx/src/support/runtime/exception_pointer_unimplemented.ipp24
3 files changed, 15 insertions, 29 deletions
diff --git a/libcxx/src/support/runtime/exception_fallback.ipp b/libcxx/src/support/runtime/exception_fallback.ipp
index ca542c9..bedb16e 100644
--- a/libcxx/src/support/runtime/exception_fallback.ipp
+++ b/libcxx/src/support/runtime/exception_fallback.ipp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include <cstdio>
+#include <__verbose_abort>
namespace std {
@@ -39,13 +39,11 @@ terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__term
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
(*get_terminate())();
// handler should not return
- fprintf(stderr, "terminate_handler unexpectedly returned\n");
- ::abort();
+ __libcpp_verbose_abort("terminate_handler unexpectedly returned\n");
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
// handler should not throw exception
- fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
- ::abort();
+ __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n");
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
@@ -54,8 +52,7 @@ bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
int uncaught_exceptions() noexcept {
#warning uncaught_exception not yet implemented
- fprintf(stderr, "uncaught_exceptions not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("uncaught_exceptions not yet implemented\n");
}
exception::~exception() noexcept {}
diff --git a/libcxx/src/support/runtime/exception_msvc.ipp b/libcxx/src/support/runtime/exception_msvc.ipp
index 163aec0..869b64d 100644
--- a/libcxx/src/support/runtime/exception_msvc.ipp
+++ b/libcxx/src/support/runtime/exception_msvc.ipp
@@ -11,8 +11,7 @@
# error this header can only be used when targeting the MSVC ABI
#endif
-#include <stdio.h>
-#include <stdlib.h>
+#include <__verbose_abort>
extern "C" {
typedef void(__cdecl* terminate_handler)();
@@ -48,13 +47,11 @@ terminate_handler get_terminate() noexcept { return ::_get_terminate(); }
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
(*get_terminate())();
// handler should not return
- fprintf(stderr, "terminate_handler unexpectedly returned\n");
- ::abort();
+ __libcpp_verbose_abort("terminate_handler unexpectedly returned\n");
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
// handler should not throw exception
- fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
- ::abort();
+ __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n");
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
diff --git a/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp b/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp
index 1fe3127..05a71ce 100644
--- a/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp
@@ -7,33 +7,28 @@
//
//===----------------------------------------------------------------------===//
-#include <stdio.h>
-#include <stdlib.h>
+#include <__verbose_abort>
namespace std {
exception_ptr::~exception_ptr() noexcept {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
}
exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
}
exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
}
exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
}
nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
@@ -46,8 +41,7 @@ nested_exception::~nested_exception() noexcept {}
[[noreturn]] void nested_exception::rethrow_nested() const {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
#if 0
if (__ptr_ == nullptr)
terminate();
@@ -57,14 +51,12 @@ nested_exception::~nested_exception() noexcept {}
exception_ptr current_exception() noexcept {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
}
[[noreturn]] void rethrow_exception(exception_ptr p) {
#warning exception_ptr not yet implemented
- fprintf(stderr, "exception_ptr not yet implemented\n");
- ::abort();
+ __libcpp_verbose_abort("exception_ptr not yet implemented\n");
}
} // namespace std