BitstreamWriter: Isolate access to the underlying buffer.
[oota-llvm.git] / include / llvm / Bitcode / BitstreamReader.h
index b7c52f4035e954fda2c7f591789e607e62c8fdc3..65868294403c02532cf79d0e3a3612a446eb13da 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 {
 
@@ -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() {