xref: /netbsd-src/external/apache2/llvm/dist/clang/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg //===-- ExampleClangLoopProtoFuzzer.cpp - Fuzz Clang ----------------------===//
2*7330f729Sjoerg //
3*7330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg //
7*7330f729Sjoerg //===----------------------------------------------------------------------===//
8*7330f729Sjoerg ///
9*7330f729Sjoerg /// \file
10*7330f729Sjoerg ///  This file implements a function that runs Clang on a single
11*7330f729Sjoerg ///  input and uses libprotobuf-mutator to find new inputs. This function is
12*7330f729Sjoerg ///  then linked into the Fuzzer library. This file differs from
13*7330f729Sjoerg ///  ExampleClangProtoFuzzer in that it uses a different protobuf that includes
14*7330f729Sjoerg ///  C++ code with a single for loop.
15*7330f729Sjoerg ///
16*7330f729Sjoerg //===----------------------------------------------------------------------===//
17*7330f729Sjoerg 
18*7330f729Sjoerg #include "cxx_loop_proto.pb.h"
19*7330f729Sjoerg #include "fuzzer-initialize/fuzzer_initialize.h"
20*7330f729Sjoerg #include "handle-cxx/handle_cxx.h"
21*7330f729Sjoerg #include "proto-to-cxx/proto_to_cxx.h"
22*7330f729Sjoerg #include "src/libfuzzer/libfuzzer_macro.h"
23*7330f729Sjoerg 
24*7330f729Sjoerg using namespace clang_fuzzer;
25*7330f729Sjoerg 
DEFINE_BINARY_PROTO_FUZZER(const LoopFunction & input)26*7330f729Sjoerg DEFINE_BINARY_PROTO_FUZZER(const LoopFunction &input) {
27*7330f729Sjoerg   auto S = LoopFunctionToString(input);
28*7330f729Sjoerg   HandleCXX(S, GetCLArgs());
29*7330f729Sjoerg }
30