[llvm] 1d66c5e - [ARM] Fix bug in also_compatible_with attribute parser
Victor Campos via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 22 01:40:46 PDT 2022
Author: Victor Campos
Date: 2022-08-22T09:40:37+01:00
New Revision: 1d66c5ebbc43cb8c08e5aa54310b7b09d965a808
URL: https://github.com/llvm/llvm-project/commit/1d66c5ebbc43cb8c08e5aa54310b7b09d965a808
DIFF: https://github.com/llvm/llvm-project/commit/1d66c5ebbc43cb8c08e5aa54310b7b09d965a808.diff
LOG: [ARM] Fix bug in also_compatible_with attribute parser
Check ScopedPrinter pointer before attempting to print the attribute's
parsed information.
Patch by Michael Platings and Victor Campos
Reviewed By: pratlucas
Differential Revision: https://reviews.llvm.org/D132214
Added:
Modified:
llvm/include/llvm/Support/ELFAttributeParser.h
llvm/lib/Support/ARMAttributeParser.cpp
llvm/lib/Support/ELFAttributeParser.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/ELFAttributeParser.h b/llvm/include/llvm/Support/ELFAttributeParser.h
index 3062dfffff68a..89a1acc8a1f9b 100644
--- a/llvm/include/llvm/Support/ELFAttributeParser.h
+++ b/llvm/include/llvm/Support/ELFAttributeParser.h
@@ -42,6 +42,10 @@ class ELFAttributeParser {
void parseIndexList(SmallVectorImpl<uint8_t> &indexList);
Error parseSubsection(uint32_t length);
+ void setAttributeString(unsigned tag, StringRef value) {
+ attributesStr.emplace(tag, value);
+ }
+
public:
virtual ~ELFAttributeParser() { static_cast<void>(!cursor.takeError()); }
Error integerAttribute(unsigned tag);
diff --git a/llvm/lib/Support/ARMAttributeParser.cpp b/llvm/lib/Support/ARMAttributeParser.cpp
index af79a58c73699..5f79510a45d2c 100644
--- a/llvm/lib/Support/ARMAttributeParser.cpp
+++ b/llvm/lib/Support/ARMAttributeParser.cpp
@@ -448,14 +448,18 @@ Error ARMAttributeParser::also_compatible_with(AttrType tag) {
}
}
- 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
index cf8a666e92bc0..2ea736e6cc059 100644
--- a/llvm/lib/Support/ELFAttributeParser.cpp
+++ b/llvm/lib/Support/ELFAttributeParser.cpp
@@ -53,7 +53,7 @@ Error ELFAttributeParser::stringAttribute(unsigned tag) {
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");
More information about the llvm-commits
mailing list