diff --git a/llvm/include/llvm/Support/ELFAttributeParser.h b/llvm/include/llvm/Support/ELFAttributeParser.h --- a/llvm/include/llvm/Support/ELFAttributeParser.h +++ b/llvm/include/llvm/Support/ELFAttributeParser.h @@ -42,6 +42,10 @@ void parseIndexList(SmallVectorImpl &indexList); Error parseSubsection(uint32_t length); + void setAttributeString(unsigned tag, StringRef value) { + attributesStr.emplace(tag, value); + } + public: virtual ~ELFAttributeParser() { static_cast(!cursor.takeError()); } Error integerAttribute(unsigned tag); diff --git a/llvm/lib/Support/ARMAttributeParser.cpp b/llvm/lib/Support/ARMAttributeParser.cpp --- a/llvm/lib/Support/ARMAttributeParser.cpp +++ b/llvm/lib/Support/ARMAttributeParser.cpp @@ -448,14 +448,18 @@ } } - DictScope scope(*sw, "Attribute"); - sw->printNumber("Tag", tag); - sw->printString("TagName", - ELFAttrs::attrTypeAsString(tag, tagToStringMap, false)); - sw->printStringEscaped("Value", RawStringValue); - if (!Description.empty()) { - sw->printString("Description", Description); + setAttributeString(tag, RawStringValue); + if (sw) { + DictScope scope(*sw, "Attribute"); + sw->printNumber("Tag", tag); + sw->printString("TagName", + ELFAttrs::attrTypeAsString(tag, tagToStringMap, false)); + sw->printStringEscaped("Value", RawStringValue); + if (!Description.empty()) { + sw->printString("Description", Description); + } } + cursor.seek(FinalOffset); return returnValue ? std::move(*returnValue) : Error::success(); diff --git a/llvm/lib/Support/ELFAttributeParser.cpp b/llvm/lib/Support/ELFAttributeParser.cpp --- a/llvm/lib/Support/ELFAttributeParser.cpp +++ b/llvm/lib/Support/ELFAttributeParser.cpp @@ -53,7 +53,7 @@ StringRef tagName = ELFAttrs::attrTypeAsString(tag, tagToStringMap, /*hasTagPrefix=*/false); StringRef desc = de.getCStrRef(cursor); - attributesStr.insert(std::make_pair(tag, desc)); + setAttributeString(tag, desc); if (sw) { DictScope scope(*sw, "Attribute");