]> granicus.if.org Git - llvm/commitdiff
[llvm-readobj] - Remove `error(llvm::Expected<T> &&E)`
authorGeorge Rimar <grimar@accesssoftek.com>
Fri, 9 Aug 2019 11:03:21 +0000 (11:03 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Fri, 9 Aug 2019 11:03:21 +0000 (11:03 +0000)
This is a bit strange method. It works like a unwrapOrError,
but named error. It does not report an Input name.
I removed it.

Differential revision: https://reviews.llvm.org/D66000

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368430 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-readobj/COFFDumper.cpp
tools/llvm-readobj/WasmDumper.cpp
tools/llvm-readobj/llvm-readobj.h

index 9b949f1c83cb9b2a806c151ed940c3121f5cf68e..2ee4d52df3231df501945879edf546f93c9680a3 100644 (file)
@@ -1048,7 +1048,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
       // To find the active frame description, search this array for the
       // smallest PC range that includes the current PC.
       for (const auto &FD : FrameData) {
-        StringRef FrameFunc = error(CVStringTable.getString(FD.FrameFunc));
+        StringRef FrameFunc = unwrapOrError(
+            Obj->getFileName(), CVStringTable.getString(FD.FrameFunc));
 
         DictScope S(W, "FrameData");
         W.printHex("RvaStart", FD.RvaStart);
@@ -1169,7 +1170,8 @@ void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
   for (auto &FC : Checksums) {
     DictScope S(W, "FileChecksum");
 
-    StringRef Filename = error(CVStringTable.getString(FC.FileNameOffset));
+    StringRef Filename = unwrapOrError(
+        Obj->getFileName(), CVStringTable.getString(FC.FileNameOffset));
     W.printHex("Filename", Filename, FC.FileNameOffset);
     W.printHex("ChecksumSize", FC.Checksum.size());
     W.printEnum("ChecksumKind", uint8_t(FC.Kind),
@@ -1211,7 +1213,8 @@ StringRef COFFDumper::getFileNameForFileOffset(uint32_t FileOffset) {
   if (Iter == CVFileChecksumTable.end())
     error(object_error::parse_failed);
 
-  return error(CVStringTable.getString(Iter->FileNameOffset));
+  return unwrapOrError(Obj->getFileName(),
+                       CVStringTable.getString(Iter->FileNameOffset));
 }
 
 void COFFDumper::printFileNameForOffset(StringRef Label, uint32_t FileOffset) {
index 041a9a15bdb64410ec5128f70d90868ffc89ca16..2ffc74b3398fb6ba62bc20f1c9180c342b05ffc8 100644 (file)
@@ -90,7 +90,7 @@ void WasmDumper::printRelocation(const SectionRef &Section,
   StringRef SymName;
   symbol_iterator SI = Reloc.getSymbol();
   if (SI != Obj->symbol_end())
-    SymName = error(SI->getName());
+    SymName = unwrapOrError(Obj->getFileName(), SI->getName());
 
   bool HasAddend = false;
   switch (RelocType) {
index 4cdb01da152c0851afbcceba64465591b169a3c1..d7fbb0e4d2585ff7385d7d8b7e532be000053cc3 100644 (file)
@@ -28,10 +28,6 @@ namespace llvm {
   void warn(llvm::Error Err);
   void error(std::error_code EC);
   void error(llvm::Error EC);
-  template <typename T> T error(llvm::Expected<T> &&E) {
-    error(E.takeError());
-    return std::move(*E);
-  }
 
   template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) {
     if (EO)