1 //===-- llvm-dis-fuzzer.cpp - Fuzzer for llvm-dis using lib/Fuzzer --------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Fuzzer for LLVM bitcode reading.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Bitcode/BitcodeReader.h"
14 #include "llvm/IR/LLVMContext.h"
15 #include "llvm/IR/Module.h"
16 #include "llvm/Support/MemoryBuffer.h"
20 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
22 auto Buffer
= MemoryBuffer::getMemBuffer(
23 StringRef(reinterpret_cast<const char *>(Data
), Size
), "Fuzzer input",
24 /*RequiresNullTerminator=*/false);
26 parseBitcodeFile(Buffer
->getMemBufferRef(), Context
).takeError());