OLD | NEW |
1 //===- BitcodeMunge.h - Subzero Bitcode Munger ------------------*- C++ -*-===// | 1 //===- BitcodeMunge.h - Subzero Bitcode Munger ------------------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // Test harness for testing malformed bitcode files in Subzero. Uses NaCl's | 10 // Test harness for testing malformed bitcode files in Subzero. Uses NaCl's |
11 // bitcode munger to do this. | 11 // bitcode munger to do this. |
12 // | 12 // |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #ifndef SUBZERO_UNITTEST_BITCODEMUNGE_H | 15 #ifndef SUBZERO_UNITTEST_BITCODEMUNGE_H |
16 #define SUBZERO_UNITTEST_BITCODEMUNGE_H | 16 #define SUBZERO_UNITTEST_BITCODEMUNGE_H |
17 | 17 |
18 #include "llvm/Bitcode/NaCl/NaClBitcodeMunge.h" | 18 #include "llvm/Bitcode/NaCl/NaClBitcodeMunge.h" |
19 | 19 |
| 20 #include "IceClFlags.h" |
| 21 |
20 namespace IceTest { | 22 namespace IceTest { |
21 | 23 |
22 // Class to run tests on Subzero's bitcode parser. Runs a Subzero | 24 // Class to run tests on Subzero's bitcode parser. Runs a Subzero |
23 // translation, using (possibly) edited bitcode record values. For | 25 // translation, using (possibly) edited bitcode record values. For |
24 // more details on how to represent the input arrays, see | 26 // more details on how to represent the input arrays, see |
25 // NaClBitcodeMunge.h. | 27 // NaClBitcodeMunge.h. |
26 class SubzeroBitcodeMunger : public llvm::NaClBitcodeMunger { | 28 class SubzeroBitcodeMunger : public llvm::NaClBitcodeMunger { |
27 public: | 29 public: |
28 SubzeroBitcodeMunger(const uint64_t Records[], size_t RecordSize, | 30 SubzeroBitcodeMunger(const uint64_t Records[], size_t RecordSize, |
29 uint64_t RecordTerminator) | 31 uint64_t RecordTerminator) |
30 : llvm::NaClBitcodeMunger(Records, RecordSize, RecordTerminator) {} | 32 : llvm::NaClBitcodeMunger(Records, RecordSize, RecordTerminator) { |
| 33 resetMungeFlags(); |
| 34 } |
31 | 35 |
32 /// Runs PNaClTranslator to translate bitcode records (with defined | 36 /// Runs PNaClTranslator to translate bitcode records (with defined |
33 /// record Munges), and puts output into DumpResults. Returns true | 37 /// record Munges), and puts output into DumpResults. Returns true |
34 /// if parse is successful. | 38 /// if parse is successful. |
35 bool runTest(const char *TestName, const uint64_t Munges[], size_t MungeSize); | 39 bool runTest(const char *TestName, const uint64_t Munges[], size_t MungeSize); |
36 | 40 |
37 /// Same as above, but without any edits. | 41 /// Same as above, but without any edits. |
38 bool runTest(const char *TestName) { | 42 bool runTest(const char *TestName) { |
39 uint64_t NoMunges[] = {0}; | 43 uint64_t NoMunges[] = {0}; |
40 return runTest(TestName, NoMunges, 0); | 44 return runTest(TestName, NoMunges, 0); |
41 } | 45 } |
| 46 |
| 47 /// Sets flags back to default assumptions for munging. |
| 48 void resetFlags(); |
| 49 |
| 50 /// Flags to use to run tests. Use to change default assumptions. |
| 51 Ice::ClFlags Flags; |
| 52 |
| 53 private: |
| 54 void resetMungeFlags(); |
42 }; | 55 }; |
43 | 56 |
44 } // end of namespace IceTest | 57 } // end of namespace IceTest |
45 | 58 |
46 #endif // SUBZERO_UNITTEST_BITCODEMUNGE_H | 59 #endif // SUBZERO_UNITTEST_BITCODEMUNGE_H |
OLD | NEW |