7 struct ContinuationRecord {
13 struct SegmentInjection {
16 ContinuationRecord Cont;
26 int PaddingBytes = 4 -
Align;
27 while (PaddingBytes > 0) {
28 uint8_t Pad =
static_cast<uint8_t
>(LF_PAD0 + PaddingBytes);
47 : SegmentWriter(Buffer), Mapping(SegmentWriter) {}
56 SegmentOffsets.
clear();
61 const SegmentInjection *FLI =
64 : &InjectMethodOverloadList;
65 const uint8_t *FLIB =
reinterpret_cast<const uint8_t *
>(FLI);
66 InjectedSegmentBytes =
77 template <
typename RecordType>
91 cantFail(Mapping.visitKnownMember(CVMR, Record));
96 assert(getCurrentSegmentLength() % 4 == 0);
109 insertSegmentEnd(OriginalOffset);
117 assert(getCurrentSegmentLength() % 4 == 0);
121 uint32_t ContinuationRecordBuilder::getCurrentSegmentLength()
const {
125 void ContinuationRecordBuilder::insertSegmentEnd(
uint32_t Offset) {
128 assert(Offset > SegmentBegin);
134 Buffer.
insert(Offset, InjectedSegmentBytes);
137 uint32_t SegmentLength = NewSegmentBegin - SegmentOffsets.
back();
138 (void) SegmentLength;
140 assert(SegmentLength % 4 == 0);
142 SegmentOffsets.
push_back(NewSegmentBegin);
149 CVType ContinuationRecordBuilder::createSegmentRecord(
151 assert(OffEnd - OffBegin <= USHRT_MAX);
154 Data = Data.
slice(OffBegin, OffEnd - OffBegin);
163 ContinuationRecord *CR =
164 reinterpret_cast<ContinuationRecord *
>(Continuation.data());
165 assert(CR->Kind == TypeLeafKind::LF_INDEX);
166 assert(CR->IndexRef == 0xB0C0B0C0);
167 CR->IndexRef = RefersTo->
getIndex();
224 std::vector<CVType> Types;
225 Types.reserve(SegmentOffsets.
size());
233 Types.push_back(createSegmentRecord(Offset, End, RefersTo));
245 #define TYPE_RECORD(EnumName, EnumVal, Name) 246 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 247 #define MEMBER_RECORD(EnumName, EnumVal, Name) \ 248 template void llvm::codeview::ContinuationRecordBuilder::writeMemberType( \ 249 Name##Record &Record); 250 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 251 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
MutableArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static SegmentInjection InjectFieldList(TypeLeafKind::LF_FIELDLIST)
This class represents lattice values for constants.
uint32_t getLength() const
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
void push_back(const T &Elt)
void writeMemberType(RecordType &Record)
void insert(uint32_t Offset, ArrayRef< uint8_t > Bytes)
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
CVRecord< TypeLeafKind > CVType
Error visitMemberEnd(CVMemberRecord &Record) override
static SegmentInjection InjectMethodOverloadList(TypeLeafKind::LF_METHODLIST)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Error visitTypeEnd(CVType &Record) override
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
static constexpr uint32_t MaxSegmentLength
The instances of the Type class are immutable: once they are created, they are never changed...
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
uint32_t getOffset() const
size_t size() const
size - Get the array size.
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
static constexpr uint32_t ContinuationLength
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint32_t getIndex() const
uint32_t bytesRemaining() const
static void addPadding(BinaryStreamWriter &Writer)
MutableArrayRef< uint8_t > data()
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Error writeEnum(T Num)
Similar to writeInteger.
void setOffset(uint32_t Off)
static TypeLeafKind getTypeLeafKind(ContinuationRecordKind CK)
std::vector< CVType > end(TypeIndex Index)
~ContinuationRecordBuilder()
ContinuationRecordBuilder()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void begin(ContinuationRecordKind RecordKind)
Error visitMemberBegin(CVMemberRecord &Record) override