diff options
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index 1af59ff679dd..a66f9af98835 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -8,7 +8,9 @@ #include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" #include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/GUID.h" #include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamWriter.h" @@ -68,10 +70,10 @@ uint32_t CodeViewRecordIO::maxFieldLength() const { Optional<uint32_t> Min = Limits.front().bytesRemaining(Offset); for (auto X : makeArrayRef(Limits).drop_front()) { Optional<uint32_t> ThisMin = X.bytesRemaining(Offset); - if (ThisMin.hasValue()) - Min = (Min.hasValue()) ? std::min(*Min, *ThisMin) : *ThisMin; + if (ThisMin) + Min = Min ? std::min(*Min, *ThisMin) : *ThisMin; } - assert(Min.hasValue() && "Every field must have a maximum length!"); + assert(Min && "Every field must have a maximum length!"); return *Min; } @@ -279,17 +281,24 @@ void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value, // FIXME: There are no test cases covering this function. // This may be because we always consider enumerators to be unsigned. // See FIXME at CodeViewDebug.cpp : CodeViewDebug::lowerTypeEnum. - if (Value >= std::numeric_limits<int8_t>::min()) { + if (Value < LF_NUMERIC && Value >= 0) { + emitComment(Comment); + Streamer->emitIntValue(Value, 2); + incrStreamedLen(2); + } else if (Value >= std::numeric_limits<int8_t>::min() && + Value <= std::numeric_limits<int8_t>::max()) { Streamer->emitIntValue(LF_CHAR, 2); emitComment(Comment); Streamer->emitIntValue(Value, 1); incrStreamedLen(3); - } else if (Value >= std::numeric_limits<int16_t>::min()) { + } else if (Value >= std::numeric_limits<int16_t>::min() && + Value <= std::numeric_limits<int16_t>::max()) { Streamer->emitIntValue(LF_SHORT, 2); emitComment(Comment); Streamer->emitIntValue(Value, 2); incrStreamedLen(4); - } else if (Value >= std::numeric_limits<int32_t>::min()) { + } else if (Value >= std::numeric_limits<int32_t>::min() && + Value <= std::numeric_limits<int32_t>::max()) { Streamer->emitIntValue(LF_LONG, 2); emitComment(Comment); Streamer->emitIntValue(Value, 4); @@ -328,17 +337,23 @@ void CodeViewRecordIO::emitEncodedUnsignedInteger(const uint64_t &Value, } Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { - if (Value >= std::numeric_limits<int8_t>::min()) { + if (Value < LF_NUMERIC && Value >= 0) { + if (auto EC = Writer->writeInteger<int16_t>(Value)) + return EC; + } else if (Value >= std::numeric_limits<int8_t>::min() && + Value <= std::numeric_limits<int8_t>::max()) { if (auto EC = Writer->writeInteger<uint16_t>(LF_CHAR)) return EC; if (auto EC = Writer->writeInteger<int8_t>(Value)) return EC; - } else if (Value >= std::numeric_limits<int16_t>::min()) { + } else if (Value >= std::numeric_limits<int16_t>::min() && + Value <= std::numeric_limits<int16_t>::max()) { if (auto EC = Writer->writeInteger<uint16_t>(LF_SHORT)) return EC; if (auto EC = Writer->writeInteger<int16_t>(Value)) return EC; - } else if (Value >= std::numeric_limits<int32_t>::min()) { + } else if (Value >= std::numeric_limits<int32_t>::min() && + Value <= std::numeric_limits<int32_t>::max()) { if (auto EC = Writer->writeInteger<uint16_t>(LF_LONG)) return EC; if (auto EC = Writer->writeInteger<int32_t>(Value)) |