Change encoding of instruction operands in bitcode binaries to be relative
[oota-llvm.git] / include / llvm / Bitcode / BitstreamReader.h
index b7c52f4035e954fda2c7f591789e607e62c8fdc3..840f57e7526d274eac8e9f8474a8ea434a954626 100644 (file)
 
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/StreamableMemoryObject.h"
 #include <climits>
 #include <string>
 #include <vector>
-#include "llvm/Support/StreamableMemoryObject.h"
 
 namespace llvm {
 
@@ -46,9 +47,9 @@ private:
   /// block/record name information in the BlockInfo block. Only llvm-bcanalyzer
   /// uses this.
   bool IgnoreBlockInfoNames;
-  
-  BitstreamReader(const BitstreamReader&);  // DO NOT IMPLEMENT
-  void operator=(const BitstreamReader&);  // DO NOT IMPLEMENT
+
+  BitstreamReader(const BitstreamReader&) LLVM_DELETED_FUNCTION;
+  void operator=(const BitstreamReader&) LLVM_DELETED_FUNCTION;
 public:
   BitstreamReader() : IgnoreBlockInfoNames(true) {
   }
@@ -242,12 +243,13 @@ public:
   }
 
   uint32_t getWord(size_t pos) {
-    uint32_t word = -1;
+    uint8_t buf[sizeof(uint32_t)];
+    memset(buf, 0xFF, sizeof(buf));
     BitStream->getBitcodeBytes().readBytes(pos,
-                                           sizeof(word),
-                                           reinterpret_cast<uint8_t *>(&word),
+                                           sizeof(buf),
+                                           buf,
                                            NULL);
-    return word;
+    return *reinterpret_cast<support::ulittle32_t *>(buf);
   }
 
   bool AtEndOfStream() {
@@ -407,7 +409,7 @@ public:
   }
 
   /// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter
-  /// the block, and return true if the block is valid.
+  /// the block, and return true if the block has an error.
   bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = 0) {
     // Save the current block's state on BlockScope.
     BlockScope.push_back(Block(CurCodeSize));