Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame] | 1 | //===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --------------------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 10 | /// This file implements a function that runs Clang on a single |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame] | 11 | /// input and uses libprotobuf-mutator to find new inputs. This function is |
| 12 | /// then linked into the Fuzzer library. |
| 13 | /// |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "cxx_proto.pb.h" |
| 17 | #include "handle-cxx/handle_cxx.h" |
| 18 | #include "proto-to-cxx/proto_to_cxx.h" |
Matt Morehouse | 293c269 | 2018-06-05 00:11:41 +0000 | [diff] [blame] | 19 | #include "fuzzer-initialize/fuzzer_initialize.h" |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame] | 20 | #include "src/libfuzzer/libfuzzer_macro.h" |
| 21 | |
| 22 | using namespace clang_fuzzer; |
| 23 | |
| 24 | DEFINE_BINARY_PROTO_FUZZER(const Function& input) { |
| 25 | auto S = FunctionToString(input); |
Matt Morehouse | 293c269 | 2018-06-05 00:11:41 +0000 | [diff] [blame] | 26 | HandleCXX(S, GetCLArgs()); |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame] | 27 | } |