[ARM] Change ARMAttributeParser::Parse to use support::endianness and simplify
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index b3f8984..c37436e 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -842,7 +842,8 @@
       break;
     ARMAttributeParser attributes;
     ArrayRef<uint8_t> contents = check(this->getObj().getSectionContents(&sec));
-    attributes.Parse(contents, /*isLittle*/ config->ekind == ELF32LEKind);
+    attributes.parse(contents, config->ekind == ELF32LEKind ? support::little
+                                                            : support::big);
     updateSupportedARMFeatures(attributes);
     updateARMVFPArgs(attributes, this);
 
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index 8a68e49..7effce6 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -380,7 +380,7 @@
         if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
           return Error::success();
 
-        Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
+        Attributes.parse(Contents, ELFT::TargetEndianness);
         break;
       }
     }
diff --git a/llvm/include/llvm/Support/ARMAttributeParser.h b/llvm/include/llvm/Support/ARMAttributeParser.h
index f6c39ab..df7417f 100644
--- a/llvm/include/llvm/Support/ARMAttributeParser.h
+++ b/llvm/include/llvm/Support/ARMAttributeParser.h
@@ -11,6 +11,7 @@
 
 #include "ARMBuildAttributes.h"
 #include "ScopedPrinter.h"
+#include "llvm/Support/Endian.h"
 
 #include <map>
 
@@ -124,7 +125,7 @@
 
   ARMAttributeParser() : SW(nullptr) { }
 
-  void Parse(ArrayRef<uint8_t> Section, bool isLittle);
+  void parse(ArrayRef<uint8_t> Section, support::endianness E);
 
   bool hasAttribute(unsigned Tag) const {
     return Attributes.count(Tag);
diff --git a/llvm/lib/Support/ARMAttributeParser.cpp b/llvm/lib/Support/ARMAttributeParser.cpp
index 8a89f4c..812b160 100644
--- a/llvm/lib/Support/ARMAttributeParser.cpp
+++ b/llvm/lib/Support/ARMAttributeParser.cpp
@@ -695,14 +695,14 @@
   }
 }
 
-void ARMAttributeParser::Parse(ArrayRef<uint8_t> Section, bool isLittle) {
+void ARMAttributeParser::parse(ArrayRef<uint8_t> Section,
+                               support::endianness E) {
   uint64_t Offset = 1;
   unsigned SectionNumber = 0;
 
   while (Offset < Section.size()) {
-    uint32_t SectionLength = isLittle ?
-      support::endian::read32le(Section.data() + Offset) :
-      support::endian::read32be(Section.data() + Offset);
+    uint32_t SectionLength =
+        support::endian::read32(Section.data() + Offset, E);
 
     if (SW) {
       SW->startLine() << "Section " << ++SectionNumber << " {\n";
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 794c463..93ec477 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2688,7 +2688,7 @@
     if (Contents.size() == 1)
       continue;
 
-    ARMAttributeParser(&W).Parse(Contents, true);
+    ARMAttributeParser(&W).parse(Contents, support::little);
   }
 }
 
diff --git a/llvm/unittests/Support/ARMAttributeParser.cpp b/llvm/unittests/Support/ARMAttributeParser.cpp
index 6781acc..adb36de 100644
--- a/llvm/unittests/Support/ARMAttributeParser.cpp
+++ b/llvm/unittests/Support/ARMAttributeParser.cpp
@@ -34,7 +34,7 @@
     reinterpret_cast<const uint8_t*>(OS.str().c_str()), OS.str().size());
 
   ARMAttributeParser Parser;
-  Parser.Parse(Bytes, true);
+  Parser.parse(Bytes, support::little);
 
   return (Parser.hasAttribute(ExpectedTag) &&
     Parser.getAttributeValue(ExpectedTag) == ExpectedValue);