Replace ErrorOr<void> with error_code.

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

llvm-svn: 194028
This commit is contained in:
Rafael Espindola 2013-11-05 00:09:36 +00:00
parent 081eaef6fa
commit 75c2ae9664
16 changed files with 37 additions and 37 deletions

View File

@ -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.

View File

@ -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

View File

@ -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);
}

View File

@ -77,7 +77,7 @@ ErrorOr<InputElement *> InputGraph::getNextInputElement() {
}
/// \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;

View File

@ -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;

View File

@ -213,7 +213,7 @@ int relocHexGOTREL_32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A,
} // 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;

View File

@ -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:

View File

@ -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()));

View File

@ -35,7 +35,7 @@ int relocB24PCREL(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
}
} // 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;

View File

@ -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;

View File

@ -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;

View File

@ -33,7 +33,7 @@ int relocPC32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
}
} // 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;

View File

@ -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;

View File

@ -59,7 +59,7 @@ int64_t X86_64TargetRelocationHandler::relocAddend(const Reference &ref) const {
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;

View File

@ -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;

View File

@ -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()))