xref: /aosp_15_r20/external/compiler-rt/test/msan/stack-origin.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
2*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out
3*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&1
4*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out
5*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&1
6*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out
7*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&1
8*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out
9*7c3d14c8STreehugger Robot 
10*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1
11*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
12*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&1
13*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
14*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1
15*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
16*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1
17*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
18*7c3d14c8STreehugger Robot 
19*7c3d14c8STreehugger Robot #include <stdlib.h>
main(int argc,char ** argv)20*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
21*7c3d14c8STreehugger Robot   int x;
22*7c3d14c8STreehugger Robot   int *volatile p = &x;
23*7c3d14c8STreehugger Robot   return *p;
24*7c3d14c8STreehugger Robot   // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
25*7c3d14c8STreehugger Robot   // CHECK: {{#0 0x.* in main .*stack-origin.cc:}}[[@LINE-2]]
26*7c3d14c8STreehugger Robot 
27*7c3d14c8STreehugger Robot   // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
28*7c3d14c8STreehugger Robot   // CHECK-ORIGINS: {{#0 0x.* in main .*stack-origin.cc:}}[[@LINE-8]]
29*7c3d14c8STreehugger Robot 
30*7c3d14c8STreehugger Robot   // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin.cc:.* main}}
31*7c3d14c8STreehugger Robot }
32