[PATCH] D36882: [clang-proto-fuzzer] Allow user-specified compiler arguments.
Matt Morehouse via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 18 10:50:36 PDT 2017
morehouse created this revision.
Herald added subscribers: kristof.beyls, aemerson.
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
https://reviews.llvm.org/D36882
Files:
clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
Index: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===================================================================
--- clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,24 @@
#include "src/libfuzzer/libfuzzer_macro.h"
+#include "llvm/ADT/StringRef.h"
+
using namespace clang_fuzzer;
+static std::vector<const char *> CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+ CLArgs.push_back("-O2");
+ int I;
+ for (I = 1; I < *argc; I++)
+ if (llvm::StringRef((*argv)[I]).equals("-ignore_remaining_args=1"))
+ break;
+ for (I++; I < *argc; I++)
+ CLArgs.push_back((*argv)[I]);
+ return 0;
+}
+
DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
auto S = FunctionToString(input);
- HandleCXX(S, {"-O2"});
+ HandleCXX(S, CLArgs);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36882.111705.patch
Type: text/x-patch
Size: 867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170818/d829d4a1/attachment.bin>
More information about the cfe-commits
mailing list