[libcxx-commits] [libcxx] [libcxx] mark _LIBCPP_VERBOSE_{ABORT, TRAP} `nomerge` (PR #200078)

George Burgess IV via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 28 08:06:20 PDT 2026


https://github.com/gburgessiv updated https://github.com/llvm/llvm-project/pull/200078

>From f52035fc489f5b64ebda27b188b665301abc2c39 Mon Sep 17 00:00:00 2001
From: George Burgess IV <gbiv at google.com>
Date: Wed, 27 May 2026 16:59:12 -0600
Subject: [PATCH] [libcxx] mark _LIBCPP_VERBOSE_{ABORT,TRAP} `nomerge`

Suggested in #198831 - this may increase binary size slightly (since
`TRAP`s can no longer fold together), but makes attribution
significantly easier.
---
 libcxx/include/__cxx03/__verbose_abort | 4 ++--
 libcxx/include/__verbose_abort         | 4 ++--
 libcxx/include/__verbose_trap          | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libcxx/include/__cxx03/__verbose_abort b/libcxx/include/__cxx03/__verbose_abort
index 52d1297b65593..01da6ba5acbaa 100644
--- a/libcxx/include/__cxx03/__verbose_abort
+++ b/libcxx/include/__cxx03/__verbose_abort
@@ -40,9 +40,9 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const cha
 #  if !_LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT
 // The decltype is there to suppress -Wunused warnings in this configuration.
 void __use(const char*, ...);
-#    define _LIBCPP_VERBOSE_ABORT(...) (decltype(::std::__use(__VA_ARGS__))(), __builtin_abort())
+#    define _LIBCPP_VERBOSE_ABORT(...) ({ decltype(::std::__use(__VA_ARGS__))(); [[clang::__nomerge__]] __builtin_abort(); })
 #  else
-#    define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)
+#    define _LIBCPP_VERBOSE_ABORT(...) ({ [[clang::__nomerge__]] ::std::__libcpp_verbose_abort(__VA_ARGS__); })
 #  endif
 
 #endif // !defined(_LIBCPP_VERBOSE_ABORT)
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index 22df0e14463d5..1f95aac7932bc 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -42,9 +42,9 @@ _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 #  if !_LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT
 // The decltype is there to suppress -Wunused warnings in this configuration.
 void __use(const char*, ...);
-#    define _LIBCPP_VERBOSE_ABORT(...) (decltype(::std::__use(__VA_ARGS__))(), __builtin_abort())
+#    define _LIBCPP_VERBOSE_ABORT(...) ({ decltype(::std::__use(__VA_ARGS__))(); [[clang::__nomerge__]] __builtin_abort(); })
 #  else
-#    define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)
+#    define _LIBCPP_VERBOSE_ABORT(...) ({ [[clang::__nomerge__]] ::std::__libcpp_verbose_abort(__VA_ARGS__); })
 #  endif
 
 #endif // !defined(_LIBCPP_VERBOSE_ABORT)
diff --git a/libcxx/include/__verbose_trap b/libcxx/include/__verbose_trap
index 13ea727738c3b..60378b50e8b5d 100644
--- a/libcxx/include/__verbose_trap
+++ b/libcxx/include/__verbose_trap
@@ -23,12 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 // version before upstream Clang actually got the builtin.
 // TODO: Remove once AppleClang supports the two-arguments version of the builtin.
 #  if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
-#    define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap(message)
+#    define _LIBCPP_VERBOSE_TRAP(message) ({ [[clang::__nomerge__]] __builtin_verbose_trap(message); })
 #  else
-#    define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap("libc++", message)
+#    define _LIBCPP_VERBOSE_TRAP(message) ({ [[clang::__nomerge__]] __builtin_verbose_trap("libc++", message); })
 #  endif
 #else
-#  define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
+#  define _LIBCPP_VERBOSE_TRAP(message) ({ (void)message; [[clang::__nomerge__]] __builtin_trap(); })
 #endif
 
 _LIBCPP_END_NAMESPACE_STD



More information about the libcxx-commits mailing list