29 if (value >= strings.
size()) {
33 " value: " +
Twine(value));
43 attributes.insert(std::make_pair(tag, value));
47 sw->printNumber(
"Tag", tag);
49 sw->printString(
"TagName", tagName);
50 sw->printNumber(
"Value", value);
63 sw->printNumber(
"Tag", tag);
65 sw->printString(
"TagName", tagName);
66 sw->printString(
"Value", desc);
73 attributes.insert(std::make_pair(tag, value));
79 sw->printNumber(
"Tag", tag);
80 sw->printNumber(
"Value", value);
82 sw->printString(
"TagName", tagName);
83 if (!valueDesc.
empty())
84 sw->printString(
"Description", valueDesc);
100 while ((pos =
cursor.tell()) < end) {
103 if (
Error e = handler(tag, handled))
129 sw->printNumber(
"SectionLength", length);
130 sw->printString(
"Vendor", vendorName);
137 if (vendorName.
lower() != vendor) {
142 while (
cursor.tell() < end) {
147 return cursor.takeError();
151 sw->printNumber(
"Size",
size);
155 "invalid attribute size " +
Twine(
size) +
163 scopeName =
"FileAttributes";
166 scopeName =
"SectionAttributes";
167 indexName =
"Sections";
171 scopeName =
"SymbolAttributes";
172 indexName =
"Symbols";
184 if (!indices.
empty())
185 sw->printList(indexName, indices);
196 unsigned sectionNumber = 0;
201 struct ClearCursorError {
210 "unrecognized format-version: 0x" +
216 return cursor.takeError();
219 sw->startLine() <<
"Section " << ++sectionNumber <<
" {\n";
223 if (sectionLength < 4 ||
cursor.tell() - 4 + sectionLength > section.
size())
225 "invalid section length " +
226 Twine(sectionLength) +
" at offset 0x" +
233 sw->startLine() <<
"}\n";
237 return cursor.takeError();
static constexpr EnumEntry< unsigned > tagNames[]
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
void setAttributeString(unsigned tag, StringRef value)
Error integerAttribute(unsigned tag)
TagNameMap tagToStringMap
void parseIndexList(SmallVectorImpl< uint8_t > &indexList)
Error stringAttribute(unsigned tag)
Error parseAttributeList(uint32_t length)
void printAttribute(unsigned tag, unsigned value, StringRef valueDesc)
DataExtractor::Cursor cursor
Error parseSubsection(uint32_t length)
Error parse(ArrayRef< uint8_t > section, llvm::endianness endian) override
Error parseStringAttribute(const char *name, unsigned tag, ArrayRef< const char * > strings)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
LLVM_ABI std::string lower() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(uint64_t Val)
LLVM_ABI StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, bool hasTagPrefix=true)
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
ArrayRef(const T &OneElt) -> ArrayRef< T >
void consumeError(Error Err)
Consume a Error without doing anything.