1*d21b3d34SFangrui Song // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1 2*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 3*d21b3d34SFangrui Song // RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&1 4*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 5*d21b3d34SFangrui Song // RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&1 6*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 7*d21b3d34SFangrui Song // RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&1 8*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 9*d21b3d34SFangrui Song 10*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1 11*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 12*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&1 13*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 14*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1 15*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 16*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1 17*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 18*d21b3d34SFangrui Song 19*d21b3d34SFangrui Song #include <sanitizer/msan_interface.h> 20*d21b3d34SFangrui Song #include <stdlib.h> 21*d21b3d34SFangrui Song main(int argc,char ** argv)22*d21b3d34SFangrui Songint main(int argc, char **argv) { 23*d21b3d34SFangrui Song int *volatile p = (int *)malloc(sizeof(int)); 24*d21b3d34SFangrui Song 25*d21b3d34SFangrui Song __msan_check_mem_is_initialized(p, sizeof(*p)); 26*d21b3d34SFangrui Song // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value 27*d21b3d34SFangrui Song // CHECK: {{#0 0x.* in main .*check_mem_is_initialized.cpp:}}[[@LINE-2]] 28*d21b3d34SFangrui Song 29*d21b3d34SFangrui Song // CHECK-ORIGINS: Uninitialized value was created by a heap allocation 30*d21b3d34SFangrui Song // CHECK-ORIGINS: {{#0 0x.* in .*malloc}} 31*d21b3d34SFangrui Song // CHECK-ORIGINS: {{#1 0x.* in main .*check_mem_is_initialized.cpp:}}[[@LINE-8]] 32*d21b3d34SFangrui Song return 0; 33*d21b3d34SFangrui Song } 34