[WebAssembly] Use tabs instead of spaces in assembly output.
[oota-llvm.git] / tools / llvm-readobj / Win64EHDumper.cpp
index f058632a8ce89e4310fa8321a3cd7d53cc9e193e..2da5ae3200fde841b46be0cdcdaf6c2d18e016d4 100644 (file)
@@ -118,19 +118,19 @@ static std::string formatSymbol(const Dumper::Context &Ctx,
   std::string Buffer;
   raw_string_ostream OS(Buffer);
 
-  StringRef Name;
   SymbolRef Symbol;
-  if (Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData) ||
-      Symbol.getName(Name)) {
-    OS << format(" (0x%" PRIX64 ")", Offset);
-    return OS.str();
+  if (!Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData)) {
+    if (ErrorOr<StringRef> Name = Symbol.getName()) {
+      OS << *Name;
+      if (Displacement > 0)
+        OS << format(" +0x%X (0x%" PRIX64 ")", Displacement, Offset);
+      else
+        OS << format(" (0x%" PRIX64 ")", Offset);
+      return OS.str();
+    }
   }
 
-  OS << Name;
-  if (Displacement > 0)
-    OS << format(" +0x%X (0x%" PRIX64 ")", Displacement, Offset);
-  else
-    OS << format(" (0x%" PRIX64 ")", Offset);
+  OS << format(" (0x%" PRIX64 ")", Offset);
   return OS.str();
 }
 
@@ -144,15 +144,14 @@ static std::error_code resolveRelocation(const Dumper::Context &Ctx,
           Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData))
     return EC;
 
-  if (std::error_code EC = Symbol.getAddress(ResolvedAddress))
-    return EC;
-
-  section_iterator SI = Ctx.COFF.section_begin();
-  if (std::error_code EC = Symbol.getSection(SI))
+  ErrorOr<uint64_t> ResolvedAddressOrErr = Symbol.getAddress();
+  if (std::error_code EC = ResolvedAddressOrErr.getError())
     return EC;
+  ResolvedAddress = *ResolvedAddressOrErr;
 
-  ResolvedSection = Ctx.COFF.getCOFFSection(*SI);
-  return object_error::success;
+  ErrorOr<section_iterator> SI = Symbol.getSection();
+  ResolvedSection = Ctx.COFF.getCOFFSection(**SI);
+  return std::error_code();
 }
 
 namespace llvm {
@@ -255,7 +254,7 @@ void Dumper::printUnwindInfo(const Context &Ctx, const coff_section *Section,
         return;
       }
 
-      printUnwindCode(UI, ArrayRef<UnwindCode>(UCI, UCE));
+      printUnwindCode(UI, makeArrayRef(UCI, UCE));
       UCI = UCI + UsedSlots - 1;
     }
   }
@@ -282,11 +281,11 @@ void Dumper::printRuntimeFunction(const Context &Ctx,
 
   const coff_section *XData;
   uint64_t Offset;
-  if (error(resolveRelocation(Ctx, Section, SectionOffset + 8, XData, Offset)))
-    return;
+  resolveRelocation(Ctx, Section, SectionOffset + 8, XData, Offset);
 
   ArrayRef<uint8_t> Contents;
-  if (error(Ctx.COFF.getSectionContents(XData, Contents)) || Contents.empty())
+  error(Ctx.COFF.getSectionContents(XData, Contents));
+  if (Contents.empty())
     return;
 
   Offset = Offset + RF.UnwindInfoOffset;
@@ -300,15 +299,15 @@ void Dumper::printRuntimeFunction(const Context &Ctx,
 void Dumper::printData(const Context &Ctx) {
   for (const auto &Section : Ctx.COFF.sections()) {
     StringRef Name;
-    if (error(Section.getName(Name)))
-      continue;
+    Section.getName(Name);
 
     if (Name != ".pdata" && !Name.startswith(".pdata$"))
       continue;
 
     const coff_section *PData = Ctx.COFF.getCOFFSection(Section);
     ArrayRef<uint8_t> Contents;
-    if (error(Ctx.COFF.getSectionContents(PData, Contents)) || Contents.empty())
+    error(Ctx.COFF.getSectionContents(PData, Contents));
+    if (Contents.empty())
       continue;
 
     const RuntimeFunction *Entries =