diff options
Diffstat (limited to 'lib/DebugInfo/CodeView/TypeRecordBuilder.cpp')
-rw-r--r-- | lib/DebugInfo/CodeView/TypeRecordBuilder.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp b/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp index cbf464fd7668..112612cc85ea 100644 --- a/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp +++ b/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp @@ -12,8 +12,8 @@ using namespace llvm; using namespace codeview; -TypeRecordBuilder::TypeRecordBuilder(TypeRecordKind Kind) : Stream(Buffer), - Writer(Stream) { +TypeRecordBuilder::TypeRecordBuilder(TypeRecordKind Kind) + : Stream(Buffer), Writer(Stream) { writeTypeRecordKind(Kind); } @@ -60,50 +60,50 @@ void TypeRecordBuilder::writeEncodedInteger(int64_t Value) { void TypeRecordBuilder::writeEncodedSignedInteger(int64_t Value) { if (Value >= std::numeric_limits<int8_t>::min() && Value <= std::numeric_limits<int8_t>::max()) { - writeUInt16(static_cast<uint16_t>(TypeRecordKind::SByte)); + writeUInt16(LF_CHAR); writeInt16(static_cast<int8_t>(Value)); } else if (Value >= std::numeric_limits<int16_t>::min() && Value <= std::numeric_limits<int16_t>::max()) { - writeUInt16(static_cast<uint16_t>(TypeRecordKind::Int16)); + writeUInt16(LF_SHORT); writeInt16(static_cast<int16_t>(Value)); } else if (Value >= std::numeric_limits<int32_t>::min() && Value <= std::numeric_limits<int32_t>::max()) { - writeUInt16(static_cast<uint32_t>(TypeRecordKind::Int32)); + writeUInt16(LF_LONG); writeInt32(static_cast<int32_t>(Value)); } else { - writeUInt16(static_cast<uint16_t>(TypeRecordKind::Int64)); + writeUInt16(LF_QUADWORD); writeInt64(Value); } } void TypeRecordBuilder::writeEncodedUnsignedInteger(uint64_t Value) { - if (Value < static_cast<uint16_t>(TypeRecordKind::SByte)) { + if (Value < LF_CHAR) { writeUInt16(static_cast<uint16_t>(Value)); } else if (Value <= std::numeric_limits<uint16_t>::max()) { - writeUInt16(static_cast<uint16_t>(TypeRecordKind::UInt16)); + writeUInt16(LF_USHORT); writeUInt16(static_cast<uint16_t>(Value)); } else if (Value <= std::numeric_limits<uint32_t>::max()) { - writeUInt16(static_cast<uint16_t>(TypeRecordKind::UInt32)); + writeUInt16(LF_ULONG); writeUInt32(static_cast<uint32_t>(Value)); } else { - writeUInt16(static_cast<uint16_t>(TypeRecordKind::UInt64)); + writeUInt16(LF_UQUADWORD); writeUInt64(Value); } } -void TypeRecordBuilder::writeNullTerminatedString(const char *Value) { - assert(Value != nullptr); - - size_t Length = strlen(Value); - Stream.write(Value, Length); - writeUInt8(0); -} - void TypeRecordBuilder::writeNullTerminatedString(StringRef Value) { + // Microsoft's linker seems to have trouble with symbol names longer than + // 0xffd8 bytes. + Value = Value.substr(0, 0xffd8); Stream.write(Value.data(), Value.size()); writeUInt8(0); } +void TypeRecordBuilder::writeGuid(StringRef Guid) { + assert(Guid.size() == 16); + Stream.write(Guid.data(), 16); +} + void TypeRecordBuilder::writeTypeIndex(TypeIndex TypeInd) { writeUInt32(TypeInd.getIndex()); } |