diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
commit | 3a0822f094b578157263e04114075ad7df81db41 (patch) | |
tree | bc48361fe2cd1ca5f93ac01b38b183774468fc79 /include/llvm/Bitcode/BitstreamWriter.h | |
parent | 85d8b2bbe386bcfe669575d05b61482d7be07e5d (diff) |
Diffstat (limited to 'include/llvm/Bitcode/BitstreamWriter.h')
-rw-r--r-- | include/llvm/Bitcode/BitstreamWriter.h | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h index f7487a05bdb7..eef6076d6a45 100644 --- a/include/llvm/Bitcode/BitstreamWriter.h +++ b/include/llvm/Bitcode/BitstreamWriter.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Bitcode/BitCodes.h" +#include "llvm/Support/Endian.h" #include <vector> namespace llvm { @@ -63,10 +64,7 @@ class BitstreamWriter { // BackpatchWord - Backpatch a 32-bit word in the output with the specified // value. void BackpatchWord(unsigned ByteNo, unsigned NewWord) { - Out[ByteNo++] = (unsigned char)(NewWord >> 0); - Out[ByteNo++] = (unsigned char)(NewWord >> 8); - Out[ByteNo++] = (unsigned char)(NewWord >> 16); - Out[ByteNo ] = (unsigned char)(NewWord >> 24); + support::endian::write32le(&Out[ByteNo], NewWord); } void WriteByte(unsigned char Value) { @@ -74,12 +72,9 @@ class BitstreamWriter { } void WriteWord(unsigned Value) { - unsigned char Bytes[4] = { - (unsigned char)(Value >> 0), - (unsigned char)(Value >> 8), - (unsigned char)(Value >> 16), - (unsigned char)(Value >> 24) }; - Out.append(&Bytes[0], &Bytes[4]); + Value = support::endian::byte_swap<uint32_t, support::little>(Value); + Out.append(reinterpret_cast<const char *>(&Value), + reinterpret_cast<const char *>(&Value + 1)); } unsigned GetBufferOffset() const { @@ -525,6 +520,6 @@ public: }; -} // End llvm namespace +} // namespace llvm #endif |