[PATCH] D131914: [ubsan-minimal] Report the address of an error

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 3 10:16:30 PDT 2022


MaskRay accepted this revision.
MaskRay added inline comments.
Herald added a subscriber: StephenFan.


================
Comment at: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:96
+// How many chars we need to reserve to print an address.
+static const unsigned int kAddrBuf = SANITIZER_WORDSIZE / 4;
+#define MSG_TMPL(msg) "ubsan: " msg " by 0x"
----------------
`constexpr unsigned kAddrBuf = ...`

static is redundant for const. But when constexpr works, prefer constexpr instead.


================
Comment at: compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c:11
   (void)t;
-  // CHECK: ubsan: alignment-assumption
+  // CHECK: ubsan: alignment-assumption by 0x{{[[:xdigit:]]+$}}
   // CHECK-NOT: alignment-assumption
----------------
Note: `[[#%x,]]` can replace `{{[[:xdigit:]]+}}` but here we match `$` too which requires `{{$}}`, I think xdigit is fine, too.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131914/new/

https://reviews.llvm.org/D131914



More information about the llvm-commits mailing list