27 using namespace llvm::pdb;
41 FinalizedHashTable.
clear();
42 FinalizedInfo.
reset();
48 "Expected string buffer size"));
51 if (
auto EC = Stream.
readStreamRef(StringsBuffer, StringBufferSize))
55 if (
auto EC = OffsetIndexMap.
load(Stream))
60 for (
const auto &Entry : OffsetIndexMap) {
61 std::tie(NameOffset, NameIndex) = Entry;
71 "Expected name map name"));
74 Mapping.
insert({Str, NameIndex});
84 if (
auto EC = Writer.
writeInteger(FinalizedInfo->StringDataBytes))
89 if (Item == Mapping.
end())
96 if (
auto EC = FinalizedHashTable.
commit(Writer))
104 return FinalizedInfo->SerializedLength;
107 FinalizedHashTable.
clear();
112 if (Item == Mapping.
end())
114 FinalizedHashTable.
set(FinalizedInfo->StringDataBytes, Item->
getValue());
115 FinalizedInfo->StringDataBytes += Item->getKeyLength() + 1;
121 FinalizedInfo->SerializedLength += FinalizedInfo->StringDataBytes;
123 FinalizedInfo->SerializedLength +=
125 return FinalizedInfo->SerializedLength;
130 return make_range<StringMapConstIterator<uint32_t>>(Mapping.
begin(),
137 auto Iter = Mapping.
find(Stream);
138 if (Iter == Mapping.
end())
140 StreamNo = Iter->second;
145 FinalizedInfo.
reset();
146 Mapping[Stream] = StreamNo;
150 FinalizedInfo.
reset();
151 Mapping.
erase(Stream);
uint32_t calculateSerializedLength() const
void remove(StringRef Stream)
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
iterator find(StringRef Key)
void set(StringRef Stream, uint32_t StreamNo)
Error commit(BinaryStreamWriter &Writer) const
static constexpr const char * OrderedStreamNames[]
Error readCString(StringRef &Dest)
Read a null terminated string from Dest.
void set(uint32_t K, uint32_t V)
const T & getValue() const LLVM_LVALUE_FUNCTION
Error load(BinaryStreamReader &Stream)
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
iterator_range< StringMapConstIterator< uint32_t > > entries() const
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the the integer Value to the underlying stream in the specified endianness. ...
Error load(BinaryStreamReader &Stream)
Error writeCString(StringRef Str)
Write the the string Str to the underlying stream followed by a null terminator.
void setOffset(uint32_t Off)
static ErrorSuccess success()
Create a success value.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
A range adaptor for a pair of iterators.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Error readStreamRef(BinaryStreamRef &Ref)
Read the entire remainder of the underlying stream into Ref.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Error commit(BinaryStreamWriter &Writer) const
Lightweight error class with error context and mandatory checking.
bool get(StringRef Stream, uint32_t &StreamNo) const
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
void emplace(ArgTypes &&...Args)
Create a new object by constructing it in place with the given arguments.