summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-02-18 01:35:33 +0000
committerZachary Turner <zturner@google.com>2017-02-18 01:35:33 +0000
commit181fe17b6f0f434d39b32b90b12844f7a9b55a3b (patch)
treea9c68cad05c7c6c643e75369b57019c314dce048 /llvm/lib/DebugInfo/CodeView
parent0aef305f352235fe66d44e8f253b3b09d27a1b10 (diff)
downloadbcm5719-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')
-rw-r--r--llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp2
-rw-r--r--llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp44
-rw-r--r--llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp20
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp8
4 files changed, 41 insertions, 33 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
index 48160252c6d..db5db3eeded 100644
--- a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
@@ -182,7 +182,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(msf::StreamReader Reader) {
TypeLeafKind Leaf;
while (!Reader.empty()) {
- if (auto EC = Reader.readEnum(Leaf))
+ if (auto EC = Reader.readEnum(Leaf, llvm::support::little))
return EC;
CVMemberRecord Record;
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;
}
diff --git a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
index 6f29caa9bbf..6be9a059b89 100644
--- a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
+++ b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
@@ -37,7 +37,7 @@ Error llvm::codeview::consume(msf::StreamReader &Reader, APSInt &Num) {
// Used to avoid overload ambiguity on APInt construtor.
bool FalseVal = false;
uint16_t Short;
- if (auto EC = Reader.readInteger(Short))
+ if (auto EC = Reader.readInteger(Short, llvm::support::little))
return EC;
if (Short < LF_NUMERIC) {
@@ -49,49 +49,49 @@ Error llvm::codeview::consume(msf::StreamReader &Reader, APSInt &Num) {
switch (Short) {
case LF_CHAR: {
int8_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(8, N, true), false);
return Error::success();
}
case LF_SHORT: {
int16_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(16, N, true), false);
return Error::success();
}
case LF_USHORT: {
uint16_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(16, N, false), true);
return Error::success();
}
case LF_LONG: {
int32_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(32, N, true), false);
return Error::success();
}
case LF_ULONG: {
uint32_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(32, N, FalseVal), true);
return Error::success();
}
case LF_QUADWORD: {
int64_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(64, N, true), false);
return Error::success();
}
case LF_UQUADWORD: {
uint64_t N;
- if (auto EC = Reader.readInteger(N))
+ if (auto EC = Reader.readInteger(N, llvm::support::little))
return EC;
Num = APSInt(APInt(64, N, false), true);
return Error::success();
@@ -124,7 +124,7 @@ Error llvm::codeview::consume_numeric(msf::StreamReader &Reader,
}
Error llvm::codeview::consume(msf::StreamReader &Reader, uint32_t &Item) {
- return Reader.readInteger(Item);
+ return Reader.readInteger(Item, llvm::support::little);
}
Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) {
@@ -137,7 +137,7 @@ Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) {
}
Error llvm::codeview::consume(msf::StreamReader &Reader, int32_t &Item) {
- return Reader.readInteger(Item);
+ return Reader.readInteger(Item, llvm::support::little);
}
Error llvm::codeview::consume(msf::StreamReader &Reader, StringRef &Item) {
diff --git a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
index f24fcff8627..299e9ad6930 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
@@ -76,7 +76,7 @@ TypeSerializer::addPadding(MutableArrayRef<uint8_t> Record) {
int N = PaddingBytes;
while (PaddingBytes > 0) {
uint8_t Pad = static_cast<uint8_t>(LF_PAD0 + PaddingBytes);
- if (auto EC = Writer.writeInteger(Pad))
+ if (auto EC = Writer.writeInteger(Pad, llvm::support::little))
return std::move(EC);
--PaddingBytes;
}
@@ -207,11 +207,11 @@ Error TypeSerializer::visitMemberEnd(CVMemberRecord &Record) {
msf::StreamWriter CW(CS);
if (auto EC = CW.writeBytes(CopyData))
return EC;
- if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX))
+ if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX, llvm::support::little))
return EC;
- if (auto EC = CW.writeInteger(uint16_t(0)))
+ if (auto EC = CW.writeInteger<uint16_t>(0, llvm::support::little))
return EC;
- if (auto EC = CW.writeInteger(uint32_t(0xB0C0B0C0)))
+ if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0, llvm::support::little))
return EC;
FieldListSegments.push_back(SavedSegment);
OpenPOWER on IntegriCloud