[libc-commits] [libc] [libc] introduce sanitization check and heap walk utilities (PR #210373)

Daniel Thornburgh via libc-commits libc-commits at lists.llvm.org
Fri Jul 17 19:06:18 PDT 2026


================
@@ -20,6 +20,22 @@
 #define LIBC_ASSERT(COND) assert(COND)
 #endif // LIBC_ASSERT
 
+#ifndef LIBC_COPT_ENABLE_SANITIZATION
+#define LIBC_COPT_ENABLE_SANITIZATION false
+#endif
+
+#if LIBC_COPT_ENABLE_SANITIZATION
+#define LIBC_SANITIZATION_CHECK(COND)                                          \
+  do {                                                                         \
+    LIBC_ASSERT((COND) && "Runtime sanitization failed.");                     \
----------------
mysterymath wrote:

Ah, yeah, I meant callsite of the `LIBC_SANITIZATION_CHECK` macro. If this will show up as `assertion failed: <COND> && "Specific Message" && "Runtime sanitization failed.", it seems better to have "Specific Message" describe the actual error itself. That is, I'm uncertain of the value of a fixed sanitization message; it seems most useful as a greppable code, but otherwise, it seems like this could really just be `LIBC_ASSERT((COND))`, and if so, there might be some simpler macro stuffs that could do that.

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


More information about the libc-commits mailing list