r311185 - [clang-proto-fuzzer] Allow user-specified compiler arguments.
Matt Morehouse via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 18 11:34:39 PDT 2017
Author: morehouse
Date: Fri Aug 18 11:34:39 2017
New Revision: 311185
URL: http://llvm.org/viewvc/llvm-project?rev=311185&view=rev
Log:
[clang-proto-fuzzer] Allow user-specified compiler arguments.
Summary:
Arguments can be specified after -ignore_remaining_args=1 to modify
the compiler invocation. For example, the following command-line
will fuzz LLVM with a custom optimization level and target triple:
clang-proto-fuzzer CORPUS/ -ignore_remaining_args -O3 \
-triple arm64-apple-ios9
Reviewers: vitalybuka, kcc
Reviewed By: vitalybuka
Subscribers: aemerson, cfe-commits, kristof.beyls
Differential Revision: https://reviews.llvm.org/D36882
Modified:
cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
Modified: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp?rev=311185&r1=311184&r2=311185&view=diff
==============================================================================
--- cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp Fri Aug 18 11:34:39 2017
@@ -20,9 +20,25 @@
#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, {"-O2"});
+ HandleCXX(S, CLArgs);
}
More information about the cfe-commits
mailing list