brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1019 B · a5c4e0f Raw
29 lines · cpp
1//===-- llvm-dis-fuzzer.cpp - Fuzzer for llvm-dis using lib/Fuzzer --------===//2//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-exception6//7//===----------------------------------------------------------------------===//8//9// Fuzzer for LLVM bitcode reading.10//11//===----------------------------------------------------------------------===//12 13#include "llvm/Bitcode/BitcodeReader.h"14#include "llvm/IR/LLVMContext.h"15#include "llvm/IR/Module.h"16#include "llvm/Support/MemoryBuffer.h"17 18using namespace llvm;19 20extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {21  LLVMContext Context;22  auto Buffer = MemoryBuffer::getMemBuffer(23      StringRef(reinterpret_cast<const char *>(Data), Size), "Fuzzer input",24      /*RequiresNullTerminator=*/false);25  consumeError(26      parseBitcodeFile(Buffer->getMemBufferRef(), Context).takeError());27  return 0;28}29