diff options
author | Zachary Turner <zturner@google.com> | 2017-02-25 00:44:30 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-02-25 00:44:30 +0000 |
commit | af299ea5d456aa2fc19d7fdb041a0452d209fd4c (patch) | |
tree | 2d863cba130306041941aeec5b44baa2e9c00ec1 /llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | |
parent | 42de38076517bc68a2b97c55dcbac7ea8d80b11b (diff) | |
download | bcm5719-llvm-af299ea5d456aa2fc19d7fdb041a0452d209fd4c.tar.gz bcm5719-llvm-af299ea5d456aa2fc19d7fdb041a0452d209fd4c.zip |
[PDB] General improvements to Stream library.
This adds various new functionality and cleanup surrounding the
use of the Stream library. Major changes include:
* Renaming of all classes for more consistency / meaningfulness
* Addition of some new methods for reading multiple values at once.
* Full suite of unit tests for reader / writer functionality.
* Full set of doxygen comments for all classes.
* Streams now store their own endianness.
* Fixed some bugs in a few of the classes that were discovered
by the unit tests.
llvm-svn: 296215
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index fd60059b5c6..a204d43ba13 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -87,14 +87,13 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) { Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { if (isWriting()) { - if (auto EC = - Writer->writeInteger(TypeInd.getIndex(), llvm::support::little)) + if (auto EC = Writer->writeInteger(TypeInd.getIndex())) return EC; return Error::success(); } uint32_t I; - if (auto EC = Reader->readInteger(I, llvm::support::little)) + if (auto EC = Reader->readInteger(I)) return EC; TypeInd.setIndex(I); return Error::success(); @@ -146,10 +145,10 @@ Error CodeViewRecordIO::mapStringZ(StringRef &Value) { if (isWriting()) { // Truncate if we attempt to write too much. StringRef S = Value.take_front(maxFieldLength() - 1); - if (auto EC = Writer->writeZeroString(S)) + if (auto EC = Writer->writeCString(S)) return EC; } else { - if (auto EC = Reader->readZeroString(Value)) + if (auto EC = Reader->readCString(Value)) return EC; } return Error::success(); @@ -177,7 +176,7 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { if (auto EC = mapStringZ(V)) return EC; } - if (auto EC = Writer->writeInteger<uint8_t>(0, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint8_t>(0)) return EC; } else { StringRef S; @@ -195,28 +194,24 @@ 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<uint16_t>(LF_CHAR, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_CHAR)) return EC; - if (auto EC = Writer->writeInteger<int8_t>(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger<int8_t>(Value)) return EC; } else if (Value >= std::numeric_limits<int16_t>::min()) { - if (auto EC = - Writer->writeInteger<uint16_t>(LF_SHORT, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_SHORT)) return EC; - if (auto EC = Writer->writeInteger<int16_t>(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger<int16_t>(Value)) return EC; } else if (Value >= std::numeric_limits<int32_t>::min()) { - if (auto EC = - Writer->writeInteger<uint16_t>(LF_LONG, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_LONG)) return EC; - if (auto EC = Writer->writeInteger<int32_t>(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger<int32_t>(Value)) return EC; } else { - if (auto EC = - Writer->writeInteger<uint16_t>(LF_QUADWORD, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_QUADWORD)) return EC; - if (auto EC = Writer->writeInteger(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger(Value)) return EC; } return Error::success(); @@ -224,25 +219,22 @@ Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { Error CodeViewRecordIO::writeEncodedUnsignedInteger(const uint64_t &Value) { if (Value < LF_NUMERIC) { - if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(Value)) return EC; } else if (Value <= std::numeric_limits<uint16_t>::max()) { - if (auto EC = - Writer->writeInteger<uint16_t>(LF_USHORT, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_USHORT)) return EC; - if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(Value)) return EC; } else if (Value <= std::numeric_limits<uint32_t>::max()) { - if (auto EC = - Writer->writeInteger<uint16_t>(LF_ULONG, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_ULONG)) return EC; - if (auto EC = Writer->writeInteger<uint32_t>(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint32_t>(Value)) return EC; } else { - if (auto EC = - Writer->writeInteger<uint16_t>(LF_UQUADWORD, llvm::support::little)) + if (auto EC = Writer->writeInteger<uint16_t>(LF_UQUADWORD)) return EC; - if (auto EC = Writer->writeInteger(Value, llvm::support::little)) + if (auto EC = Writer->writeInteger(Value)) return EC; } |