[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / msan / death-callback.cpp
bloba22514d0c38b63257416270d0ee00ef58d314b08
1 // RUN: %clangxx_msan -DERROR %s -o %t && not %run %t 2>&1 | \
2 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCB
3 // RUN: %clangxx_msan -DERROR -DMSANCB_SET %s -o %t && not %run %t 2>&1 | \
4 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CB
5 // RUN: %clangxx_msan -DERROR -DMSANCB_SET -DMSANCB_CLEAR %s -o %t && not %run %t 2>&1 | \
6 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCB
7 // RUN: %clangxx_msan -DMSANCB_SET %s -o %t && %run %t 2>&1 | \
8 // RUN: FileCheck %s --check-prefixes=SUCCEED,CHECK-NOCB
10 #include <sanitizer/msan_interface.h>
11 #include <stdio.h>
12 #include <stdlib.h>
14 void cb(void) {
15 fprintf(stderr, "msan-death-callback\n");
18 int main(int argc, char **argv) {
19 int *volatile p = (int *)malloc(sizeof(int));
20 *p = 42;
21 free(p);
23 #ifdef MSANCB_SET
24 __msan_set_death_callback(cb);
25 #endif
27 #ifdef MSANCB_CLEAR
28 __msan_set_death_callback(0);
29 #endif
31 #ifdef ERROR
32 if (*p)
33 exit(0);
34 #endif
35 // CHECK-CB: msan-death-callback
36 // CHECK-NOCB-NOT: msan-death-callback
38 // CHECK-NOT: done
39 // SUCCEED: done
40 fprintf(stderr, "done\n");
41 return 0;