1667c152bSManuel Klimek //===-- ClangFuzzer.cpp - Fuzz Clang --------------------------------------===// 2667c152bSManuel Klimek // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6667c152bSManuel Klimek // 7667c152bSManuel Klimek //===----------------------------------------------------------------------===// 8667c152bSManuel Klimek /// 9667c152bSManuel Klimek /// \file 109fc8faf9SAdrian Prantl /// This file implements a function that runs Clang on a single 11667c152bSManuel Klimek /// input. This function is then linked into the Fuzzer library. 12667c152bSManuel Klimek /// 13667c152bSManuel Klimek //===----------------------------------------------------------------------===// 14667c152bSManuel Klimek 15f051f5d1SMatt Morehouse #include "handle-cxx/handle_cxx.h" 16667c152bSManuel Klimek 17f051f5d1SMatt Morehouse using namespace clang_fuzzer; 18667c152bSManuel Klimek LLVMFuzzerInitialize(int * argc,char *** argv)197b6010cdSMatt Morehouseextern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; } 207b6010cdSMatt Morehouse LLVMFuzzerTestOneInput(uint8_t * data,size_t size)21e39fec5bSKostya Serebryanyextern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { 22667c152bSManuel Klimek std::string s((const char *)data, size); 23*e5ecba4fSDavid Goldman HandleCXX(s, "./test.cc", {"-O2"}); 24e39fec5bSKostya Serebryany return 0; 25667c152bSManuel Klimek } 26