Manuel Klimek | 667c152 | 2015-03-28 00:07:39 +0000 | [diff] [blame] | 1 | //===-- ClangFuzzer.cpp - Fuzz Clang --------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// \brief This file implements a function that runs Clang on a single |
| 12 | /// input. This function is then linked into the Fuzzer library. |
| 13 | /// |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame^] | 16 | #include "handle-cxx/handle_cxx.h" |
Manuel Klimek | 667c152 | 2015-03-28 00:07:39 +0000 | [diff] [blame] | 17 | |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame^] | 18 | using namespace clang_fuzzer; |
Manuel Klimek | 667c152 | 2015-03-28 00:07:39 +0000 | [diff] [blame] | 19 | |
Kostya Serebryany | e39fec5 | 2015-10-02 23:34:37 +0000 | [diff] [blame] | 20 | extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { |
Manuel Klimek | 667c152 | 2015-03-28 00:07:39 +0000 | [diff] [blame] | 21 | std::string s((const char *)data, size); |
Matt Morehouse | f051f5d | 2017-08-08 20:15:04 +0000 | [diff] [blame^] | 22 | HandleCXX(s, {"-O2"}); |
Kostya Serebryany | e39fec5 | 2015-10-02 23:34:37 +0000 | [diff] [blame] | 23 | return 0; |
Manuel Klimek | 667c152 | 2015-03-28 00:07:39 +0000 | [diff] [blame] | 24 | } |