22 using namespace llvm::msf;
23 using namespace llvm::pdb;
25 NameMap::NameMap() =
default;
33 make_error<RawError>(raw_error_code::corrupt_file,
34 "Expected name map length"));
36 return make_error<RawError>(raw_error_code::corrupt_file,
37 "Invalid name map length");
41 Stream.
setOffset(StringsOffset + NumberOfBytes);
48 make_error<RawError>(raw_error_code::corrupt_file,
49 "Expected name map hash size"));
54 if (
auto EC = Stream.
readInteger(MaxNumberOfStrings))
56 make_error<RawError>(raw_error_code::corrupt_file,
57 "Expected name map max strings"));
59 if (MaxNumberOfStrings > (UINT32_MAX /
sizeof(
uint32_t)))
60 return make_error<RawError>(raw_error_code::corrupt_file,
61 "Implausible number of strings");
70 make_error<RawError>(raw_error_code::corrupt_file,
71 "Expected name map num words"));
73 if (NumPresentWords > MaxNumberOfWords)
74 return make_error<RawError>(raw_error_code::corrupt_file,
75 "Number of present words is too large");
82 make_error<RawError>(raw_error_code::corrupt_file,
83 "Expected name map word"));
84 for (
unsigned Idx = 0; Idx < 32; ++Idx)
85 if (Word & (1U << Idx))
86 Present.set((
I * 32) + Idx);
95 make_error<RawError>(raw_error_code::corrupt_file,
96 "Expected name map num deleted words"));
98 if (NumDeletedWords > MaxNumberOfWords)
99 return make_error<RawError>(raw_error_code::corrupt_file,
100 "Number of deleted words is too large");
107 make_error<RawError>(raw_error_code::corrupt_file,
108 "Expected name map word"));
109 for (
unsigned Idx = 0; Idx < 32; ++Idx)
110 if (Word & (1U << Idx))
111 Deleted.set((
I * 32) + Idx);
114 for (
unsigned I : Present) {
123 make_error<RawError>(raw_error_code::corrupt_file,
124 "Expected name map name offset"));
130 make_error<RawError>(raw_error_code::corrupt_file,
131 "Expected name map name index"));
134 uint32_t StringOffset = StringsOffset + NameOffset;
141 make_error<RawError>(raw_error_code::corrupt_file,
142 "Expected name map name"));
146 Mapping.insert({Str, NameIndex});
153 return make_range<StringMapConstIterator<uint32_t>>(Mapping.begin(),
158 auto Iter = Mapping.find(Name);
159 if (Iter == Mapping.end())
161 Value = Iter->second;
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
void setOffset(uint32_t Off)
Error readZeroString(StringRef &Dest)
Error readInteger(uint8_t &Dest)
uint32_t getOffset() const
static ErrorSuccess success()
Create a success value.
A range adaptor for a pair of iterators.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
uint32_t bytesRemaining() const
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.