[lld] r240147 - [lld] Allow LLD passes to return error codes.

Lang Hames lhames at gmail.com
Fri Jun 19 10:51:46 PDT 2015


Author: lhames
Date: Fri Jun 19 12:51:46 2015
New Revision: 240147

URL: http://llvm.org/viewvc/llvm-project?rev=240147&view=rev
Log:
[lld] Allow LLD passes to return error codes.

Modified:
    lld/trunk/include/lld/Core/Pass.h
    lld/trunk/include/lld/Core/PassManager.h
    lld/trunk/lib/Driver/Driver.cpp
    lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/OrderPass.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h
    lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h

Modified: lld/trunk/include/lld/Core/Pass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Pass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Pass.h (original)
+++ lld/trunk/include/lld/Core/Pass.h Fri Jun 19 12:51:46 2015
@@ -34,7 +34,7 @@ public:
   virtual ~Pass() { }
 
   /// Do the actual work of the Pass.
-  virtual void perform(std::unique_ptr<SimpleFile> &mergedFile) = 0;
+  virtual std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) = 0;
 
 protected:
   // Only subclassess can be instantiated.

Modified: lld/trunk/include/lld/Core/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/PassManager.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/PassManager.h (original)
+++ lld/trunk/include/lld/Core/PassManager.h Fri Jun 19 12:51:46 2015
@@ -33,7 +33,8 @@ public:
 
   std::error_code runOnFile(std::unique_ptr<SimpleFile> &file) {
     for (std::unique_ptr<Pass> &pass : _passes)
-      pass->perform(file);
+      if (std::error_code EC = pass->perform(file))
+        return EC;
     return std::error_code();
   }
 

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Fri Jun 19 12:51:46 2015
@@ -117,7 +117,12 @@ bool Driver::link(LinkingContext &ctx, r
   ScopedTask passTask(getDefaultDomain(), "Passes");
   PassManager pm;
   ctx.addPasses(pm);
-  pm.runOnFile(merged);
+  if (std::error_code ec = pm.runOnFile(merged)) {
+    diagnostics << "Failed to write file '" << ctx.outputPath()
+                << "': " << ec.message() << "\n";
+    return false;
+  }
+
   passTask.end();
 
   // Give linked atoms to Writer to generate output file.

Modified: lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp Fri Jun 19 12:51:46 2015
@@ -22,9 +22,10 @@ namespace {
 class OrderPass : public Pass {
 public:
   /// Sorts atoms by position
-  void perform(std::unique_ptr<SimpleFile> &file) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override {
     SimpleFile::DefinedAtomRange defined = file->definedAtoms();
     std::sort(defined.begin(), defined.end(), DefinedAtom::compareByPosition);
+    return std::error_code();
   }
 };
 

Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp Fri Jun 19 12:51:46 2015
@@ -256,7 +256,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<SimpleFile> &mf) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mf) override {
     ScopedTask task(getDefaultDomain(), "AArch64 GOT/PLT Pass");
     DEBUG_WITH_TYPE(
         "AArch64", llvm::dbgs() << "Undefined Atoms"
@@ -315,6 +315,8 @@ public:
       obj->setOrdinal(ordinal++);
       mf->addAtom(*obj);
     }
+
+    return std::error_code();
   }
 
 protected:

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Fri Jun 19 12:51:46 2015
@@ -673,7 +673,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<SimpleFile> &mf) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mf) override {
     ScopedTask task(getDefaultDomain(), "ARM GOT/PLT Pass");
     DEBUG_WITH_TYPE(
         "ARM", llvm::dbgs() << "Undefined Atoms" << "\n";
@@ -759,6 +759,8 @@ public:
       v->setOrdinal(ordinal++);
       mf->addAtom(*v);
     }
+
+    return std::error_code();
   }
 
 protected:

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Fri Jun 19 12:51:46 2015
@@ -169,7 +169,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<SimpleFile> &mf) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mf) override {
     // Process all references.
     for (const auto &atom : mf->defined())
       for (const auto &ref : *atom)
@@ -197,6 +197,8 @@ public:
       got->setOrdinal(ordinal++);
       mf->addAtom(*got);
     }
+
+    return std::error_code();
   }
 
 protected:

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.cpp Fri Jun 19 12:51:46 2015
@@ -49,7 +49,7 @@ static int32_t getSectionPriority(String
   return priority;
 }
 
-void MipsCtorsOrderPass::perform(std::unique_ptr<SimpleFile> &f) {
+std::error_code MipsCtorsOrderPass::perform(std::unique_ptr<SimpleFile> &f) {
   auto definedAtoms = f->definedAtoms();
 
   auto last = std::stable_partition(definedAtoms.begin(), definedAtoms.end(),
@@ -71,4 +71,6 @@ void MipsCtorsOrderPass::perform(std::un
 
     return leftPriority < rightPriority;
   });
+
+  return std::error_code();
 }

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsCtorsOrderPass.h Fri Jun 19 12:51:46 2015
@@ -17,7 +17,7 @@ namespace elf {
 /// \brief This pass sorts atoms in .{ctors,dtors}.<priority> sections.
 class MipsCtorsOrderPass : public Pass {
 public:
-  void perform(std::unique_ptr<SimpleFile> &mergedFile) override;
+  std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) override;
 };
 }
 }

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Fri Jun 19 12:51:46 2015
@@ -302,7 +302,7 @@ template <typename ELFT> class Relocatio
 public:
   RelocationPass(MipsLinkingContext &ctx);
 
-  void perform(std::unique_ptr<SimpleFile> &mf) override;
+  std::error_code perform(std::unique_ptr<SimpleFile> &mf) override;
 
 private:
   /// \brief Reference to the linking context.
@@ -428,7 +428,7 @@ RelocationPass<ELFT>::RelocationPass(Mip
 }
 
 template <typename ELFT>
-void RelocationPass<ELFT>::perform(std::unique_ptr<SimpleFile> &mf) {
+std::error_code RelocationPass<ELFT>::perform(std::unique_ptr<SimpleFile> &mf) {
   for (const auto &atom : mf->defined())
     for (const auto &ref : *atom)
       collectReferenceInfo(*cast<MipsELFDefinedAtom<ELFT>>(atom),
@@ -518,6 +518,8 @@ void RelocationPass<ELFT>::perform(std::
     la25->setOrdinal(ordinal++);
     mf->addAtom(*la25);
   }
+
+  return std::error_code();
 }
 
 template <typename ELFT>

Modified: lld/trunk/lib/ReaderWriter/ELF/OrderPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OrderPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OrderPass.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OrderPass.h Fri Jun 19 12:51:46 2015
@@ -19,9 +19,10 @@ namespace elf {
 /// \brief This pass sorts atoms by file and atom ordinals.
 class OrderPass : public Pass {
 public:
-  void perform(std::unique_ptr<SimpleFile> &file) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override {
     parallel_sort(file->definedAtoms().begin(), file->definedAtoms().end(),
                   DefinedAtom::compareByPosition);
+    return std::error_code();
   }
 };
 }

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp Fri Jun 19 12:51:46 2015
@@ -254,7 +254,7 @@ public:
   ///
   /// After all references are handled, the atoms created during that are all
   /// added to mf.
-  void perform(std::unique_ptr<SimpleFile> &mf) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mf) override {
     ScopedTask task(getDefaultDomain(), "X86-64 GOT/PLT Pass");
     // Process all references.
     for (const auto &atom : mf->defined())
@@ -293,6 +293,7 @@ public:
       obj->setOrdinal(ordinal++);
       mf->addAtom(*obj);
     }
+    return std::error_code();
   }
 
 protected:

Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Fri Jun 19 12:51:46 2015
@@ -277,7 +277,7 @@ public:
         _isBig(MachOLinkingContext::isBigEndian(_ctx.arch())) {}
 
 private:
-  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     DEBUG(llvm::dbgs() << "MachO Compact Unwind pass\n");
 
     std::map<const Atom *, CompactUnwindEntry> unwindLocs;
@@ -294,7 +294,7 @@ private:
 
     // Skip rest of pass if no unwind info.
     if (unwindLocs.empty() && dwarfFrames.empty())
-      return;
+      return std::error_code();
 
     // FIXME: if there are more than 4 personality functions then we need to
     // defer to DWARF info for the ones we don't put in the list. They should
@@ -348,6 +348,8 @@ private:
     mergedFile->removeDefinedAtomsIf([](const DefinedAtom *atom) {
       return atom->contentType() == DefinedAtom::typeCompactUnwindInfo;
     });
+
+    return std::error_code();
   }
 
   void collectCompactUnwindEntries(

Modified: lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp Fri Jun 19 12:51:46 2015
@@ -96,7 +96,7 @@ public:
         _file("<mach-o GOT Pass>") {}
 
 private:
-  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     // Scan all references in all atoms.
     for (const DefinedAtom *atom : mergedFile->defined()) {
       for (const Reference *ref : *atom) {
@@ -131,6 +131,8 @@ private:
     });
     for (const GOTEntryAtom *slot : entries)
       mergedFile->addAtom(*slot);
+
+    return std::error_code();
   }
 
   bool shouldReplaceTargetWithGOTAtom(const Atom *target, bool canBypassGOT) {

Modified: lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp Fri Jun 19 12:51:46 2015
@@ -437,7 +437,7 @@ void LayoutPass::undecorate(SimpleFile::
 }
 
 /// Perform the actual pass
-void LayoutPass::perform(std::unique_ptr<SimpleFile> &mergedFile) {
+std::error_code LayoutPass::perform(std::unique_ptr<SimpleFile> &mergedFile) {
   // sort the atoms
   ScopedTask task(getDefaultDomain(), "LayoutPass");
   SimpleFile::DefinedAtomRange atomRange = mergedFile->definedAtoms();
@@ -468,6 +468,8 @@ void LayoutPass::perform(std::unique_ptr
     llvm::dbgs() << "sorted atoms:\n";
     printDefinedAtoms(atomRange);
   });
+
+  return std::error_code();
 }
 
 void addLayoutPass(PassManager &pm, const MachOLinkingContext &ctx) {

Modified: lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/LayoutPass.h Fri Jun 19 12:51:46 2015
@@ -46,7 +46,7 @@ public:
   LayoutPass(const Registry &registry, SortOverride sorter);
 
   /// Sorts atoms in mergedFile by content type then by command line order.
-  void perform(std::unique_ptr<SimpleFile> &mergedFile) override;
+  std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) override;
 
   virtual ~LayoutPass() {}
 

Modified: lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp Fri Jun 19 12:51:46 2015
@@ -44,7 +44,7 @@ public:
       : _ctx(context), _archHandler(_ctx.archHandler()),
         _stubInfo(_archHandler.stubInfo()), _file("<mach-o shim pass>") {}
 
-  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     // Scan all references in all atoms.
     for (const DefinedAtom *atom : mergedFile->defined()) {
       for (const Reference *ref : *atom) {
@@ -63,7 +63,7 @@ public:
     }
     // Exit early if no shims needed.
     if (_targetToShim.empty())
-      return;
+      return std::error_code();
 
     // Sort shim atoms so the layout order is stable.
     std::vector<const DefinedAtom *> shims;
@@ -80,6 +80,8 @@ public:
     for (const DefinedAtom *shim : shims) {
       mergedFile->addAtom(*shim);
     }
+
+    return std::error_code();
   }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp Fri Jun 19 12:51:46 2015
@@ -209,10 +209,10 @@ public:
       : _ctx(context), _archHandler(_ctx.archHandler()),
         _stubInfo(_archHandler.stubInfo()), _file("<mach-o Stubs pass>") {}
 
-  void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &mergedFile) override {
     // Skip this pass if output format uses text relocations instead of stubs.
     if (!this->noTextRelocs())
-      return;
+      return std::error_code();
 
     // Scan all references in all atoms.
     for (const DefinedAtom *atom : mergedFile->defined()) {
@@ -239,7 +239,7 @@ public:
 
     // Exit early if no stubs needed.
     if (_targetToUses.empty())
-      return;
+      return std::error_code();
 
     // First add help-common and GOT slots used by lazy binding.
     SimpleDefinedAtom *helperCommonAtom =
@@ -314,6 +314,8 @@ public:
       // Calculate new offset
       lazyOffset += target->name().size() + 12;
     }
+
+    return std::error_code();
   }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp Fri Jun 19 12:51:46 2015
@@ -175,15 +175,15 @@ EdataPass::createOrdinalTable(const std:
   return ret;
 }
 
-void EdataPass::perform(std::unique_ptr<SimpleFile> &file) {
+std::error_code EdataPass::perform(std::unique_ptr<SimpleFile> &file) {
   dedupExports(_ctx);
   assignOrdinals(_ctx);
 
   std::vector<TableEntry> entries;
   if (!getExportedAtoms(_ctx, file.get(), entries))
-    return;
+    return std::error_code();
   if (entries.empty())
-    return;
+    return std::error_code();
 
   int ordinalBase, maxOrdinal;
   std::tie(ordinalBase, maxOrdinal) = getOrdinalBase(entries);
@@ -221,6 +221,8 @@ void EdataPass::perform(std::unique_ptr<
   file->addAtom(*ordinalTable);
   addDir32NBReloc(table, ordinalTable, _ctx.getMachineType(),
                   offsetof(export_directory_table_entry, OrdinalTableRVA));
+
+  return std::error_code();
 }
 
 } // namespace pecoff

Modified: lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h Fri Jun 19 12:51:46 2015
@@ -66,7 +66,7 @@ public:
   EdataPass(PECOFFLinkingContext &ctx)
       : _ctx(ctx), _file(ctx), _is64(ctx.is64Bit()), _stringOrdinal(1024) {}
 
-  void perform(std::unique_ptr<SimpleFile> &file) override;
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override;
 
 private:
   edata::EdataAtom *

Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp Fri Jun 19 12:51:46 2015
@@ -287,9 +287,9 @@ DelayLoaderAtom::createContent(MachineTy
 
 } // namespace idata
 
-void IdataPass::perform(std::unique_ptr<SimpleFile> &file) {
+std::error_code IdataPass::perform(std::unique_ptr<SimpleFile> &file) {
   if (file->sharedLibrary().empty())
-    return;
+    return std::error_code();
 
   idata::IdataContext context(*file, _dummyFile, _ctx);
   std::map<StringRef, std::vector<COFFSharedLibraryAtom *>> sharedAtoms =
@@ -322,6 +322,8 @@ void IdataPass::perform(std::unique_ptr<
     new (_alloc) idata::DelayNullImportDirectoryAtom(context);
 
   replaceSharedLibraryAtoms(*file);
+
+  return std::error_code();
 }
 
 std::map<StringRef, std::vector<COFFSharedLibraryAtom *>>

Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h Fri Jun 19 12:51:46 2015
@@ -195,7 +195,7 @@ class IdataPass : public lld::Pass {
 public:
   IdataPass(const PECOFFLinkingContext &ctx) : _dummyFile(ctx), _ctx(ctx) {}
 
-  void perform(std::unique_ptr<SimpleFile> &file) override;
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override;
 
 private:
   std::map<StringRef, std::vector<COFFSharedLibraryAtom *>>

Modified: lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/InferSubsystemPass.h Fri Jun 19 12:51:46 2015
@@ -22,13 +22,13 @@ class InferSubsystemPass : public lld::P
 public:
   InferSubsystemPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
 
-  void perform(std::unique_ptr<SimpleFile> &file) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override {
     if (_ctx.getSubsystem() != WindowsSubsystem::IMAGE_SUBSYSTEM_UNKNOWN)
-      return;
+      return std::error_code();
 
     if (_ctx.isDll()) {
       _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI);
-      return;
+      return std::error_code();
     }
 
     // Scan the resolved symbols to infer the subsystem.
@@ -45,15 +45,17 @@ public:
       if (atom->name() == wWinMain || atom->name().startswith(wWinMainAt) ||
           atom->name() == winMain || atom->name().startswith(winMainAt)) {
         _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI);
-        return;
+        return std::error_code();
       }
       if (atom->name() == wmain || atom->name().startswith(wmainAt) ||
           atom->name() == main || atom->name().startswith(mainAt)) {
         _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI);
-        return;
+        return std::error_code();
       }
     }
     llvm::report_fatal_error("Failed to infer subsystem");
+
+    return std::error_code();
   }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.cpp Fri Jun 19 12:51:46 2015
@@ -49,9 +49,9 @@ LoadConfigAtom::LoadConfigAtom(VirtualFi
 
 } // namespace loadcfg
 
-void LoadConfigPass::perform(std::unique_ptr<SimpleFile> &file) {
+std::error_code LoadConfigPass::perform(std::unique_ptr<SimpleFile> &file) {
   if (_ctx.noSEH())
-    return;
+    return std::error_code();
 
   // Find the first atom in .sxdata section.
   const DefinedAtom *sxdata = nullptr;
@@ -64,11 +64,13 @@ void LoadConfigPass::perform(std::unique
     }
   }
   if (!sxdata)
-    return;
+    return std::error_code();
 
   auto *loadcfg = new (_alloc)
       loadcfg::LoadConfigAtom(_file, sxdata, sectionSize / sizeof(uint32_t));
   file->addAtom(*loadcfg);
+
+  return std::error_code();
 }
 
 } // namespace pecoff

Modified: lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h Fri Jun 19 12:51:46 2015
@@ -49,7 +49,7 @@ class LoadConfigPass : public lld::Pass
 public:
   LoadConfigPass(PECOFFLinkingContext &ctx) : _ctx(ctx), _file(ctx) {}
 
-  void perform(std::unique_ptr<SimpleFile> &file) override;
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override;
 
 private:
   PECOFFLinkingContext &_ctx;

Modified: lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/OrderPass.h Fri Jun 19 12:51:46 2015
@@ -55,9 +55,10 @@ static bool compare(const DefinedAtom *l
 
 class OrderPass : public lld::Pass {
 public:
-  void perform(std::unique_ptr<SimpleFile> &file) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override {
     SimpleFile::DefinedAtomRange defined = file->definedAtoms();
     parallel_sort(defined.begin(), defined.end(), compare);
+    return std::error_code();
   }
 };
 

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h?rev=240147&r1=240146&r2=240147&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h Fri Jun 19 12:51:46 2015
@@ -21,9 +21,10 @@ class PDBPass : public lld::Pass {
 public:
   PDBPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
 
-  void perform(std::unique_ptr<SimpleFile> &file) override {
+  std::error_code perform(std::unique_ptr<SimpleFile> &file) override {
     if (_ctx.getDebug())
       touch(_ctx.getPDBFilePath());
+    return std::error_code();
   }
 
 private:





More information about the llvm-commits mailing list