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);
115 template <
typename Trunc,
typename T>
117 static_assert(
sizeof(Trunc) <=
sizeof(
T));
119 Trunc Truncated =
static_cast<Trunc
>(
Value);
131 using U = std::underlying_type_t<T>;
135 X =
static_cast<U
>(
Value);
153 const Twine &Comment =
"");
155 template <
typename SizeType,
typename T,
typename ElementMapper>
157 const Twine &Comment =
"") {
160 Size =
static_cast<SizeType
>(Items.size());
161 emitComment(Comment);
162 Streamer->emitIntValue(
Size,
sizeof(
Size));
163 incrStreamedLen(
sizeof(
Size));
165 for (
auto &
X : Items) {
166 if (
auto EC = Mapper(*
this,
X))
170 Size =
static_cast<SizeType
>(Items.size());
171 if (
auto EC = Writer->writeInteger(
Size))
174 for (
auto &
X : Items) {
175 if (
auto EC = Mapper(*
this,
X))
179 if (
auto EC = Reader->readInteger(
Size))
181 for (SizeType
I = 0;
I <
Size; ++
I) {
182 typename T::value_type Item;
183 if (
auto EC = Mapper(*
this, Item))
185 Items.push_back(Item);
192 template <
typename T,
typename ElementMapper>
194 const Twine &Comment =
"") {
195 emitComment(Comment);
197 for (
auto &Item : Items) {
198 if (
auto EC = Mapper(*
this, Item))
202 typename T::value_type
Field;
204 while (!Reader->empty() && Reader->peek() < 0xf0 ) {
205 if (
auto EC = Mapper(*
this,
Field))
207 Items.push_back(
Field);
214 const Twine &Comment =
"");
216 const Twine &Comment =
"");
229 Streamer->AddRawComment(
T);
233 void emitEncodedSignedInteger(
const int64_t &
Value,
234 const Twine &Comment =
"");
236 const Twine &Comment =
"");
237 Error writeEncodedSignedInteger(
const int64_t &
Value);
240 void incrStreamedLen(
const uint64_t &Len) {
245 void resetStreamedLen() {
250 void emitComment(
const Twine &Comment) {
252 Twine TComment(Comment);
253 if (!TComment.isTriviallyEmpty())
259 uint32_t BeginOffset;
260 std::optional<uint32_t> MaxLength;
262 std::optional<uint32_t> bytesRemaining(uint32_t CurrentOffset)
const {
265 assert(CurrentOffset >= BeginOffset);
267 uint32_t BytesUsed = CurrentOffset - BeginOffset;
268 if (BytesUsed >= *MaxLength)
270 return *MaxLength - BytesUsed;
274 SmallVector<RecordLimit, 2> Limits;
276 BinaryStreamReader *Reader =
nullptr;
277 BinaryStreamWriter *Writer =
nullptr;
278 CodeViewRecordStreamer *Streamer =
nullptr;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
OptimizedStructLayoutField Field
This file defines the SmallVector class.
std::unique_ptr< MCStreamer > && Streamer
An arbitrary precision integer that knows its signedness.
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.
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="")
Error mapTruncInteger(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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This represents the 'GUID' type from windows.h.