1//===-- ExampleClangLoopProtoFuzzer.cpp - Fuzz Clang ----------------------===//
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-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements a function that runs Clang on a single
11/// input and uses libprotobuf-mutator to find new inputs. This function is
12/// then linked into the Fuzzer library. This file differs from
13/// ExampleClangProtoFuzzer in that it uses a different protobuf that includes
14/// C++ code with a single for loop.
15///
16//===----------------------------------------------------------------------===//
17
18#include "cxx_loop_proto.pb.h"
19#include "fuzzer-initialize/fuzzer_initialize.h"
20#include "handle-cxx/handle_cxx.h"
21#include "proto-to-cxx/proto_to_cxx.h"
22#include "src/libfuzzer/libfuzzer_macro.h"
23
24using namespace clang_fuzzer;
25
26DEFINE_BINARY_PROTO_FUZZER(const LoopFunction &input) {
27 auto S = LoopFunctionToString(input);
28 HandleCXX(S, GetCLArgs());
29}
30

source code of clang/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp