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