1 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
2 // RUN: not %run %t >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
5 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
6 // RUN: not %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
10 // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
11 // RUN: not %run %t >%t.out 2>&1
12 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
14 // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
15 // RUN: not %run %t >%t.out 2>&1
16 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
23 volatile int idx
= 30;
25 __attribute__((noinline
))
26 void fn_g(int a
, int b
) {
27 xx
[idx
] = a
; xx
[idx
+ 10] = b
;
30 __attribute__((noinline
))
31 void fn_f(int a
, int b
) {
35 __attribute__((noinline
))
37 memcpy(&yy
, &xx
, sizeof(xx
));
40 int main(int argc
, char *argv
[]) {
45 return yy
[idx
+ OFFSET
];
48 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
49 // CHECK: {{#0 .* in main .*chained_origin_memcpy.cpp:}}[[@LINE-4]]
51 // CHECK: Uninitialized value was stored to memory at
52 // CHECK-FULL-STACK: {{#1 .* in fn_h.*chained_origin_memcpy.cpp:}}[[@LINE-15]]
53 // CHECK-SHORT-STACK: {{#0 .* in __msan_memcpy.*msan_interceptors.cpp:}}
55 // CHECK: Uninitialized value was stored to memory at
56 // CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-29]]
57 // CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memcpy.cpp:}}[[@LINE-25]]
58 // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-31]]
60 // CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main'
61 // CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main'
62 // CHECK: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-22]]