diff options
author | Zachary Turner <zturner@google.com> | 2017-02-18 01:35:33 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-02-18 01:35:33 +0000 |
commit | 181fe17b6f0f434d39b32b90b12844f7a9b55a3b (patch) | |
tree | a9c68cad05c7c6c643e75369b57019c314dce048 /llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | |
parent | 0aef305f352235fe66d44e8f253b3b09d27a1b10 (diff) | |
download | bcm5719-llvm-181fe17b6f0f434d39b32b90b12844f7a9b55a3b.tar.gz bcm5719-llvm-181fe17b6f0f434d39b32b90b12844f7a9b55a3b.zip |
Don't assume little endian in StreamReader / StreamWriter.
In an effort to generalize this so it can be used by more than
just PDB code, we shouldn't assume little endian.
llvm-svn: 295525
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index 9bd85cf9dc6..b7e74a1f455 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -87,13 +87,14 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) { Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { if (isWriting()) { - if (auto EC = Writer->writeInteger(TypeInd.getIndex())) + if (auto EC = + Writer->writeInteger(TypeInd.getIndex(), llvm::support::little)) return EC; return Error::success(); } uint32_t I; - if (auto EC = Reader->readInteger(I)) + if (auto EC = Reader->readInteger(I, llvm::support::little)) return EC; TypeInd.setIndex(I); return Error::success(); @@ -176,7 +177,7 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { if (auto EC = mapStringZ(V)) return EC; } - if (auto EC = Writer->writeInteger(uint8_t(0))) + if (auto EC = Writer->writeInteger<uint8_t>(0, llvm::support::little)) return EC; } else { StringRef S; @@ -194,24 +195,28 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { assert(Value < 0 && "Encoded integer is not signed!"); if (Value >= std::numeric_limits<int8_t>::min()) { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_CHAR))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_CHAR, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(static_cast<int8_t>(Value))) + if (auto EC = Writer->writeInteger<int8_t>(Value, llvm::support::little)) return EC; } else if (Value >= std::numeric_limits<int16_t>::min()) { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_SHORT))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_SHORT, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(static_cast<int16_t>(Value))) + if (auto EC = Writer->writeInteger<int16_t>(Value, llvm::support::little)) return EC; } else if (Value >= std::numeric_limits<int32_t>::min()) { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_LONG))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_LONG, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(static_cast<int32_t>(Value))) + if (auto EC = Writer->writeInteger<int32_t>(Value, llvm::support::little)) return EC; } else { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_QUADWORD))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_QUADWORD, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(Value)) + if (auto EC = Writer->writeInteger(Value, llvm::support::little)) return EC; } return Error::success(); @@ -219,22 +224,25 @@ Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { Error CodeViewRecordIO::writeEncodedUnsignedInteger(const uint64_t &Value) { if (Value < LF_NUMERIC) { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(Value))) + if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little)) return EC; } else if (Value <= std::numeric_limits<uint16_t>::max()) { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_USHORT))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_USHORT, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(Value))) + if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little)) return EC; } else if (Value <= std::numeric_limits<uint32_t>::max()) { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_ULONG))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_ULONG, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(static_cast<uint32_t>(Value))) + if (auto EC = Writer->writeInteger<uint32_t>(Value, llvm::support::little)) return EC; } else { - if (auto EC = Writer->writeInteger(static_cast<uint16_t>(LF_UQUADWORD))) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_UQUADWORD, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(Value)) + if (auto EC = Writer->writeInteger(Value, llvm::support::little)) return EC; } |