Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / set-error-report-callback.cpp
blob42a57365d3914713b95dd3cc423a04d841e9bfbd
1 // RUN: %clangxx_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
3 #include <stdio.h>
4 #include <stdlib.h>
6 #include <sanitizer/hwasan_interface.h>
8 __attribute__((no_sanitize("hwaddress"))) extern "C" void callback(const char *msg) {
9 fprintf(stderr, "== error start\n%s\n== error end\n", msg);
12 int main() {
13 __hwasan_enable_allocator_tagging();
14 __hwasan_set_error_report_callback(&callback);
15 char *volatile p = (char *)malloc(16);
16 p[16] = 1;
17 free(p);
18 // CHECK: ERROR: HWAddressSanitizer:
19 // CHECK: WRITE of size 1 at
20 // CHECK: allocated by thread {{.*}} here:
21 // CHECK: Memory tags around the buggy address
23 // CHECK: == error start
24 // CHECK: ERROR: HWAddressSanitizer:
25 // CHECK: WRITE of size 1 at
26 // CHECK: allocated by thread {{.*}} here:
27 // CHECK: Memory tags around the buggy address
28 // CHECK: == error end