summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2017-09-02 23:43:04 +0000
committerJustin Bogner <mail@justinbogner.com>2017-09-02 23:43:04 +0000
commit7f28d732d2a851c097aeb544dc8010bd78d721b5 (patch)
treed81bc09dc20f38218c8379743e0127e689fbc0cf /llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp
parent4cfdc8a04c3eb7eb037ec492a294b8f60ba3e753 (diff)
downloadbcm5719-llvm-7f28d732d2a851c097aeb544dc8010bd78d721b5.tar.gz
bcm5719-llvm-7f28d732d2a851c097aeb544dc8010bd78d721b5.zip
Move some CLI utils out of llvm-isel-fuzzer and into the library
FuzzMutate might not be the best place for these, but it makes more sense than an entirely new library for now. This will make setting up fuzz targets with consistent CLI handling easier. llvm-svn: 312425
Diffstat (limited to 'llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp')
-rw-r--r--llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp38
1 files changed, 3 insertions, 35 deletions
diff --git a/llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp
index 89c1c81cdbe..ec9c74e3040 100644
--- a/llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp
+++ b/llvm/tools/llvm-isel-fuzzer/DummyISelFuzzer.cpp
@@ -11,43 +11,11 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
+#include "llvm/FuzzMutate/FuzzerCLI.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv);
-
int main(int argc, char *argv[]) {
- errs() << "*** This tool was not linked to libFuzzer.\n"
- << "*** No fuzzing will be performed.\n";
- if (int RC = LLVMFuzzerInitialize(&argc, &argv)) {
- errs() << "Initialization failed\n";
- return RC;
- }
-
- for (int I = 1; I < argc; ++I) {
- StringRef Arg(argv[I]);
- if (Arg.startswith("-")) {
- if (Arg.equals("-ignore_remaining_args=1"))
- break;
- continue;
- }
-
- auto BufOrErr = MemoryBuffer::getFile(Arg, /*FileSize-*/ -1,
- /*RequiresNullTerminator=*/false);
- if (std::error_code EC = BufOrErr.getError()) {
- errs() << "Error reading file: " << Arg << ": " << EC.message() << "\n";
- return 1;
- }
- std::unique_ptr<MemoryBuffer> Buf = std::move(BufOrErr.get());
- errs() << "Running: " << Arg << " (" << Buf->getBufferSize() << " bytes)\n";
- LLVMFuzzerTestOneInput(
- reinterpret_cast<const uint8_t *>(Buf->getBufferStart()),
- Buf->getBufferSize());
- }
+ return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput,
+ LLVMFuzzerInitialize);
}
OpenPOWER on IntegriCloud