diff options
author | Zachary Turner <zturner@google.com> | 2017-02-28 00:04:07 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-02-28 00:04:07 +0000 |
commit | 695ed56ba5d3bd3b86c6a4ed6d79b89eb8fbd2f4 (patch) | |
tree | caf35bd7345bb071545ef39b636b40ffafc41504 /llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp | |
parent | 59cd89332010b22e82c3110d558ff37948c4df1e (diff) | |
download | bcm5719-llvm-695ed56ba5d3bd3b86c6a4ed6d79b89eb8fbd2f4.tar.gz bcm5719-llvm-695ed56ba5d3bd3b86c6a4ed6d79b89eb8fbd2f4.zip |
[PDB] Make streams carry their own endianness.
Before the endianness was specified on each call to read
or write of the StreamReader / StreamWriter, but in practice
it's extremely rare for streams to have data encoded in
multiple different endiannesses, so we should optimize for the
99% use case.
This makes the code cleaner and more general, but otherwise
has NFC.
llvm-svn: 296415
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp index d276aa0b84d..eaa70f2b181 100644 --- a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp +++ b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp @@ -37,7 +37,7 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { // Used to avoid overload ambiguity on APInt construtor. bool FalseVal = false; uint16_t Short; - if (auto EC = Reader.readInteger(Short, llvm::support::little)) + if (auto EC = Reader.readInteger(Short)) return EC; if (Short < LF_NUMERIC) { @@ -49,49 +49,49 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { switch (Short) { case LF_CHAR: { int8_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(8, N, true), false); return Error::success(); } case LF_SHORT: { int16_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(16, N, true), false); return Error::success(); } case LF_USHORT: { uint16_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(16, N, false), true); return Error::success(); } case LF_LONG: { int32_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(32, N, true), false); return Error::success(); } case LF_ULONG: { uint32_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(32, N, FalseVal), true); return Error::success(); } case LF_QUADWORD: { int64_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(64, N, true), false); return Error::success(); } case LF_UQUADWORD: { uint64_t N; - if (auto EC = Reader.readInteger(N, llvm::support::little)) + if (auto EC = Reader.readInteger(N)) return EC; Num = APSInt(APInt(64, N, false), true); return Error::success(); @@ -103,7 +103,7 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { Error llvm::codeview::consume(StringRef &Data, APSInt &Num) { ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end()); - BinaryByteStream S(Bytes); + BinaryByteStream S(Bytes, llvm::support::little); BinaryStreamReader SR(S); auto EC = consume(SR, Num); Data = Data.take_back(SR.bytesRemaining()); @@ -124,12 +124,12 @@ Error llvm::codeview::consume_numeric(BinaryStreamReader &Reader, } Error llvm::codeview::consume(BinaryStreamReader &Reader, uint32_t &Item) { - return Reader.readInteger(Item, llvm::support::little); + return Reader.readInteger(Item); } Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) { ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end()); - BinaryByteStream S(Bytes); + BinaryByteStream S(Bytes, llvm::support::little); BinaryStreamReader SR(S); auto EC = consume(SR, Item); Data = Data.take_back(SR.bytesRemaining()); @@ -137,7 +137,7 @@ Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) { } Error llvm::codeview::consume(BinaryStreamReader &Reader, int32_t &Item) { - return Reader.readInteger(Item, llvm::support::little); + return Reader.readInteger(Item); } Error llvm::codeview::consume(BinaryStreamReader &Reader, StringRef &Item) { |