diff options
author | Chris Lattner <sabre@nondot.org> | 2013-02-10 06:36:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2013-02-10 06:36:29 +0000 |
commit | e9288fbe4df5c912f5bb42c33a675b61d45c0a99 (patch) | |
tree | 4093dcf0559aaecdd78b437033e3901d21deba2e /include | |
parent | 10b043e2ab08f234780b9b5dec39f5478e211f60 (diff) | |
download | external_llvm-e9288fbe4df5c912f5bb42c33a675b61d45c0a99.zip external_llvm-e9288fbe4df5c912f5bb42c33a675b61d45c0a99.tar.gz external_llvm-e9288fbe4df5c912f5bb42c33a675b61d45c0a99.tar.bz2 |
ok, ok, stop fighting type punning warnings by just using a union.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Bitcode/BitstreamReader.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index 48a6989..edec6e1 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -364,13 +364,16 @@ public: uint32_t R = uint32_t(CurWord); // Read the next word from the stream. - char buf[sizeof(word_t)] = {0}; - BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf), - (uint8_t*)buf, NULL); + union { + uint8_t ArrayMember[sizeof(word_t)]; + support::detail::packed_endian_specific_integral + <word_t, support::little, support::unaligned> EndianMember; + } buf = { { 0 } }; - typedef support::detail::packed_endian_specific_integral - <word_t, support::little, support::unaligned> Endian_T; - CurWord = *(Endian_T*)buf; + BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(buf), + buf.ArrayMember, NULL); + // Handle big-endian byte-swapping if necessary. + CurWord = buf.EndianMember; NextChar += sizeof(word_t); |