Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / TraceMallocTest.cpp
blob5a7dfe9d38d01aebbe7604854b26a965aec9e9af
1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 // Tests -trace_malloc
6 #include <assert.h>
7 #include <cstddef>
8 #include <cstdint>
9 #include <cstdlib>
10 #include <iostream>
12 int *Ptr;
14 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
15 if (!Size) return 0;
16 if (*Data == 1) {
17 delete Ptr;
18 Ptr = nullptr;
19 } else if (*Data == 2) {
20 delete Ptr;
21 Ptr = new int;
22 } else if (*Data == 3) {
23 if (!Ptr)
24 Ptr = new int;
26 return 0;