1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1 2*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out && FileCheck %s < %t.out 3*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1 4*7c3d14c8STreehugger Robot // RUN: FileCheck %s < %t.out && FileCheck %s < %t.out 5*7c3d14c8STreehugger Robot 6*7c3d14c8STreehugger Robot // Test origin propagation through insertvalue IR instruction. 7*7c3d14c8STreehugger Robot 8*7c3d14c8STreehugger Robot #include <stdio.h> 9*7c3d14c8STreehugger Robot #include <stdint.h> 10*7c3d14c8STreehugger Robot 11*7c3d14c8STreehugger Robot struct mypair { 12*7c3d14c8STreehugger Robot int64_t x; 13*7c3d14c8STreehugger Robot int y; 14*7c3d14c8STreehugger Robot }; 15*7c3d14c8STreehugger Robot my_make_pair(int64_t x,int y)16*7c3d14c8STreehugger Robotmypair my_make_pair(int64_t x, int y) { 17*7c3d14c8STreehugger Robot mypair p; 18*7c3d14c8STreehugger Robot p.x = x; 19*7c3d14c8STreehugger Robot p.y = y; 20*7c3d14c8STreehugger Robot return p; 21*7c3d14c8STreehugger Robot } 22*7c3d14c8STreehugger Robot main()23*7c3d14c8STreehugger Robotint main() { 24*7c3d14c8STreehugger Robot int64_t * volatile p = new int64_t; 25*7c3d14c8STreehugger Robot mypair z = my_make_pair(*p, 0); 26*7c3d14c8STreehugger Robot if (z.x) 27*7c3d14c8STreehugger Robot printf("zzz\n"); 28*7c3d14c8STreehugger Robot // CHECK: MemorySanitizer: use-of-uninitialized-value 29*7c3d14c8STreehugger Robot // CHECK: {{in main .*insertvalue_origin.cc:}}[[@LINE-3]] 30*7c3d14c8STreehugger Robot 31*7c3d14c8STreehugger Robot // CHECK: Uninitialized value was created by a heap allocation 32*7c3d14c8STreehugger Robot // CHECK: {{in main .*insertvalue_origin.cc:}}[[@LINE-8]] 33*7c3d14c8STreehugger Robot delete p; 34*7c3d14c8STreehugger Robot return 0; 35*7c3d14c8STreehugger Robot } 36