| 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 #pragma clang diagnostic push | 18 #pragma clang diagnostic push |
| 19 #pragma clang diagnostic ignored "-Wunused-parameter" | 19 #pragma clang diagnostic ignored "-Wunused-parameter" |
| 20 #include "llvm/Bitcode/NaCl/NaClBitcodeMunge.h" | 20 #include "llvm/Bitcode/NaCl/NaClBitcodeMunge.h" |
| 21 #pragma clang diagnostic pop | 21 #pragma clang diagnostic pop |
| 22 | 22 |
| 23 #include "IceClFlags.h" | 23 #include "IceClFlags.h" |
| 24 #include "IceGlobalContext.h" |
| 24 | 25 |
| 25 namespace IceTest { | 26 namespace IceTest { |
| 26 | 27 |
| 27 // Class to run tests on Subzero's bitcode parser. Runs a Subzero | 28 // Class to run tests on Subzero's bitcode parser. Runs a Subzero |
| 28 // translation, using (possibly) edited bitcode record values. For | 29 // translation, using (possibly) edited bitcode record values. For |
| 29 // more details on how to represent the input arrays, see | 30 // more details on how to represent the input arrays, see |
| 30 // NaClBitcodeMunge.h. | 31 // NaClBitcodeMunge.h. |
| 31 class SubzeroBitcodeMunger : public llvm::NaClBitcodeMunger { | 32 class SubzeroBitcodeMunger : public llvm::NaClBitcodeMunger { |
| 32 public: | 33 public: |
| 33 SubzeroBitcodeMunger(const uint64_t Records[], size_t RecordSize, | 34 SubzeroBitcodeMunger(const uint64_t Records[], size_t RecordSize, |
| 34 uint64_t RecordTerminator) | 35 uint64_t RecordTerminator) |
| 35 : llvm::NaClBitcodeMunger(Records, RecordSize, RecordTerminator) { | 36 : llvm::NaClBitcodeMunger(Records, RecordSize, RecordTerminator), |
| 37 Flags(Ice::GlobalContext::Flags) { |
| 36 resetMungeFlags(); | 38 resetMungeFlags(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 /// Runs PNaClTranslator to parse and (optionally) translate bitcode records | 41 /// Runs PNaClTranslator to parse and (optionally) translate bitcode records |
| 40 /// (with defined record Munges), and puts output into DumpResults. Returns | 42 /// (with defined record Munges), and puts output into DumpResults. Returns |
| 41 /// true if parse is successful. | 43 /// true if parse is successful. |
| 42 bool runTest(const uint64_t Munges[], size_t MungeSize, | 44 bool runTest(const uint64_t Munges[], size_t MungeSize, |
| 43 bool DisableTranslation = false); | 45 bool DisableTranslation = false); |
| 44 | 46 |
| 45 /// Same as above, but without any edits. | 47 /// Same as above, but without any edits. |
| 46 bool runTest(bool DisableTranslation = false) { | 48 bool runTest(bool DisableTranslation = false) { |
| 47 uint64_t NoMunges[] = {0}; | 49 uint64_t NoMunges[] = {0}; |
| 48 return runTest(NoMunges, 0, DisableTranslation); | 50 return runTest(NoMunges, 0, DisableTranslation); |
| 49 } | 51 } |
| 50 | 52 |
| 51 /// Flags to use to run tests. Use to change default assumptions. | 53 /// Flags to use to run tests. Use to change default assumptions. |
| 52 Ice::ClFlags Flags; | 54 Ice::ClFlags &Flags; |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 void resetMungeFlags(); | 57 void resetMungeFlags(); |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 } // end of namespace IceTest | 60 } // end of namespace IceTest |
| 59 | 61 |
| 60 #endif // SUBZERO_UNITTEST_BITCODEMUNGE_H | 62 #endif // SUBZERO_UNITTEST_BITCODEMUNGE_H |
| OLD | NEW |