brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 1c9d66a Raw
44 lines · cpp
1// Test that on the second entry to a function the origins are still right.2 3// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&14// RUN: FileCheck %s < %t.out5// RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&16// RUN: FileCheck %s < %t.out7// RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&18// RUN: FileCheck %s < %t.out9// RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&110// RUN: FileCheck %s < %t.out11 12// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %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 -O1 %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 -O2 %s -o %t && not %run %t >%t.out 2>&117// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out18// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&119// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out20 21#include <stdlib.h>22 23int t;24 25extern "C" void f(int depth) {26  if (depth)27    return f(depth - 1);28 29  volatile int x;30  t = x;31}32 33int main(int argc, char **argv) {34  f(1);35  return t;36  // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value37  // CHECK: {{#0 0x.* in main .*stack-origin2.cpp:}}[[@LINE-2]]38 39  // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame40  // CHECK-ORIGINS: {{#0 0x.* in f .*stack-origin2.cpp:}}[[@LINE-11]]41 42  // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin2.cpp:.* main}}43}44