OLD | NEW |
---|---|
(Empty) | |
1 //===- NaClFuzz.h - Fuzz PNaCl bitcode records ----------------------------===// | |
jvoung (off chromium)
2015/06/02 16:14:03
NaClFuzz.cpp
Karl
2015/06/02 16:40:23
Done.
| |
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 // | |
10 // This file implements a basic fuzzer for a list of PNaCl bitcode records. | |
11 // | |
12 //===----------------------------------------------------------------------===// | |
13 | |
14 #include "llvm/ADT/STLExtras.h" | |
15 #include "llvm/Bitcode/NaCl/NaClFuzz.h" | |
16 #include "llvm/Support/Format.h" | |
jvoung (off chromium)
2015/06/02 16:14:03
can some of this be trimmed?
Karl
2015/06/02 16:40:23
Done. Removed Format.h
| |
17 | |
18 #include <array> | |
19 #include <cmath> | |
20 #include <cstdlib> | |
21 #include <map> | |
jvoung (off chromium)
2015/06/02 16:14:03
where is <map> <set> <cmath> etc. used?
Karl
2015/06/02 16:40:23
Removed all <...> includes.
| |
22 #include <set> | |
23 | |
24 | |
25 using namespace llvm; | |
26 using namespace naclfuzz; | |
jvoung (off chromium)
2015/06/02 16:14:03
Do you really need "using namespace naclfuzz"? Mos
Karl
2015/06/02 16:40:23
Sorry for all the unnecessary boilerplate. Most of
| |
27 | |
28 namespace { | |
29 | |
30 // Names for edit actions. | |
31 const char *ActionNameArray[] = { | |
32 "Insert", | |
33 "Mutate", | |
34 "Remove", | |
35 "Replace", | |
36 "Swap" | |
37 }; | |
38 | |
39 } // end of anonymous namespace | |
40 | |
41 namespace naclfuzz { | |
42 | |
43 const char *RecordFuzzer::actionName(EditAction Action) { | |
44 return Action < array_lengthof(ActionNameArray) | |
45 ? ActionNameArray[Action] : "???"; | |
46 } | |
47 | |
48 RecordFuzzer::RecordFuzzer(NaClMungedBitcode &Bitcode, | |
49 RandomNumberGenerator &Generator) | |
50 : Bitcode(Bitcode), Generator(Generator) { | |
51 if (Bitcode.getBaseRecords().empty()) | |
52 report_fatal_error( | |
53 "Sorry, the fuzzer doesn't know how to fuzz an empty record list"); | |
54 } | |
55 | |
56 RecordFuzzer::~RecordFuzzer() {} | |
57 | |
58 void RecordFuzzer::clear() { | |
59 Bitcode.removeEdits(); | |
60 } | |
61 | |
62 } // end of namespace naclfuzz | |
OLD | NEW |