10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESERIALIZER_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPESERIALIZER_H
36 struct RecordSegment {
41 for (
const auto &R : SubRecords) {
50 static constexpr uint8_t ContinuationLength = 8;
52 RecordSegment CurrentSegment;
58 std::vector<uint8_t> RecordBuffer;
66 bool isInFieldList()
const;
90 #define TYPE_RECORD(EnumName, EnumVal, Name) \
91 virtual Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \
92 return visitKnownRecordImpl(CVR, Record); \
94 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
95 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
96 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
97 return visitKnownMemberImpl<Name##Record>(CVR, Record); \
99 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
100 #include "llvm/DebugInfo/CodeView/TypeRecords.def"
103 template <
typename RecordKind>
104 Error visitKnownRecordImpl(
CVType &CVR, RecordKind &Record) {
105 return Mapping.visitKnownRecord(CVR, Record);
108 template <
typename RecordType>
109 Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
110 assert(CVR.Kind == static_cast<TypeLeafKind>(Record.getKind()));
115 if (
auto EC = Mapping.visitKnownMember(CVR, Record))
120 MutableArrayRef<uint8_t> ThisRecord = getCurrentSubRecordData();
121 auto ExpectedRecord = addPadding(ThisRecord);
123 return ExpectedRecord.takeError();
124 ThisRecord = *ExpectedRecord;
126 CurrentSegment.SubRecords.emplace_back(CVR.Kind, ThisRecord.size());
127 CVR.Data = ThisRecord;
131 assert(ThisRecord.size() % 4 == 0);
132 assert(CurrentSegment.length() % 4 == 0);
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Error visitMemberBegin(CVMemberRecord &Record) override
Error visitTypeEnd(CVType &Record) override
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Tagged union holding either a T or a Error.
CVRecord< TypeLeafKind > CVType
ArrayRef< MutableArrayRef< uint8_t > > records() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Allocate memory in an ever growing pool, as if by bump-pointer.
TypeIndex insertRecordBytes(MutableArrayRef< uint8_t > Record)
static ErrorSuccess success()
Create a success value.
TypeIndex getLastTypeIndex() const
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Error visitMemberEnd(CVMemberRecord &Record) override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
TypeSerializer(BumpPtrAllocator &Storage)
Expected< TypeIndex > visitTypeEndGetIndex(CVType &Record)