Avoid pointer aliasing for double/bits conversions.

Instead use the llvm MathExtras.h functions for this, which use union
aliasing.
This commit is contained in:
Peter Johnson
2015-08-12 17:15:10 -07:00
parent c34ba968f1
commit e9618df1b5
2 changed files with 4 additions and 2 deletions

View File

@@ -12,6 +12,7 @@
#include <cstdlib>
#include <cstring>
#include "llvm/MathExtras.h"
#include "leb128.h"
using namespace nt;
@@ -41,7 +42,7 @@ static double ReadDouble(const char*& buf) {
val <<= 8;
val |= (*((unsigned char*)buf)) & 0xff;
++buf;
return reinterpret_cast<double&>(val);
return llvm::BitsToDouble(val);
}
WireDecoder::WireDecoder(raw_istream& is, unsigned int proto_rev) : m_is(is) {