Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / recover.cpp
blobcb9916ef4755b6bfc2ee94b0905727c6195e1614
1 // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
2 // FileCheck %s <%t.out
3 // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
4 // FileCheck %s <%t.out
5 // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
6 // FileCheck %s <%t.out
8 // Test behavior of -fsanitize-recover=memory and MSAN_OPTIONS=keep_going.
9 // -fsanitize-recover=memory provides the default value of keep_going flag; value
10 // of 1 can be overwritten by MSAN_OPTIONS, value of 0 can not.
12 // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&1
13 // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
14 // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
15 // FileCheck %s <%t.out
16 // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
17 // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
18 // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1
19 // FileCheck %s <%t.out
20 // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1
21 // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
23 // Basic test of legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going.
25 // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1
26 // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out
27 // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
28 // FileCheck %s <%t.out
30 #include <stdio.h>
31 #include <stdlib.h>
33 int main(int argc, char **argv) {
34 char *volatile x = (char*)malloc(5 * sizeof(char));
35 if (x[0])
36 exit(0);
37 fprintf(stderr, "Done\n");
38 // CHECK-NOT: Done
39 // CHECK-RECOVER: Done
40 return 0;