brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · f24758a Raw
40 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&12// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out3// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&14// FileCheck %s <%t.out5// RUN: %clangxx_msan -O0 %s -o %t && env MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&16// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out7 8// Test how -fsanitize-recover=memory and MSAN_OPTIONS=keep_going affect reports9// from interceptors.10// -fsanitize-recover=memory provides the default value of keep_going flag, but is11// always overwritten by MSAN_OPTIONS12 13// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&114// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out15// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&116// FileCheck %s <%t.out17// RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && env MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&118// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out19 20// Test how legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going affect21// reports from interceptors.22 23// RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&124// FileCheck --check-prefix=CHECK-RECOVER %s <%t.out25 26#include <stdio.h>27#include <stdlib.h>28#include <string.h>29 30int main(int argc, char **argv) {31  char *volatile x = (char*)malloc(5 * sizeof(char));32  x[4] = 0;33  if (strlen(x) < 3)34    exit(0);35  fprintf(stderr, "Done\n");36  // CHECK-NOT: Done37  // CHECK-RECOVER: Done38  return 0;39}40