[lld] r194028 - Replace ErrorOr<void> with error_code.

Rafael Espindola rafael.espindola at gmail.com
Mon Nov 4 16:09:37 PST 2013


Author: rafael
Date: Mon Nov  4 18:09:36 2013
New Revision: 194028

URL: http://llvm.org/viewvc/llvm-project?rev=194028&view=rev
Log:
Replace ErrorOr<void> with error_code.

It was never transporting any value in addition to the error_code.

Modified:
    lld/trunk/include/lld/Core/PassManager.h
    lld/trunk/include/lld/Driver/InputGraph.h
    lld/trunk/lib/Core/PassManager.cpp
    lld/trunk/lib/Driver/InputGraph.cpp
    lld/trunk/lib/ReaderWriter/ELF/File.h
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h
    lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h
    lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp

Modified: lld/trunk/include/lld/Core/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/PassManager.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/PassManager.h (original)
+++ lld/trunk/include/lld/Core/PassManager.h Mon Nov  4 18:09:36 2013
@@ -32,7 +32,7 @@ public:
     _passes.push_back(std::move(pass));
   }
 
-  ErrorOr<void> runOnFile(std::unique_ptr<MutableFile> &);
+  error_code runOnFile(std::unique_ptr<MutableFile> &);
 
 private:
   /// \brief Passes in the order they should run.

Modified: lld/trunk/include/lld/Driver/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/InputGraph.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/InputGraph.h (original)
+++ lld/trunk/include/lld/Driver/InputGraph.h Mon Nov  4 18:09:36 2013
@@ -105,11 +105,11 @@ public:
   virtual ErrorOr<InputElement *> getNextInputElement();
 
   /// \brief Set the index on what inputElement has to be returned
-  virtual ErrorOr<void> setNextElementIndex(uint32_t index = 0);
+  virtual error_code setNextElementIndex(uint32_t index = 0);
 
   /// \brief Reset the inputGraph for the inputGraph to start processing
   /// files from the beginning
-  virtual ErrorOr<void> reset() { return setNextElementIndex(0); }
+  virtual error_code reset() { return setNextElementIndex(0); }
 
 protected:
   // Input arguments

Modified: lld/trunk/lib/Core/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/PassManager.cpp?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/Core/PassManager.cpp (original)
+++ lld/trunk/lib/Core/PassManager.cpp Mon Nov  4 18:09:36 2013
@@ -15,7 +15,7 @@
 #include "llvm/Support/ErrorOr.h"
 
 namespace lld {
-ErrorOr<void> PassManager::runOnFile(std::unique_ptr<MutableFile> &mf) {
+error_code PassManager::runOnFile(std::unique_ptr<MutableFile> &mf) {
   for (auto &pass : _passes) {
     pass->perform(mf);
   }

Modified: lld/trunk/lib/Driver/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/InputGraph.cpp?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/Driver/InputGraph.cpp (original)
+++ lld/trunk/lib/Driver/InputGraph.cpp Mon Nov  4 18:09:36 2013
@@ -77,7 +77,7 @@ ErrorOr<InputElement *> InputGraph::getN
 }
 
 /// \brief Set the index on what inputElement has to be returned
-ErrorOr<void> InputGraph::setNextElementIndex(uint32_t index) {
+error_code InputGraph::setNextElementIndex(uint32_t index) {
   if (index > _inputArgs.size())
     return make_error_code(llvm::errc::invalid_argument);
   _nextElementIndex = index;

Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Mon Nov  4 18:09:36 2013
@@ -134,27 +134,27 @@ public:
 
     // Read input sections from the input file that need to be converted to
     // atoms
-    if (auto err = createAtomizableSections()) ; else {
+    if (auto err = createAtomizableSections()) {
       EC = err;
       return;
     }
 
     // For mergeable strings, we would need to split the section into various
     // atoms
-    if (auto err = createMergeableAtoms()) ; else {
+    if (auto err = createMergeableAtoms()) {
       EC = err;
       return;
     }
 
     // Create the necessary symbols that are part of the section that we
     // created in createAtomizableSections function
-    if (auto err = createSymbolsFromAtomizableSections()) ; else {
+    if (auto err = createSymbolsFromAtomizableSections()) {
       EC = err;
       return;
     }
 
     // Create the appropriate atoms from the file
-    if (auto err = createAtoms()) ; else {
+    if (auto err = createAtoms()) {
       EC = err;
       return;
     }
@@ -162,7 +162,7 @@ public:
 
   /// \brief Read input sections and populate necessary data structures
   /// to read them later and create atoms
-  ErrorOr<void> createAtomizableSections() {
+  error_code createAtomizableSections() {
     // Handle: SHT_REL and SHT_RELA sections:
     // Increment over the sections, when REL/RELA section types are found add
     // the contents to the RelocationReferences map.
@@ -220,7 +220,7 @@ public:
 
   /// \brief Create mergeable atoms from sections that have the merge attribute
   /// set
-  ErrorOr<void> createMergeableAtoms() {
+  error_code createMergeableAtoms() {
     // Divide the section that contains mergeable strings into tokens
     // TODO
     // a) add resolver support to recognize multibyte chars
@@ -268,7 +268,7 @@ public:
   /// \brief Add the symbols that the sections contain. The symbols will be
   /// converted to atoms for
   /// Undefined symbols, absolute symbols
-  ErrorOr<void> createSymbolsFromAtomizableSections() {
+  error_code createSymbolsFromAtomizableSections() {
     // Increment over all the symbols collecting atoms and symbol names for
     // later use.
     auto SymI = _objFile->begin_symbols(),
@@ -327,7 +327,7 @@ public:
   }
 
   /// \brief Create individual atoms
-  ErrorOr<void> createAtoms() {
+  error_code createAtoms() {
     for (auto &i : _sectionSymbols) {
       const Elf_Shdr *section = i.first;
       std::vector<Elf_Sym_Iter> &symbols = i.second;

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp Mon Nov  4 18:09:36 2013
@@ -213,7 +213,7 @@ int relocHexGOTREL_32(uint8_t *location,
 
 } // end anon namespace
 
-ErrorOr<void> HexagonTargetRelocationHandler::applyRelocation(
+error_code HexagonTargetRelocationHandler::applyRelocation(
     ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
     const Reference &ref) const {
   uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h Mon Nov  4 18:09:36 2013
@@ -28,7 +28,7 @@ public:
       const HexagonTargetLayout<HexagonELFType> &layout)
       : _context(context), _targetHandler(tH), _targetLayout(layout) {}
 
-  virtual ErrorOr<void>
+  virtual error_code
   applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
                   const lld::AtomLayout &, const Reference &) const;
 private:

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=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Mon Nov  4 18:09:36 2013
@@ -278,13 +278,13 @@ public:
     return ga;
   }
 
-  ErrorOr<void> handleGOTREL(const Reference &ref) {
+  error_code handleGOTREL(const Reference &ref) {
     // Turn this so that the target is set to the GOT entry
     const_cast<Reference &>(ref).setTarget(getGOTEntry(ref.target()));
     return error_code::success();
   }
 
-  ErrorOr<void> handlePLT32(const Reference &ref) {
+  error_code handlePLT32(const Reference &ref) {
     // Turn this into a PC32 to the PLT entry.
     const_cast<Reference &>(ref).setKind(R_HEX_B22_PCREL);
     const_cast<Reference &>(ref).setTarget(getPLTEntry(ref.target()));

Modified: lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp Mon Nov  4 18:09:36 2013
@@ -35,7 +35,7 @@ int relocB24PCREL(uint8_t *location, uin
 }
 } // end anon namespace
 
-ErrorOr<void> PPCTargetRelocationHandler::applyRelocation(
+error_code PPCTargetRelocationHandler::applyRelocation(
     ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
     const Reference &ref) const {
   uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;

Modified: lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h Mon Nov  4 18:09:36 2013
@@ -24,9 +24,9 @@ public:
   PPCTargetRelocationHandler(const PPCLinkingContext &context)
       : _context(context) {}
 
-  virtual ErrorOr<void> applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
-                                        const lld::AtomLayout &,
-                                        const Reference &)const;
+  virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
+                                     const lld::AtomLayout &,
+                                     const Reference &) const;
 
 private:
   const PPCLinkingContext &_context;

Modified: lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h Mon Nov  4 18:09:36 2013
@@ -69,7 +69,7 @@ public:
 
 template <class ELFT> class TargetRelocationHandler {
 public:
-  virtual ErrorOr<void>
+  virtual error_code
   applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
                   const lld::AtomLayout &, const Reference &) const = 0;
 

Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp Mon Nov  4 18:09:36 2013
@@ -33,7 +33,7 @@ int relocPC32(uint8_t *location, uint64_
 }
 } // end anon namespace
 
-ErrorOr<void> X86TargetRelocationHandler::applyRelocation(
+error_code X86TargetRelocationHandler::applyRelocation(
     ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
     const Reference &ref) const {
   uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;

Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h Mon Nov  4 18:09:36 2013
@@ -24,9 +24,9 @@ public:
   X86TargetRelocationHandler(const X86LinkingContext &context)
       : _context(context) {}
 
-  virtual ErrorOr<void> applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
-                                        const lld::AtomLayout &,
-                                        const Reference &)const;
+  virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
+                                     const lld::AtomLayout &,
+                                     const Reference &) const;
 
 private:
   const X86LinkingContext &_context;

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp Mon Nov  4 18:09:36 2013
@@ -59,7 +59,7 @@ int64_t X86_64TargetRelocationHandler::r
   return 0;
 }
 
-ErrorOr<void> X86_64TargetRelocationHandler::applyRelocation(
+error_code X86_64TargetRelocationHandler::applyRelocation(
     ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
     const Reference &ref) const {
   uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h?rev=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h Mon Nov  4 18:09:36 2013
@@ -24,9 +24,9 @@ public:
   X86_64TargetRelocationHandler(const X86_64LinkingContext &context)
       : _tlsSize(0), _context(context) {}
 
-  virtual ErrorOr<void> applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
-                                        const lld::AtomLayout &,
-                                        const Reference &) const;
+  virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
+                                     const lld::AtomLayout &,
+                                     const Reference &) const;
 
   virtual int64_t relocAddend(const Reference &) const;
 

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=194028&r1=194027&r2=194028&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp Mon Nov  4 18:09:36 2013
@@ -146,7 +146,7 @@ protected:
   ///
   /// This create a PLT and GOT entry for the IFUNC if one does not exist. The
   /// GOT entry and a IRELATIVE relocation to the original target resolver.
-  ErrorOr<void> handleIFUNC(const Reference &ref) {
+  error_code handleIFUNC(const Reference &ref) {
     auto target = dyn_cast_or_null<const DefinedAtom>(ref.target());
     if (target && target->contentType() == DefinedAtom::typeResolver)
       const_cast<Reference &>(ref).setTarget(getIFUNCPLTEntry(target));
@@ -297,9 +297,9 @@ public:
   StaticRelocationPass(const elf::X86_64LinkingContext &ctx)
       : RelocationPass(ctx) {}
 
-  ErrorOr<void> handlePlain(const Reference &ref) { return handleIFUNC(ref); }
+  error_code handlePlain(const Reference &ref) { return handleIFUNC(ref); }
 
-  ErrorOr<void> handlePLT32(const Reference &ref) {
+  error_code handlePLT32(const Reference &ref) {
     // __tls_get_addr is handled elsewhere.
     if (ref.target() && ref.target()->name() == "__tls_get_addr") {
       const_cast<Reference &>(ref).setKind(R_X86_64_NONE);
@@ -315,7 +315,7 @@ public:
     return error_code::success();
   }
 
-  ErrorOr<void> handleGOT(const Reference &ref) {
+  error_code handleGOT(const Reference &ref) {
     if (isa<UndefinedAtom>(ref.target()))
       const_cast<Reference &>(ref).setTarget(getNullGOT());
     else if (const DefinedAtom *da = dyn_cast<const DefinedAtom>(ref.target()))
@@ -390,7 +390,7 @@ public:
     return oa;
   }
 
-  ErrorOr<void> handlePlain(const Reference &ref) {
+  error_code handlePlain(const Reference &ref) {
     if (!ref.target())
       return error_code::success();
     if (auto sla = dyn_cast<SharedLibraryAtom>(ref.target())) {
@@ -403,7 +403,7 @@ public:
     return error_code::success();
   }
 
-  ErrorOr<void> handlePLT32(const Reference &ref) {
+  error_code handlePLT32(const Reference &ref) {
     // Turn this into a PC32 to the PLT entry.
     const_cast<Reference &>(ref).setKind(R_X86_64_PC32);
     // Handle IFUNC.
@@ -432,7 +432,7 @@ public:
     return got->second;
   }
 
-  ErrorOr<void> handleGOT(const Reference &ref) {
+  error_code handleGOT(const Reference &ref) {
     if (isa<UndefinedAtom>(ref.target()))
       const_cast<Reference &>(ref).setTarget(getNullGOT());
     else if (const DefinedAtom *da = dyn_cast<const DefinedAtom>(ref.target()))





More information about the llvm-commits mailing list