[RISCV] Consume error from parsing attributes section
authorJessica Clarke <jrtc27@jrtc27.com>
Fri, 10 Apr 2020 00:30:48 +0000 (01:30 +0100)
committerJessica Clarke <jrtc27@jrtc27.com>
Fri, 10 Apr 2020 14:05:53 +0000 (15:05 +0100)
Summary:
We don't consume the error from getBuildAttributes, so an assertions
build crashes with "Program aborted due to an unhandled Error:".
Explicitly consume it like the ARM version in that case.

Reviewers: asb, jhenderson, MaskRay, HsiangKai

Reviewed By: MaskRay

Subscribers: kristof.beyls, hiraditya, simoncook, kito-cheng, shiva0217, rogfer01, rkruppe, psnobl, benna, Jim, lenary, s.egerton, sameer.abuasal, luismarques, evandro, danielkiss, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77841

llvm/lib/Object/ELFObjectFile.cpp

index 8627d1b..c919d25 100644 (file)
@@ -297,8 +297,11 @@ SubtargetFeatures ELFObjectFileBase::getRISCVFeatures() const {
   // Add features according to the ELF attribute section.
   // If there are any unrecognized features, ignore them.
   RISCVAttributeParser Attributes;
-  if (Error E = getBuildAttributes(Attributes))
+  if (Error E = getBuildAttributes(Attributes)) {
+    // TODO Propagate Error.
+    consumeError(std::move(E));
     return Features; // Keep "c" feature if there is one in PlatformFlags.
+  }
 
   Optional<StringRef> Attr = Attributes.getAttributeString(RISCVAttrs::ARCH);
   if (Attr.hasValue()) {