Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / memprof / TestCases / realloc.cpp
blobfa55646a0df9b4ae3ed3060c34594b2d07cc0234
1 // RUN: %clangxx_memprof -O0 %s -o %t
2 // Default is true (free on realloc to 0 size)
3 // RUN: %run %t 2>&1 | FileCheck %s
4 // RUN: %env_memprof_opts=allocator_frees_and_returns_null_on_realloc_zero=true %run %t 2>&1 | FileCheck %s
5 // RUN: %env_memprof_opts=allocator_frees_and_returns_null_on_realloc_zero=false %run %t 2>&1 | FileCheck %s --check-prefix=NO-FREE
7 #include <stdio.h>
8 #include <stdlib.h>
10 int main() {
11 void *p = malloc(42);
12 p = realloc(p, 0);
13 if (p) {
14 // NO-FREE: Allocated something on realloc(p, 0)
15 fprintf(stderr, "Allocated something on realloc(p, 0)\n");
16 } else {
17 // CHECK: realloc(p, 0) returned nullptr
18 fprintf(stderr, "realloc(p, 0) returned nullptr\n");
20 free(p);