[libcxx-commits] [libcxx] [libc++][hardening] Use `__builtin_verbose_trap` if it's available. (PR #84870)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 11 21:48:10 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Konstantin Varlamov (var-const)

<details>
<summary>Changes</summary>

Keep falling back to `__builtin_trap` on older versions of Clang.


---
Full diff: https://github.com/llvm/llvm-project/pull/84870.diff


1 Files Affected:

- (modified) libcxx/vendor/llvm/default_assertion_handler.in (+5-2) 


``````````diff
diff --git a/libcxx/vendor/llvm/default_assertion_handler.in b/libcxx/vendor/llvm/default_assertion_handler.in
index 8bc0553c078b34..8b892ff7b565eb 100644
--- a/libcxx/vendor/llvm/default_assertion_handler.in
+++ b/libcxx/vendor/llvm/default_assertion_handler.in
@@ -23,8 +23,11 @@
 
 #else
 
-// TODO(hardening): use `__builtin_verbose_trap(message)` once that becomes available.
-#  define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
+#  if __has_builtin(__builtin_verbose_trap)
+#    define _LIBCPP_ASSERTION_HANDLER(message) (__builtin_verbose_trap(message))
+#  else
+#    define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
+#  endif
 
 #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/84870


More information about the libcxx-commits mailing list