Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / realloc-origin.cpp
blob5bceddad660688e6658d2a69f0e0b6d2e7d5dcd3
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
3 // RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1
4 // RUN: FileCheck %s < %t.out
6 // This test relies on realloc from 100 to 101 being done in-place.
8 #include <stdlib.h>
9 int main(int argc, char **argv) {
10 char *p = (char *)malloc(100);
11 p = (char *)realloc(p, 101);
12 char x = p[100];
13 free(p);
14 return x;
15 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
16 // CHECK: {{#0 0x.* in main .*realloc-origin.cpp:}}[[@LINE-2]]
18 // CHECK: Uninitialized value was created by a heap allocation
19 // CHECK: {{#0 0x.* in .*realloc}}
20 // CHECK: {{#1 0x.* in main .*realloc-origin.cpp:}}[[@LINE-9]]