[llvm] r241033 - Don't return error_code from a function that doesn't fail.
Rafael Espindola
rafael.espindola at gmail.com
Mon Jun 29 18:53:01 PDT 2015
Author: rafael
Date: Mon Jun 29 20:53:01 2015
New Revision: 241033
URL: http://llvm.org/viewvc/llvm-project?rev=241033&view=rev
Log:
Don't return error_code from a function that doesn't fail.
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/lib/Object/Object.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Mon Jun 29 20:53:01 2015
@@ -678,8 +678,7 @@ protected:
uint64_t &Res) const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
- std::error_code getRelocationType(DataRefImpl Rel,
- uint64_t &Res) const override;
+ uint64_t getRelocationType(DataRefImpl Rel) const override;
std::error_code
getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Mon Jun 29 20:53:01 2015
@@ -233,8 +233,7 @@ protected:
uint64_t &Res) const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
- std::error_code getRelocationType(DataRefImpl Rel,
- uint64_t &Res) const override;
+ uint64_t getRelocationType(DataRefImpl Rel) const override;
std::error_code
getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
@@ -725,14 +724,12 @@ uint64_t ELFObjectFile<ELFT>::getROffset
}
template <class ELFT>
-std::error_code ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel,
- uint64_t &Result) const {
+uint64_t ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const {
const Elf_Shdr *sec = getRelSection(Rel);
if (sec->sh_type == ELF::SHT_REL)
- Result = getRel(Rel)->getType(EF.isMips64EL());
+ return getRel(Rel)->getType(EF.isMips64EL());
else
- Result = getRela(Rel)->getType(EF.isMips64EL());
- return std::error_code();
+ return getRela(Rel)->getType(EF.isMips64EL());
}
template <class ELFT>
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Mon Jun 29 20:53:01 2015
@@ -240,8 +240,7 @@ public:
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
section_iterator getRelocationSection(DataRefImpl Rel) const;
- std::error_code getRelocationType(DataRefImpl Rel,
- uint64_t &Res) const override;
+ uint64_t getRelocationType(DataRefImpl Rel) const override;
std::error_code
getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Jun 29 20:53:01 2015
@@ -53,7 +53,7 @@ public:
std::error_code getAddress(uint64_t &Result) const;
uint64_t getOffset() const;
symbol_iterator getSymbol() const;
- std::error_code getType(uint64_t &Result) const;
+ uint64_t getType() const;
/// @brief Indicates whether this relocation should hidden when listing
/// relocations, usually because it is the trailing part of a multipart
@@ -242,8 +242,7 @@ protected:
uint64_t &Res) const = 0;
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
- virtual std::error_code getRelocationType(DataRefImpl Rel,
- uint64_t &Res) const = 0;
+ virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
virtual std::error_code
getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const = 0;
@@ -464,8 +463,8 @@ inline symbol_iterator RelocationRef::ge
return OwningObject->getRelocationSymbol(RelocationPimpl);
}
-inline std::error_code RelocationRef::getType(uint64_t &Result) const {
- return OwningObject->getRelocationType(RelocationPimpl, Result);
+inline uint64_t RelocationRef::getType() const {
+ return OwningObject->getRelocationType(RelocationPimpl);
}
inline std::error_code
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Mon Jun 29 20:53:01 2015
@@ -668,8 +668,7 @@ DWARFContextInMemory::DWARFContextInMemo
uint64_t SectionSize = RelocatedSection->getSize();
for (const RelocationRef &Reloc : Section.relocations()) {
uint64_t Address = Reloc.getOffset();
- uint64_t Type;
- Reloc.getType(Type);
+ uint64_t Type = Reloc.getType();
uint64_t SymAddr = 0;
uint64_t SectionLoadAddress = 0;
object::symbol_iterator Sym = Reloc.getSymbol();
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Mon Jun 29 20:53:01 2015
@@ -772,8 +772,7 @@ void RuntimeDyldELF::findOPDEntrySection
i != e;) {
// The R_PPC64_ADDR64 relocation indicates the first field
// of a .opd entry
- uint64_t TypeFunc;
- check(i->getType(TypeFunc));
+ uint64_t TypeFunc = i->getType();
if (TypeFunc != ELF::R_PPC64_ADDR64) {
++i;
continue;
@@ -790,8 +789,7 @@ void RuntimeDyldELF::findOPDEntrySection
break;
// Just check if following relocation is a R_PPC64_TOC
- uint64_t TypeTOC;
- check(i->getType(TypeTOC));
+ uint64_t TypeTOC = i->getType();
if (TypeTOC != ELF::R_PPC64_TOC)
continue;
@@ -1059,8 +1057,7 @@ relocation_iterator RuntimeDyldELF::proc
unsigned SectionID, relocation_iterator RelI, const ObjectFile &O,
ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs) {
const auto &Obj = cast<ELFObjectFileBase>(O);
- uint64_t RelType;
- Check(RelI->getType(RelType));
+ uint64_t RelType = RelI->getType();
ErrorOr<int64_t> AddendOrErr = ELFRelocationRef(*RelI).getAddend();
int64_t Addend = AddendOrErr ? *AddendOrErr : 0;
elf_symbol_iterator Symbol = RelI->getSymbol();
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h Mon Jun 29 20:53:01 2015
@@ -125,8 +125,7 @@ public:
const bool IsExtern = SecI == Obj.section_end();
// Determine the Addend used to adjust the relocation value.
- uint64_t RelType;
- Check(RelI->getType(RelType));
+ uint64_t RelType = RelI->getType();
uint64_t Offset = RelI->getOffset();
uint64_t Addend = 0;
SectionEntry &Section = Sections[SectionID];
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Mon Jun 29 20:53:01 2015
@@ -990,11 +990,9 @@ symbol_iterator COFFObjectFile::getReloc
return symbol_iterator(SymbolRef(Ref, this));
}
-std::error_code COFFObjectFile::getRelocationType(DataRefImpl Rel,
- uint64_t &Res) const {
+uint64_t COFFObjectFile::getRelocationType(DataRefImpl Rel) const {
const coff_relocation* R = toRel(Rel);
- Res = R->Type;
- return std::error_code();
+ return R->Type;
}
const coff_section *
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Jun 29 20:53:01 2015
@@ -654,19 +654,16 @@ MachOObjectFile::getRelocationSection(Da
return section_iterator(getAnyRelocationSection(getRelocation(Rel)));
}
-std::error_code MachOObjectFile::getRelocationType(DataRefImpl Rel,
- uint64_t &Res) const {
+uint64_t MachOObjectFile::getRelocationType(DataRefImpl Rel) const {
MachO::any_relocation_info RE = getRelocation(Rel);
- Res = getAnyRelocationType(RE);
- return std::error_code();
+ return getAnyRelocationType(RE);
}
std::error_code
MachOObjectFile::getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const {
StringRef res;
- uint64_t RType;
- getRelocationType(Rel, RType);
+ uint64_t RType = getRelocationType(Rel);
unsigned Arch = this->getArch();
@@ -776,8 +773,7 @@ MachOObjectFile::getRelocationTypeName(D
std::error_code MachOObjectFile::getRelocationHidden(DataRefImpl Rel,
bool &Result) const {
unsigned Arch = getArch();
- uint64_t Type;
- getRelocationType(Rel, Type);
+ uint64_t Type = getRelocationType(Rel);
Result = false;
@@ -791,8 +787,7 @@ std::error_code MachOObjectFile::getRelo
if (Type == MachO::X86_64_RELOC_UNSIGNED && Rel.d.a > 0) {
DataRefImpl RelPrev = Rel;
RelPrev.d.a--;
- uint64_t PrevType;
- getRelocationType(RelPrev, PrevType);
+ uint64_t PrevType = getRelocationType(RelPrev);
if (PrevType == MachO::X86_64_RELOC_SUBTRACTOR)
Result = true;
}
Modified: llvm/trunk/lib/Object/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Object.cpp (original)
+++ llvm/trunk/lib/Object/Object.cpp Mon Jun 29 20:53:01 2015
@@ -208,10 +208,7 @@ LLVMSymbolIteratorRef LLVMGetRelocationS
}
uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI) {
- uint64_t ret;
- if (std::error_code ec = (*unwrap(RI))->getType(ret))
- report_fatal_error(ec.message());
- return ret;
+ return (*unwrap(RI))->getType();
}
// NOTE: Caller takes ownership of returned string.
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp Mon Jun 29 20:53:01 2015
@@ -26,7 +26,7 @@ public:
X86_64ELFRelocationInfo(MCContext &Ctx) : MCRelocationInfo(Ctx) {}
const MCExpr *createExprForRelocation(RelocationRef Rel) override {
- uint64_t RelType; Rel.getType(RelType);
+ uint64_t RelType = Rel.getType();
elf_symbol_iterator SymI = Rel.getSymbol();
StringRef SymName; SymI->getName(SymName);
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp Mon Jun 29 20:53:01 2015
@@ -27,7 +27,7 @@ public:
const MCExpr *createExprForRelocation(RelocationRef Rel) override {
const MachOObjectFile *Obj = cast<MachOObjectFile>(Rel.getObject());
- uint64_t RelType; Rel.getType(RelType);
+ uint64_t RelType = Rel.getType();
symbol_iterator SymI = Rel.getSymbol();
StringRef SymName; SymI->getName(SymName);
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=241033&r1=241032&r2=241033&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Mon Jun 29 20:53:01 2015
@@ -804,11 +804,9 @@ void COFFDumper::printRelocations() {
void COFFDumper::printRelocation(const SectionRef &Section,
const RelocationRef &Reloc) {
uint64_t Offset = Reloc.getOffset();
- uint64_t RelocType;
+ uint64_t RelocType = Reloc.getType();
SmallString<32> RelocName;
StringRef SymbolName;
- if (error(Reloc.getType(RelocType)))
- return;
if (error(Reloc.getTypeName(RelocName)))
return;
symbol_iterator Symbol = Reloc.getSymbol();
More information about the llvm-commits
mailing list