9#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
10#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
47 return Writer->getOffset();
49 return Reader->getOffset();
63 : Streamer(&Streamer) {}
71 return (Streamer !=
nullptr) && (Reader ==
nullptr) && (Writer ==
nullptr);
74 return (Reader !=
nullptr) && (Streamer ==
nullptr) && (Writer ==
nullptr);
77 return (Writer !=
nullptr) && (Streamer ==
nullptr) && (Reader ==
nullptr);
86 Streamer->emitBytes(BytesSR);
87 incrStreamedLen(
sizeof(
T));
92 return Writer->writeObject(
Value);
95 if (
auto EC = Reader->readObject(ValuePtr))
103 emitComment(Comment);
104 Streamer->emitIntValue((
int)
Value,
sizeof(
T));
105 incrStreamedLen(
sizeof(
T));
110 return Writer->writeInteger(
Value);
112 return Reader->readInteger(
Value);
119 using U = std::underlying_type_t<T>;
123 X =
static_cast<U
>(
Value);
141 const Twine &Comment =
"");
143 template <
typename SizeType,
typename T,
typename ElementMapper>
145 const Twine &Comment =
"") {
148 Size =
static_cast<SizeType
>(Items.size());
149 emitComment(Comment);
150 Streamer->emitIntValue(
Size,
sizeof(
Size));
151 incrStreamedLen(
sizeof(
Size));
153 for (
auto &
X : Items) {
154 if (
auto EC = Mapper(*
this,
X))
158 Size =
static_cast<SizeType
>(Items.size());
159 if (
auto EC = Writer->writeInteger(
Size))
162 for (
auto &
X : Items) {
163 if (
auto EC = Mapper(*
this,
X))
167 if (
auto EC = Reader->readInteger(
Size))
169 for (SizeType
I = 0;
I <
Size; ++
I) {
170 typename T::value_type Item;
171 if (
auto EC = Mapper(*
this, Item))
173 Items.push_back(Item);
180 template <
typename T,
typename ElementMapper>
182 const Twine &Comment =
"") {
183 emitComment(Comment);
185 for (
auto &Item : Items) {
186 if (
auto EC = Mapper(*
this, Item))
190 typename T::value_type
Field;
192 while (!Reader->empty() && Reader->peek() < 0xf0 ) {
193 if (
auto EC = Mapper(*
this,
Field))
195 Items.push_back(
Field);
202 const Twine &Comment =
"");
204 const Twine &Comment =
"");
217 Streamer->AddRawComment(
T);
221 void emitEncodedSignedInteger(
const int64_t &
Value,
222 const Twine &Comment =
"");
224 const Twine &Comment =
"");
225 Error writeEncodedSignedInteger(
const int64_t &
Value);
228 void incrStreamedLen(
const uint64_t &Len) {
233 void resetStreamedLen() {
238 void emitComment(
const Twine &Comment) {
240 Twine TComment(Comment);
241 if (!TComment.isTriviallyEmpty())
247 uint32_t BeginOffset;
248 std::optional<uint32_t> MaxLength;
250 std::optional<uint32_t> bytesRemaining(uint32_t CurrentOffset)
const {
253 assert(CurrentOffset >= BeginOffset);
255 uint32_t BytesUsed = CurrentOffset - BeginOffset;
256 if (BytesUsed >= *MaxLength)
258 return *MaxLength - BytesUsed;
262 SmallVector<RecordLimit, 2> Limits;
264 BinaryStreamReader *Reader =
nullptr;
265 BinaryStreamWriter *Writer =
nullptr;
266 CodeViewRecordStreamer *Streamer =
nullptr;
267 uint64_t StreamedLen = 0;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
OptimizedStructLayoutField Field
This file defines the SmallVector class.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Provides read only access to a subclass of BinaryStream.
Provides write only access to a subclass of WritableBinaryStream.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
Error mapVectorTail(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
CodeViewRecordIO(BinaryStreamWriter &Writer)
LLVM_ABI Error padToAlignment(uint32_t Align)
Error mapVectorN(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
Error mapInteger(T &Value, const Twine &Comment="")
LLVM_ABI Error endRecord()
LLVM_ABI Error mapInteger(TypeIndex &TypeInd, const Twine &Comment="")
CodeViewRecordIO(BinaryStreamReader &Reader)
LLVM_ABI Error mapGuid(GUID &Guid, const Twine &Comment="")
LLVM_ABI Error mapStringZVectorZ(std::vector< StringRef > &Value, const Twine &Comment="")
LLVM_ABI Error skipPadding()
LLVM_ABI Error mapStringZ(StringRef &Value, const Twine &Comment="")
Error mapObject(T &Value)
uint64_t getStreamedLen()
Error mapEnum(T &Value, const Twine &Comment="")
LLVM_ABI Error mapEncodedInteger(int64_t &Value, const Twine &Comment="")
LLVM_ABI Error beginRecord(std::optional< uint32_t > MaxLength)
LLVM_ABI Error mapByteVectorTail(ArrayRef< uint8_t > &Bytes, const Twine &Comment="")
CodeViewRecordIO(CodeViewRecordStreamer &Streamer)
LLVM_ABI uint32_t maxFieldLength() const
void emitRawComment(const Twine &T)
virtual void emitBytes(StringRef Data)=0
virtual bool isVerboseAsm()=0
virtual void AddComment(const Twine &T)=0
virtual void emitIntValue(uint64_t Value, unsigned Size)=0
virtual void emitBinaryData(StringRef Data)=0
virtual std::string getTypeName(TypeIndex TI)=0
virtual ~CodeViewRecordStreamer()=default
virtual void AddRawComment(const Twine &T)=0
This is an optimization pass for GlobalISel generic memory operations.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
This struct is a compact representation of a valid (non-zero power of two) alignment.
This represents the 'GUID' type from windows.h.