Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
ok, ok, stop fighting type punning warnings by just using a union.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174827 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Feb 10, 2013
1 parent d8f713e commit 3fc7f48
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions include/llvm/Bitcode/BitstreamReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,16 @@ class BitstreamCursor {
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);

Expand Down

0 comments on commit 3fc7f48

Please sign in to comment.