[libcxx-commits] [PATCH] D131408: [libc++] Make __libcpp_verbose_abort [[noreturn]]
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 8 08:55:34 PDT 2022
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This will allow using it in functions that are [[noreturn]] themselves.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131408
Files:
libcxx/include/__verbose_abort
libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp
libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp
libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
Index: libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
===================================================================
--- libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
+++ libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
@@ -16,15 +16,13 @@
// failures when back-deploying.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
-#include <cassert>
+#include <cstdlib>
-bool handler_called = false;
void std::__libcpp_verbose_abort(char const*, ...) {
- handler_called = true;
+ std::exit(EXIT_SUCCESS);
}
int main(int, char**) {
_LIBCPP_ASSERT(false, "message");
- assert(handler_called);
- return 0;
+ return EXIT_FAILURE;
}
Index: libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp
===================================================================
--- libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp
+++ libcxx/test/libcxx/assertions/customize_verbose_abort.pass.cpp
@@ -14,15 +14,13 @@
// failures when back-deploying.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
-#include <cassert>
+#include <cstdlib>
-bool handler_called = false;
void std::__libcpp_verbose_abort(char const*, ...) {
- handler_called = true;
+ std::exit(EXIT_SUCCESS);
}
int main(int, char**) {
_LIBCPP_ASSERT(false, "message");
- assert(handler_called);
- return 0;
+ return EXIT_FAILURE;
}
Index: libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp
===================================================================
--- libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp
+++ libcxx/test/libcxx/assertions/customize_verbose_abort.backdeployment.pass.cpp
@@ -9,20 +9,18 @@
// Make sure that we can enable assertions when we back-deploy to older platforms
// if we define _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED.
//
-// Note that this test isn't really different from customize_handler.pass.cpp when
-// run outside of back-deployment scenarios, but we still run it all the time.
+// Note that this test isn't really different from customize_verbose_abort.pass.cpp when
+// run outside of back-deployment scenarios, but we always want to run this test.
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
-#include <cassert>
+#include <cstdlib>
-bool handler_called = false;
void std::__libcpp_verbose_abort(char const*, ...) {
- handler_called = true;
+ std::exit(EXIT_SUCCESS);
}
int main(int, char**) {
_LIBCPP_ASSERT(false, "message");
- assert(handler_called);
- return 0;
+ return EXIT_FAILURE;
}
Index: libcxx/include/__verbose_abort
===================================================================
--- libcxx/include/__verbose_abort
+++ libcxx/include/__verbose_abort
@@ -29,7 +29,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline
+_LIBCPP_NORETURN _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline
void __libcpp_verbose_abort(const char *, ...) {
::abort();
}
@@ -40,7 +40,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
+_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
void __libcpp_verbose_abort(const char *__format, ...);
_LIBCPP_END_NAMESPACE_STD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131408.450832.patch
Type: text/x-patch
Size: 3533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220808/173cdbf2/attachment-0001.bin>
More information about the libcxx-commits
mailing list