[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:38:59 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 1/2] [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
>From c9f28276d50fb7a0c5eaf86e8ae7451f1f1ea9af Mon Sep 17 00:00:00 2001
From: George Burgess IV <gbiv at google.com>
Date: Thu, 28 May 2026 09:29:58 -0600
Subject: [PATCH 2/2] fix clang-format
---
libcxx/include/__cxx03/__verbose_abort | 6 +++++-
libcxx/include/__verbose_abort | 10 +++++++---
libcxx/include/__verbose_trap | 6 +++++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/libcxx/include/__cxx03/__verbose_abort b/libcxx/include/__cxx03/__verbose_abort
index 01da6ba5acbaa..f664f362b3ba2 100644
--- a/libcxx/include/__cxx03/__verbose_abort
+++ b/libcxx/include/__cxx03/__verbose_abort
@@ -40,7 +40,11 @@ _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__))(); [[clang::__nomerge__]] __builtin_abort(); })
+# define _LIBCPP_VERBOSE_ABORT(...) \
+ ({ \
+ decltype(::std::__use(__VA_ARGS__))(); \
+ [[clang::__nomerge__]] __builtin_abort(); \
+ })
# else
# define _LIBCPP_VERBOSE_ABORT(...) ({ [[clang::__nomerge__]] ::std::__libcpp_verbose_abort(__VA_ARGS__); })
# endif
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index 1f95aac7932bc..748661acbd596 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -21,8 +21,8 @@ _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.
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
- __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
+[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
+_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
// _LIBCPP_VERBOSE_ABORT(format, args...)
@@ -42,7 +42,11 @@ _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__))(); [[clang::__nomerge__]] __builtin_abort(); })
+# define _LIBCPP_VERBOSE_ABORT(...) \
+ ({ \
+ decltype(::std::__use(__VA_ARGS__))(); \
+ [[clang::__nomerge__]] __builtin_abort(); \
+ })
# else
# define _LIBCPP_VERBOSE_ABORT(...) ({ [[clang::__nomerge__]] ::std::__libcpp_verbose_abort(__VA_ARGS__); })
# endif
diff --git a/libcxx/include/__verbose_trap b/libcxx/include/__verbose_trap
index 867369afcfc1b..8aec573c8316e 100644
--- a/libcxx/include/__verbose_trap
+++ b/libcxx/include/__verbose_trap
@@ -21,7 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if __has_builtin(__builtin_verbose_trap)
# define _LIBCPP_VERBOSE_TRAP(message) ({ [[clang::__nomerge__]] __builtin_verbose_trap("libc++", message); })
#else
-# define _LIBCPP_VERBOSE_TRAP(message) ({ (void)message; [[clang::__nomerge__]] __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