xref: /llvm-project/clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp (revision 64226b2df66741a97b6095ae1373154b29d2619e)
1f051f5d1SMatt Morehouse //===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --------------------------===//
2f051f5d1SMatt Morehouse //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f051f5d1SMatt Morehouse //
7f051f5d1SMatt Morehouse //===----------------------------------------------------------------------===//
8f051f5d1SMatt Morehouse ///
9f051f5d1SMatt Morehouse /// \file
109fc8faf9SAdrian Prantl /// This file implements a function that runs Clang on a single
11f051f5d1SMatt Morehouse ///  input and uses libprotobuf-mutator to find new inputs. This function is
12f051f5d1SMatt Morehouse ///  then linked into the Fuzzer library.
13f051f5d1SMatt Morehouse ///
14f051f5d1SMatt Morehouse //===----------------------------------------------------------------------===//
15f051f5d1SMatt Morehouse 
16f051f5d1SMatt Morehouse #include "cxx_proto.pb.h"
17f051f5d1SMatt Morehouse #include "handle-cxx/handle_cxx.h"
18f051f5d1SMatt Morehouse #include "proto-to-cxx/proto_to_cxx.h"
19293c2691SMatt Morehouse #include "fuzzer-initialize/fuzzer_initialize.h"
20f051f5d1SMatt Morehouse #include "src/libfuzzer/libfuzzer_macro.h"
21f051f5d1SMatt Morehouse 
22f051f5d1SMatt Morehouse using namespace clang_fuzzer;
23f051f5d1SMatt Morehouse 
DEFINE_BINARY_PROTO_FUZZER(const Function & input)24f051f5d1SMatt Morehouse DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
25f051f5d1SMatt Morehouse   auto S = FunctionToString(input);
26*64226b2dSBenjamin Kramer   HandleCXX(S, "./test.cc", GetCLArgs());
27f051f5d1SMatt Morehouse }
28