9#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
10#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
48 return Writer->getOffset();
50 return Reader->getOffset();
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);
87 Streamer->emitBytes(BytesSR);
88 incrStreamedLen(
sizeof(
T));
93 return Writer->writeObject(
Value);
96 if (
auto EC = Reader->readObject(ValuePtr))
102 template <
typename T>
105 emitComment(Comment);
106 Streamer->emitIntValue(
Value,
sizeof(
T));
107 incrStreamedLen(
sizeof(
T));
111 return Writer->writeInteger(
Value);
116 return Reader->readInteger(
Value);
122 template <
typename Trunc,
typename T>
124 static_assert(
sizeof(
Trunc) <=
sizeof(
T));
138 using U = std::underlying_type_t<T>;
142 X =
static_cast<U
>(
Value);
160 const Twine &Comment =
"");
162 template <
typename SizeType,
typename T,
typename ElementMapper>
164 const Twine &Comment =
"") {
167 Size =
static_cast<SizeType
>(Items.size());
168 emitComment(Comment);
169 Streamer->emitIntValue(
Size,
sizeof(
Size));
170 incrStreamedLen(
sizeof(
Size));
172 for (
auto &
X : Items) {
173 if (
auto EC = Mapper(*
this,
X))
177 Size =
static_cast<SizeType
>(Items.size());
178 if (
auto EC = Writer->writeInteger(
Size))
181 for (
auto &
X : Items) {
182 if (
auto EC = Mapper(*
this,
X))
186 if (
auto EC = Reader->readInteger(
Size))
188 for (SizeType
I = 0;
I <
Size; ++
I) {
189 typename T::value_type Item;
190 if (
auto EC = Mapper(*
this, Item))
192 Items.push_back(Item);
199 template <
typename T,
typename ElementMapper>
201 const Twine &Comment =
"") {
202 emitComment(Comment);
204 for (
auto &Item : Items) {
205 if (
auto EC = Mapper(*
this, Item))
209 typename T::value_type
Field;
211 while (!Reader->empty() && Reader->peek() < 0xf0 ) {
212 if (
auto EC = Mapper(*
this,
Field))
214 Items.push_back(
Field);
221 const Twine &Comment =
"");
223 const Twine &Comment =
"");
236 Streamer->AddRawComment(
T);
241 const Twine &Comment =
"");
243 const Twine &Comment =
"");
245 void incrStreamedLen(
const uint64_t &Len) {
250 void resetStreamedLen() {
255 void emitComment(
const Twine &Comment) {
257 Twine TComment(Comment);
258 if (!TComment.isTriviallyEmpty())
264 uint32_t BeginOffset;
265 std::optional<uint32_t> MaxLength;
267 std::optional<uint32_t> bytesRemaining(uint32_t CurrentOffset)
const {
270 assert(CurrentOffset >= BeginOffset);
272 uint32_t BytesUsed = CurrentOffset - BeginOffset;
273 if (BytesUsed >= *MaxLength)
275 return *MaxLength - BytesUsed;
279 SmallVector<RecordLimit, 2> Limits;
281 BinaryStreamReader *Reader =
nullptr;
282 BinaryStreamWriter *Writer =
nullptr;
283 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)
LLVM_ABI Error mapWriteInt128(const APSInt &Value, const Twine &Comment="")
Error mapWriteInteger(const T &Value, const Twine &Comment="")
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 void emitAPSIntValue(const APSInt &Value)=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.