LLVM: include/llvm/DebugInfo/CodeView/TypeDeserializer.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H
10#define LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H
11
21#include
22#include
23#include
24
25namespace llvm {
27
29 struct MappingInfo {
32 Mapping(Reader) {}
33
37 };
38
39public:
41
45 if (auto EC = I.Mapping.visitTypeBegin(CVT))
46 return EC;
47 if (auto EC = I.Mapping.visitKnownRecord(CVT, Record))
48 return EC;
49 if (auto EC = I.Mapping.visitTypeEnd(CVT))
50 return EC;
52 }
53
54 template
63 return std::move(EC);
65 }
66
68 assert(!Mapping && "Already in a type mapping!");
69 Mapping = std::make_unique(Record.content());
70 return Mapping->Mapping.visitTypeBegin(Record);
71 }
72
76
78 assert(Mapping && "Not in a type mapping!");
79 auto EC = Mapping->Mapping.visitTypeEnd(Record);
80 Mapping.reset();
81 return EC;
82 }
83
84#define TYPE_RECORD(EnumName, EnumVal, Name) \
85 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \
86 return visitKnownRecordImpl<Name##Record>(CVR, Record); \
87 }
88#define MEMBER_RECORD(EnumName, EnumVal, Name)
89#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
90#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
91#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
92
93private:
94 template
96 return Mapping->Mapping.visitKnownRecord(CVR, Record);
97 }
98
99 std::unique_ptr Mapping;
100};
101
103 struct MappingInfo {
105 : Reader(R), Mapping(Reader), StartOffset(0) {}
106
110 };
111
112public:
118
124
126 Mapping.StartOffset = Mapping.Reader.getOffset();
127 return Mapping.Mapping.visitMemberBegin(Record);
128 }
129
131 if (auto EC = Mapping.Mapping.visitMemberEnd(Record))
132 return EC;
134 }
135
136#define TYPE_RECORD(EnumName, EnumVal, Name)
137#define MEMBER_RECORD(EnumName, EnumVal, Name) \
138 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139 return visitKnownMemberImpl<Name##Record>(CVR, Record); \
140 }
141#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
142#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
143#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
144
145private:
146 template
148 if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149 return EC;
150
152 uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153 Mapping.Reader.setOffset(Mapping.StartOffset);
154 if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155 return EC;
158 }
159 MappingInfo Mapping;
160};
161
162}
163}
164
165#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
FunctionLoweringInfo::StatepointRelocationRecord RecordType
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
Provides read only access to a subclass of BinaryStream.
LLVM_ABI Error readBytes(ArrayRef< uint8_t > &Buffer, uint32_t Size)
Read Size bytes from the underlying stream at the current offset and and set Buffer to the resulting ...
uint64_t getOffset() const
void setOffset(uint64_t Off)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
ArrayRef< uint8_t > content() const
Error visitMemberEnd(CVMemberRecord &Record) override
Definition TypeDeserializer.h:130
FieldListDeserializer(BinaryStreamReader &Reader)
Definition TypeDeserializer.h:113
~FieldListDeserializer() override
Definition TypeDeserializer.h:119
Error visitMemberBegin(CVMemberRecord &Record) override
Definition TypeDeserializer.h:125
Error visitTypeEnd(CVType &Record) override
Definition TypeDeserializer.h:77
TypeDeserializer()=default
Error visitTypeBegin(CVType &Record, TypeIndex Index) override
Definition TypeDeserializer.h:73
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Definition TypeDeserializer.h:67
static Expected< T > deserializeAs(ArrayRef< uint8_t > Data)
Definition TypeDeserializer.h:55
static Error deserializeAs(CVType &CVT, T &Record)
Definition TypeDeserializer.h:42
CVRecord< TypeLeafKind > CVType
TypeRecordKind
Distinguishes individual records in .debug$T or .debug$P section or PDB type stream.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
void consumeError(Error Err)
Consume a Error without doing anything.