[libcxx-commits] [libcxx] [libc++][hardening] Add a greppable prefix to assertion messages. (PR #150560)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 30 01:40:26 PDT 2025


================
@@ -20,8 +20,8 @@
 #define _LIBCPP_ASSERT(expression, message)                                                                            \
   (__builtin_expect(static_cast<bool>(expression), 1)                                                                  \
        ? (void)0                                                                                                       \
-       : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING(            \
-             expression) " failed: " message "\n"))
+       : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(                                                      \
+             __LINE__) ": libc++ Hardening assertion " _LIBCPP_TOSTRING(expression) " failed: " message "\n"))
----------------
philnik777 wrote:

Re. `libc++` vs. some other spelling: I'd prefer `libc++`. You can simply grep for `Hardening assertion` if the pluses are too much for you. I doubt there is much of a clash with other libraries, and if there is, you probably care about these other library diagnostics as well. If you don't then oh well, you might have to escape them. It's not the end of the world.

I think I'm happy with the current message if we rename `_LIBCPP_ASSERT` to make it clear that it's an implementation detail of hardening assertions (in a separate patch). That wasn't clear to me until now.

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


More information about the libcxx-commits mailing list