blob: 96d27f08937e00b08bb1dff1c01f9a0f70126ed9 [file] [log] [blame]
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -07001// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1
Stephen Hines2d1fdb22014-05-28 23:58:16 -07002// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -07003// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1
Stephen Hines2d1fdb22014-05-28 23:58:16 -07004// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out
5
6// Test origin propagation through insertvalue IR instruction.
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08007// REQUIRES: stable-runtime
Stephen Hines2d1fdb22014-05-28 23:58:16 -07008
9#include <stdio.h>
10#include <stdint.h>
11
12struct mypair {
13 int64_t x;
14 int y;
15};
16
17mypair my_make_pair(int64_t x, int y) {
18 mypair p;
19 p.x = x;
20 p.y = y;
21 return p;
22}
23
24int 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}