brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 5fd9084 Raw
32 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&12// RUN: FileCheck %s < %t.out3// RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&14// RUN: FileCheck %s < %t.out5// RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&16// RUN: FileCheck %s < %t.out7// RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&18// RUN: FileCheck %s < %t.out9 10// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&111// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out12// RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&113// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out14// RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&115// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out16// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&117// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out18 19#include <stdlib.h>20int main(int argc, char **argv) {21  char *volatile x = (char*)malloc(5 * sizeof(char));22  return *x;23  // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value24  // CHECK: {{#0 0x.* in main .*heap-origin.cpp:}}[[@LINE-2]]25 26  // CHECK-ORIGINS: Uninitialized value was created by a heap allocation27  // CHECK-ORIGINS: {{#0 0x.* in .*malloc}}28  // CHECK-ORIGINS: {{#1 0x.* in main .*heap-origin.cpp:}}[[@LINE-7]]29 30  // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*heap-origin.cpp:.* main}}31}32