Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
INPUTS
bindings
cmake
docs
examples
include
lib
runtime
tools
arcmt-test
c-arcmt-test
c-index-test
clang-check
clang-diff
clang-format
clang-format-vs
clang-func-mapping
clang-fuzzer
handle-cxx
proto-to-cxx
CMakeLists.txt
ClangFuzzer.cpp
Dockerfile
DummyClangFuzzer.cpp
ExampleClangProtoFuzzer.cpp
README.txt
cxx_proto.proto
clang-import-test
clang-offload-bundler
clang-refactor
clang-rename
diag-build
diagtool
driver
libclang
scan-build
scan-build-py
scan-view
CMakeLists.txt
unittests
utils
www
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp

45 lines
1.3 KiB
C++
Raw Normal View History

//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief This file implements a function that runs Clang on a single
/// input and uses libprotobuf-mutator to find new inputs. This function is
/// then linked into the Fuzzer library.
///
//===----------------------------------------------------------------------===//
#include "cxx_proto.pb.h"
#include "handle-cxx/handle_cxx.h"
#include "proto-to-cxx/proto_to_cxx.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include <cstring>
using namespace clang_fuzzer;
static std::vector<const char *> CLArgs;
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
CLArgs.push_back("-O2");
for (int I = 1; I < *argc; I++) {
if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
for (I++; I < *argc; I++)
CLArgs.push_back((*argv)[I]);
break;
}
}
return 0;
}
DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
auto S = FunctionToString(input);
HandleCXX(S, CLArgs);
}