diff options
author | Fangrui Song <maskray@google.com> | 2019-08-02 06:07:05 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-08-02 06:07:05 +0000 |
commit | d21b3d346af2f6189638d853182e389555e7ccb9 (patch) | |
tree | ef89086fd1492736105e73e06b3623df3b01df45 /compiler-rt/test/msan/chained_origin_memcpy.cpp | |
parent | 6db8c59f210af60d882f7aedc7c9dc95d41d9696 (diff) | |
download | bcm5719-llvm-d21b3d346af2f6189638d853182e389555e7ccb9.tar.gz bcm5719-llvm-d21b3d346af2f6189638d853182e389555e7ccb9.zip |
compiler-rt: Rename .cc file in test/msan to .cpp
Like r367463, but for test/msan.
llvm-svn: 367653
Diffstat (limited to 'compiler-rt/test/msan/chained_origin_memcpy.cpp')
-rw-r--r-- | compiler-rt/test/msan/chained_origin_memcpy.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/compiler-rt/test/msan/chained_origin_memcpy.cpp b/compiler-rt/test/msan/chained_origin_memcpy.cpp new file mode 100644 index 00000000000..47a0effb3cc --- /dev/null +++ b/compiler-rt/test/msan/chained_origin_memcpy.cpp @@ -0,0 +1,62 @@ +// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \ +// RUN: not %run %t >%t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out + +// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \ +// RUN: not %run %t >%t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out + + +// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \ +// RUN: not %run %t >%t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out + +// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \ +// RUN: not %run %t >%t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out + +#include <stdio.h> +#include <string.h> + +int xx[10000]; +int yy[10000]; +volatile int idx = 30; + +__attribute__((noinline)) +void fn_g(int a, int b) { + xx[idx] = a; xx[idx + 10] = b; +} + +__attribute__((noinline)) +void fn_f(int a, int b) { + fn_g(a, b); +} + +__attribute__((noinline)) +void fn_h() { + memcpy(&yy, &xx, sizeof(xx)); +} + +int main(int argc, char *argv[]) { + int volatile z1; + int volatile z2; + fn_f(z1, z2); + fn_h(); + return yy[idx + OFFSET]; +} + +// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value +// CHECK: {{#0 .* in main .*chained_origin_memcpy.cpp:}}[[@LINE-4]] + +// CHECK: Uninitialized value was stored to memory at +// CHECK-FULL-STACK: {{#1 .* in fn_h.*chained_origin_memcpy.cpp:}}[[@LINE-15]] +// CHECK-SHORT-STACK: {{#0 .* in __msan_memcpy.*msan_interceptors.cpp:}} + +// CHECK: Uninitialized value was stored to memory at +// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-29]] +// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memcpy.cpp:}}[[@LINE-25]] +// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-31]] + +// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main' +// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main' +// CHECK: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-22]] |