[libcxx-commits] [libcxx] [libc++][hardening] Add a greppable prefix to assertion messages. (PR #150560)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 25 01:30:14 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"))
----------------
var-const wrote:
Thanks for the feedback!
To be clear about the use case, the main intent is to support people turning on the upcoming `observe` mode and deliberately "grepping" (whichever actual tool they use) their logs for libc++ Hardening assertions. I presume we will document the prefix and they will be searching for a specific string -- for me at least, the intent is not to make our Hardening stand out in general. Of course, we should still strive to make the prefix readable and reasonable.
> I guess `libc++` will be more familiar to end-users than `libcxx`.
This is a good point.
> Would it also make sense to use `h` instead of `H` in `Hardening`?
I don't feel super strongly about it, but recently I've been deliberately trying to find a way to make it clearer that we use the word "hardening" in a very specific sense, as the name of our specific mechanism, and not just in the general sense of making things more robust and secure. Capitalization is supposed to stress that this refers to a specific feature.
https://github.com/llvm/llvm-project/pull/150560
More information about the libcxx-commits
mailing list