[ARM] Rewrite ARMAttributeParser
* Delete boilerplate
* Change functions to return `Error`
* Test parsing errors
* Update callers of ARMAttributeParser::parse() to check the `Error` return value.
Since this patch touches nearly everything in the file, I apply
http://llvm.org/docs/Proposals/VariableNames.html and change variable
names to lower case.
Reviewed By: compnerd
Differential Revision: https://reviews.llvm.org/D75015
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index bf6ffd6..855e032 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -157,8 +157,10 @@
SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
SubtargetFeatures Features;
ARMAttributeParser Attributes;
- if (Error E = getBuildAttributes(Attributes))
+ if (Error E = getBuildAttributes(Attributes)) {
+ consumeError(std::move(E));
return SubtargetFeatures();
+ }
// both ARMv7-M and R have to support thumb hardware div
bool isV7 = false;
@@ -305,8 +307,11 @@
return;
ARMAttributeParser Attributes;
- if (Error E = getBuildAttributes(Attributes))
+ if (Error E = getBuildAttributes(Attributes)) {
+ // TODO Propagate Error.
+ consumeError(std::move(E));
return;
+ }
std::string Triple;
// Default to ARM, but use the triple if it's been set.