xref: /openbsd-src/gnu/llvm/clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp (revision e5dd70708596ae51455a0ffa086a00c5b29f8583)
1*e5dd7070Spatrick //===-- ExampleClangLLVMProtoFuzzer.cpp - Fuzz Clang ----------------------===//
2*e5dd7070Spatrick //
3*e5dd7070Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*e5dd7070Spatrick // See https://llvm.org/LICENSE.txt for license information.
5*e5dd7070Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*e5dd7070Spatrick //
7*e5dd7070Spatrick //===----------------------------------------------------------------------===//
8*e5dd7070Spatrick ///
9*e5dd7070Spatrick /// \file
10*e5dd7070Spatrick ///  This file implements a function that compiles a single LLVM IR string as
11*e5dd7070Spatrick ///  input and uses libprotobuf-mutator to find new inputs. This function is
12*e5dd7070Spatrick ///  then linked into the Fuzzer library.
13*e5dd7070Spatrick ///
14*e5dd7070Spatrick //===----------------------------------------------------------------------===//
15*e5dd7070Spatrick 
16*e5dd7070Spatrick #include "cxx_loop_proto.pb.h"
17*e5dd7070Spatrick #include "fuzzer-initialize/fuzzer_initialize.h"
18*e5dd7070Spatrick #include "handle-llvm/handle_llvm.h"
19*e5dd7070Spatrick #include "proto-to-llvm/loop_proto_to_llvm.h"
20*e5dd7070Spatrick #include "src/libfuzzer/libfuzzer_macro.h"
21*e5dd7070Spatrick 
22*e5dd7070Spatrick using namespace clang_fuzzer;
23*e5dd7070Spatrick 
DEFINE_BINARY_PROTO_FUZZER(const LoopFunction & input)24*e5dd7070Spatrick DEFINE_BINARY_PROTO_FUZZER(const LoopFunction &input) {
25*e5dd7070Spatrick   auto S = LoopFunctionToLLVMString(input);
26*e5dd7070Spatrick   HandleLLVM(S, GetCLArgs());
27*e5dd7070Spatrick }
28