Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 1 | // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 2 | // RUN: FileCheck %s < %t.out && FileCheck %s < %t.out |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 3 | // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 4 | // RUN: FileCheck %s < %t.out && FileCheck %s < %t.out |
| 5 | |
| 6 | // Test origin propagation through insertvalue IR instruction. |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 7 | // REQUIRES: stable-runtime |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 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 | } |