blob: 2d35fb7735f97f2820e26e8160e10994acb914df [file] [log] [blame]
Manuel Klimek667c1522015-03-28 00:07:39 +00001//===-- 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 Morehousef051f5d2017-08-08 20:15:04 +000016#include "handle-cxx/handle_cxx.h"
Manuel Klimek667c1522015-03-28 00:07:39 +000017
Matt Morehousef051f5d2017-08-08 20:15:04 +000018using namespace clang_fuzzer;
Manuel Klimek667c1522015-03-28 00:07:39 +000019
Matt Morehouse7b6010c2017-10-11 15:51:12 +000020extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; }
21
Kostya Serebryanye39fec52015-10-02 23:34:37 +000022extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
Manuel Klimek667c1522015-03-28 00:07:39 +000023 std::string s((const char *)data, size);
Matt Morehousef051f5d2017-08-08 20:15:04 +000024 HandleCXX(s, {"-O2"});
Kostya Serebryanye39fec52015-10-02 23:34:37 +000025 return 0;
Manuel Klimek667c1522015-03-28 00:07:39 +000026}