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. |
| 7 | |
| 8 | #include <stdio.h> |
| 9 | #include <stdint.h> |
| 10 | |
| 11 | struct mypair { |
| 12 | int64_t x; |
| 13 | int y; |
| 14 | }; |
| 15 | |
| 16 | mypair my_make_pair(int64_t x, int y) { |
| 17 | mypair p; |
| 18 | p.x = x; |
| 19 | p.y = y; |
| 20 | return p; |
| 21 | } |
| 22 | |
| 23 | int main() { |
| 24 | int64_t * volatile p = new int64_t; |
| 25 | mypair z = my_make_pair(*p, 0); |
| 26 | if (z.x) |
| 27 | printf("zzz\n"); |
| 28 | // CHECK: MemorySanitizer: use-of-uninitialized-value |
| 29 | // CHECK: {{in main .*insertvalue_origin.cc:}}[[@LINE-3]] |
| 30 | |
| 31 | // CHECK: Uninitialized value was created by a heap allocation |
| 32 | // CHECK: {{in main .*insertvalue_origin.cc:}}[[@LINE-8]] |
| 33 | delete p; |
| 34 | return 0; |
| 35 | } |