blob: 0d5c1132ea5fbf5e68715137a40a11c8ca55ee39 [file] [log] [blame]
Aaron Ballmanef116982015-01-29 16:58:29 +00001//===- FuzzerMain.cpp - main() function and flags -------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9// main() and flags.
10//===----------------------------------------------------------------------===//
11
Kostya Serebryany016852c2015-02-19 18:45:37 +000012#include "FuzzerInterface.h"
Aaron Ballmanef116982015-01-29 16:58:29 +000013#include "FuzzerInternal.h"
14
Kostya Serebryanyaca76962016-01-16 01:23:12 +000015extern "C" {
Kostya Serebryany016852c2015-02-19 18:45:37 +000016// This function should be defined by the user.
Kostya Serebryanyaca76962016-01-16 01:23:12 +000017int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
18// This function may optionally be defined by the user.
19__attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv);
20} // extern "C"
Kostya Serebryanye8cee112015-01-31 01:14:40 +000021
Aaron Ballmanef116982015-01-29 16:58:29 +000022int main(int argc, char **argv) {
Kostya Serebryanyaca76962016-01-16 01:23:12 +000023 if (LLVMFuzzerInitialize)
24 LLVMFuzzerInitialize(&argc, &argv);
Kostya Serebryany566bc5a2015-05-06 22:19:00 +000025 return fuzzer::FuzzerDriver(argc, argv, LLVMFuzzerTestOneInput);
Aaron Ballmanef116982015-01-29 16:58:29 +000026}