From 75c2ae9664f457217a3173b5a059adaefea55723 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Nov 2013 00:09:36 +0000 Subject: [PATCH] Replace ErrorOr with error_code. It was never transporting any value in addition to the error_code. llvm-svn: 194028 --- lld/include/lld/Core/PassManager.h | 2 +- lld/include/lld/Driver/InputGraph.h | 4 ++-- lld/lib/Core/PassManager.cpp | 2 +- lld/lib/Driver/InputGraph.cpp | 2 +- lld/lib/ReaderWriter/ELF/File.h | 16 ++++++++-------- .../ELF/Hexagon/HexagonRelocationHandler.cpp | 2 +- .../ELF/Hexagon/HexagonRelocationHandler.h | 2 +- .../ELF/Hexagon/HexagonTargetHandler.cpp | 4 ++-- .../ReaderWriter/ELF/PPC/PPCTargetHandler.cpp | 2 +- lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h | 6 +++--- lld/lib/ReaderWriter/ELF/TargetHandler.h | 2 +- .../ReaderWriter/ELF/X86/X86TargetHandler.cpp | 2 +- lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h | 6 +++--- .../ELF/X86_64/X86_64RelocationHandler.cpp | 2 +- .../ELF/X86_64/X86_64RelocationHandler.h | 6 +++--- .../ELF/X86_64/X86_64RelocationPass.cpp | 14 +++++++------- 16 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lld/include/lld/Core/PassManager.h b/lld/include/lld/Core/PassManager.h index 2ed7a84db400..4bf3e4967eb4 100644 --- a/lld/include/lld/Core/PassManager.h +++ b/lld/include/lld/Core/PassManager.h @@ -32,7 +32,7 @@ public: _passes.push_back(std::move(pass)); } - ErrorOr runOnFile(std::unique_ptr &); + error_code runOnFile(std::unique_ptr &); private: /// \brief Passes in the order they should run. diff --git a/lld/include/lld/Driver/InputGraph.h b/lld/include/lld/Driver/InputGraph.h index c5c4b7e3fab5..a975a24f611c 100644 --- a/lld/include/lld/Driver/InputGraph.h +++ b/lld/include/lld/Driver/InputGraph.h @@ -105,11 +105,11 @@ public: virtual ErrorOr getNextInputElement(); /// \brief Set the index on what inputElement has to be returned - virtual ErrorOr 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 reset() { return setNextElementIndex(0); } + virtual error_code reset() { return setNextElementIndex(0); } protected: // Input arguments diff --git a/lld/lib/Core/PassManager.cpp b/lld/lib/Core/PassManager.cpp index 715a5fbda11e..a1dbe6ec85ca 100644 --- a/lld/lib/Core/PassManager.cpp +++ b/lld/lib/Core/PassManager.cpp @@ -15,7 +15,7 @@ #include "llvm/Support/ErrorOr.h" namespace lld { -ErrorOr PassManager::runOnFile(std::unique_ptr &mf) { +error_code PassManager::runOnFile(std::unique_ptr &mf) { for (auto &pass : _passes) { pass->perform(mf); } diff --git a/lld/lib/Driver/InputGraph.cpp b/lld/lib/Driver/InputGraph.cpp index abc85ce6931e..4d19fbc43acb 100644 --- a/lld/lib/Driver/InputGraph.cpp +++ b/lld/lib/Driver/InputGraph.cpp @@ -77,7 +77,7 @@ ErrorOr InputGraph::getNextInputElement() { } /// \brief Set the index on what inputElement has to be returned -ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/File.h b/lld/lib/ReaderWriter/ELF/File.h index 17994d7d8da7..85f324f1e256 100644 --- a/lld/lib/ReaderWriter/ELF/File.h +++ b/lld/lib/ReaderWriter/ELF/File.h @@ -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 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 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 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 createAtoms() { + error_code createAtoms() { for (auto &i : _sectionSymbols) { const Elf_Shdr *section = i.first; std::vector &symbols = i.second; diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp index ac7f18bfe9c0..3765aeba3b03 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp @@ -213,7 +213,7 @@ int relocHexGOTREL_32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A, } // end anon namespace -ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h index bf4f156fb32a..88653912088f 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h @@ -28,7 +28,7 @@ public: const HexagonTargetLayout &layout) : _context(context), _targetHandler(tH), _targetLayout(layout) {} - virtual ErrorOr + virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, const lld::AtomLayout &, const Reference &) const; private: diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp index 761471cb06a6..f3f90486ae31 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp @@ -278,13 +278,13 @@ public: return ga; } - ErrorOr handleGOTREL(const Reference &ref) { + error_code handleGOTREL(const Reference &ref) { // Turn this so that the target is set to the GOT entry const_cast(ref).setTarget(getGOTEntry(ref.target())); return error_code::success(); } - ErrorOr handlePLT32(const Reference &ref) { + error_code handlePLT32(const Reference &ref) { // Turn this into a PC32 to the PLT entry. const_cast(ref).setKind(R_HEX_B22_PCREL); const_cast(ref).setTarget(getPLTEntry(ref.target())); diff --git a/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp b/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp index 5b0b59bc026f..30d3ae1b50e2 100644 --- a/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp @@ -35,7 +35,7 @@ int relocB24PCREL(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) { } } // end anon namespace -ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h b/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h index 488e77ec0f22..c38193fa3c17 100644 --- a/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h @@ -24,9 +24,9 @@ public: PPCTargetRelocationHandler(const PPCLinkingContext &context) : _context(context) {} - virtual ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/TargetHandler.h b/lld/lib/ReaderWriter/ELF/TargetHandler.h index 475f8ce6b51a..90a7f295e2fb 100644 --- a/lld/lib/ReaderWriter/ELF/TargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/TargetHandler.h @@ -69,7 +69,7 @@ public: template class TargetRelocationHandler { public: - virtual ErrorOr + virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, const lld::AtomLayout &, const Reference &) const = 0; diff --git a/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp b/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp index b68a72c9aa81..648f41dabc70 100644 --- a/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp @@ -33,7 +33,7 @@ int relocPC32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) { } } // end anon namespace -ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h b/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h index 59ee1b725580..7dd432515f0e 100644 --- a/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h @@ -24,9 +24,9 @@ public: X86TargetRelocationHandler(const X86LinkingContext &context) : _context(context) {} - virtual ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp index b841851d1809..42a5a9951610 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp @@ -59,7 +59,7 @@ int64_t X86_64TargetRelocationHandler::relocAddend(const Reference &ref) const { return 0; } -ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h index f11e6ce27df0..64665fce4e0d 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.h @@ -24,9 +24,9 @@ public: X86_64TargetRelocationHandler(const X86_64LinkingContext &context) : _tlsSize(0), _context(context) {} - virtual ErrorOr 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; diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp index 3ce6b0873e3b..92bbcaf54f41 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp @@ -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 handleIFUNC(const Reference &ref) { + error_code handleIFUNC(const Reference &ref) { auto target = dyn_cast_or_null(ref.target()); if (target && target->contentType() == DefinedAtom::typeResolver) const_cast(ref).setTarget(getIFUNCPLTEntry(target)); @@ -297,9 +297,9 @@ public: StaticRelocationPass(const elf::X86_64LinkingContext &ctx) : RelocationPass(ctx) {} - ErrorOr handlePlain(const Reference &ref) { return handleIFUNC(ref); } + error_code handlePlain(const Reference &ref) { return handleIFUNC(ref); } - ErrorOr 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(ref).setKind(R_X86_64_NONE); @@ -315,7 +315,7 @@ public: return error_code::success(); } - ErrorOr handleGOT(const Reference &ref) { + error_code handleGOT(const Reference &ref) { if (isa(ref.target())) const_cast(ref).setTarget(getNullGOT()); else if (const DefinedAtom *da = dyn_cast(ref.target())) @@ -390,7 +390,7 @@ public: return oa; } - ErrorOr handlePlain(const Reference &ref) { + error_code handlePlain(const Reference &ref) { if (!ref.target()) return error_code::success(); if (auto sla = dyn_cast(ref.target())) { @@ -403,7 +403,7 @@ public: return error_code::success(); } - ErrorOr handlePLT32(const Reference &ref) { + error_code handlePLT32(const Reference &ref) { // Turn this into a PC32 to the PLT entry. const_cast(ref).setKind(R_X86_64_PC32); // Handle IFUNC. @@ -432,7 +432,7 @@ public: return got->second; } - ErrorOr handleGOT(const Reference &ref) { + error_code handleGOT(const Reference &ref) { if (isa(ref.target())) const_cast(ref).setTarget(getNullGOT()); else if (const DefinedAtom *da = dyn_cast(ref.target()))