Go to the documentation of this file.
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
10 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
22 #include <type_traits>
26 template <
typename T>
class ArrayRef;
64 : Streamer(&Streamer) {}
72 return (Streamer !=
nullptr) && (Reader ==
nullptr) && (Writer ==
nullptr);
75 return (Reader !=
nullptr) && (Streamer ==
nullptr) && (Writer ==
nullptr);
78 return (Writer !=
nullptr) && (Streamer ==
nullptr) && (Reader ==
nullptr);
88 incrStreamedLen(
sizeof(
T));
104 emitComment(Comment);
106 incrStreamedLen(
sizeof(
T));
120 using U = std::underlying_type_t<T>;
124 X =
static_cast<U
>(
Value);
142 const Twine &Comment =
"");
144 template <
typename SizeType,
typename T,
typename ElementMapper>
146 const Twine &Comment =
"") {
149 Size =
static_cast<SizeType
>(Items.size());
150 emitComment(Comment);
152 incrStreamedLen(
sizeof(Size));
154 for (
auto &
X : Items) {
155 if (
auto EC = Mapper(*
this,
X))
159 Size =
static_cast<SizeType
>(Items.size());
163 for (
auto &
X : Items) {
164 if (
auto EC = Mapper(*
this,
X))
170 for (SizeType
I = 0;
I < Size; ++
I) {
171 typename T::value_type Item;
172 if (
auto EC = Mapper(*
this, Item))
174 Items.push_back(Item);
181 template <
typename T,
typename ElementMapper>
183 const Twine &Comment =
"") {
184 emitComment(Comment);
186 for (
auto &Item : Items) {
187 if (
auto EC = Mapper(*
this, Item))
191 typename T::value_type
Field;
193 while (!Reader->
empty() && Reader->
peek() < 0xf0 ) {
194 if (
auto EC = Mapper(*
this,
Field))
196 Items.push_back(
Field);
204 const Twine &Comment =
"");
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())
248 Optional<uint32_t> MaxLength;
250 Optional<uint32_t> bytesRemaining(
uint32_t CurrentOffset)
const {
251 if (!MaxLength.hasValue())
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;
273 #endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
uint64_t getStreamedLen()
virtual void AddRawComment(const Twine &T)=0
virtual ~CodeViewRecordStreamer()=default
This is an optimization pass for GlobalISel generic memory operations.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
OptimizedStructLayoutField Field
Provides write only access to a subclass of WritableBinaryStream.
Error mapByteVectorTail(ArrayRef< uint8_t > &Bytes, const Twine &Comment="")
static ErrorSuccess success()
Create a success value.
This represents the 'GUID' type from windows.h.
Error mapStringZ(StringRef &Value, const Twine &Comment="")
virtual bool isVerboseAsm()=0
Error mapEnum(T &Value, const Twine &Comment="")
Error padToAlignment(uint32_t Align)
Error mapInteger(T &Value, const Twine &Comment="")
virtual void AddComment(const Twine &T)=0
Error beginRecord(Optional< uint32_t > MaxLength)
CodeViewRecordIO(CodeViewRecordStreamer &Streamer)
uint64_t getOffset() const
Error mapObject(T &Value)
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
An arbitrary precision integer that knows its signedness.
void emitRawComment(const Twine &T)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Error mapVectorN(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Provides read only access to a subclass of BinaryStream.
CodeViewRecordIO(BinaryStreamReader &Reader)
Error mapStringZVectorZ(std::vector< StringRef > &Value, const Twine &Comment="")
virtual std::string getTypeName(TypeIndex TI)=0
uint64_t getOffset() const
virtual void emitBinaryData(StringRef Data)=0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
StringRef - Represent a constant reference to a string, i.e.
Error mapInteger(TypeIndex &TypeInd, const Twine &Comment="")
uint32_t maxFieldLength() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Error mapEncodedInteger(int64_t &Value, const Twine &Comment="")
Lightweight error class with error context and mandatory checking.
virtual void emitIntValue(uint64_t Value, unsigned Size)=0
uint8_t peek() const
Examine the next byte of the underlying stream without advancing the stream's offset.
Error mapGuid(GUID &Guid, const Twine &Comment="")
CodeViewRecordIO(BinaryStreamWriter &Writer)
Error mapVectorTail(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
LLVM Value Representation.
virtual void emitBytes(StringRef Data)=0