[llvm] r241021 - Don't return error_code from function that never fails.
Rafael Espindola
rafael.espindola at gmail.com
Mon Jun 29 16:29:13 PDT 2015
Author: rafael
Date: Mon Jun 29 18:29:12 2015
New Revision: 241021
URL: http://llvm.org/viewvc/llvm-project?rev=241021&view=rev
Log:
Don't return error_code from function that never fails.
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/include/llvm/Object/RelocVisitor.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/lib/Object/Object.cpp
llvm/trunk/tools/dsymutil/DwarfLinker.cpp
llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
llvm/trunk/tools/llvm-objdump/COFFDump.cpp
llvm/trunk/tools/llvm-objdump/MachODump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
llvm/trunk/tools/llvm-readobj/MachODumper.cpp
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Mon Jun 29 18:29:12 2015
@@ -661,8 +661,7 @@ protected:
void moveRelocationNext(DataRefImpl &Rel) const override;
std::error_code getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const override;
- std::error_code getRelocationOffset(DataRefImpl Rel,
- 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;
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Mon Jun 29 18:29:12 2015
@@ -201,8 +201,7 @@ protected:
void moveRelocationNext(DataRefImpl &Rel) const override;
std::error_code getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const override;
- std::error_code getRelocationOffset(DataRefImpl Rel,
- 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;
@@ -689,13 +688,10 @@ ELFObjectFile<ELFT>::getRelocationAddres
}
template <class ELFT>
-std::error_code
-ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel,
- uint64_t &Result) const {
+uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
assert(EF.getHeader()->e_type == ELF::ET_REL &&
"Only relocatable object files have relocation offsets");
- Result = getROffset(Rel);
- return std::error_code();
+ return getROffset(Rel);
}
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=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Mon Jun 29 18:29:12 2015
@@ -237,8 +237,7 @@ public:
void moveRelocationNext(DataRefImpl &Rel) const override;
std::error_code getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const override;
- std::error_code getRelocationOffset(DataRefImpl Rel,
- uint64_t &Res) const override;
+ 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,
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Jun 29 18:29:12 2015
@@ -51,7 +51,7 @@ public:
void moveNext();
std::error_code getAddress(uint64_t &Result) const;
- std::error_code getOffset(uint64_t &Result) const;
+ uint64_t getOffset() const;
symbol_iterator getSymbol() const;
std::error_code getType(uint64_t &Result) const;
@@ -240,8 +240,7 @@ protected:
virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
virtual std::error_code getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const = 0;
- virtual std::error_code getRelocationOffset(DataRefImpl Rel,
- 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;
@@ -457,8 +456,8 @@ inline std::error_code RelocationRef::ge
return OwningObject->getRelocationAddress(RelocationPimpl, Result);
}
-inline std::error_code RelocationRef::getOffset(uint64_t &Result) const {
- return OwningObject->getRelocationOffset(RelocationPimpl, Result);
+inline uint64_t RelocationRef::getOffset() const {
+ return OwningObject->getRelocationOffset(RelocationPimpl);
}
inline symbol_iterator RelocationRef::getSymbol() const {
Modified: llvm/trunk/include/llvm/Object/RelocVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/RelocVisitor.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/RelocVisitor.h (original)
+++ llvm/trunk/include/llvm/Object/RelocVisitor.h Mon Jun 29 18:29:12 2015
@@ -267,8 +267,7 @@ private:
}
RelocToApply visitELF_386_PC32(RelocationRef R, uint64_t Value) {
- uint64_t Address;
- R.getOffset(Address);
+ uint64_t Address = R.getOffset();
return RelocToApply(Value - Address, 4);
}
@@ -282,8 +281,7 @@ private:
}
RelocToApply visitELF_X86_64_PC32(RelocationRef R, uint64_t Value) {
int64_t Addend = getELFAddend(R);
- uint64_t Address;
- R.getOffset(Address);
+ uint64_t Address = R.getOffset();
return RelocToApply(Value + Addend - Address, 4);
}
RelocToApply visitELF_X86_64_32(RelocationRef R, uint64_t Value) {
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Mon Jun 29 18:29:12 2015
@@ -667,8 +667,7 @@ DWARFContextInMemory::DWARFContextInMemo
if (Section.relocation_begin() != Section.relocation_end()) {
uint64_t SectionSize = RelocatedSection->getSize();
for (const RelocationRef &Reloc : Section.relocations()) {
- uint64_t Address;
- Reloc.getOffset(Address);
+ uint64_t Address = Reloc.getOffset();
uint64_t Type;
Reloc.getType(Type);
uint64_t SymAddr = 0;
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Mon Jun 29 18:29:12 2015
@@ -779,9 +779,8 @@ void RuntimeDyldELF::findOPDEntrySection
continue;
}
- uint64_t TargetSymbolOffset;
+ uint64_t TargetSymbolOffset = i->getOffset();
symbol_iterator TargetSymbol = i->getSymbol();
- check(i->getOffset(TargetSymbolOffset));
ErrorOr<int64_t> AddendOrErr =
Obj.getRelocationAddend(i->getRawDataRefImpl());
Check(AddendOrErr.getError());
@@ -1124,8 +1123,7 @@ relocation_iterator RuntimeDyldELF::proc
}
}
- uint64_t Offset;
- Check(RelI->getOffset(Offset));
+ uint64_t Offset = RelI->getOffset();
DEBUG(dbgs() << "\t\tSectionID: " << SectionID << " Offset: " << Offset
<< "\n");
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h Mon Jun 29 18:29:12 2015
@@ -72,8 +72,7 @@ protected:
bool IsPCRel = Obj.getAnyRelocationPCRel(RelInfo);
unsigned Size = Obj.getAnyRelocationLength(RelInfo);
- uint64_t Offset;
- RI->getOffset(Offset);
+ uint64_t Offset = RI->getOffset();
MachO::RelocationInfoType RelType =
static_cast<MachO::RelocationInfoType>(Obj.getAnyRelocationType(RelInfo));
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=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h Mon Jun 29 18:29:12 2015
@@ -127,8 +127,7 @@ public:
// Determine the Addend used to adjust the relocation value.
uint64_t RelType;
Check(RelI->getType(RelType));
- uint64_t Offset;
- Check(RelI->getOffset(Offset));
+ uint64_t Offset = RelI->getOffset();
uint64_t Addend = 0;
SectionEntry &Section = Sections[SectionID];
uintptr_t ObjTarget = Section.ObjAddress + Offset;
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h Mon Jun 29 18:29:12 2015
@@ -220,8 +220,7 @@ private:
SectionEntry &Section = Sections[SectionID];
uint32_t RelocType = MachO.getAnyRelocationType(RE);
bool IsPCRel = MachO.getAnyRelocationPCRel(RE);
- uint64_t Offset;
- RelI->getOffset(Offset);
+ uint64_t Offset = RelI->getOffset();
uint8_t *LocalAddress = Section.Address + Offset;
int64_t Immediate = readBytesUnaligned(LocalAddress, 4); // Copy the whole instruction out.
Immediate = ((Immediate >> 4) & 0xf000) | (Immediate & 0xfff);
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h Mon Jun 29 18:29:12 2015
@@ -138,8 +138,7 @@ private:
uint32_t RelocType = Obj.getAnyRelocationType(RE);
bool IsPCRel = Obj.getAnyRelocationPCRel(RE);
unsigned Size = Obj.getAnyRelocationLength(RE);
- uint64_t Offset;
- RelI->getOffset(Offset);
+ uint64_t Offset = RelI->getOffset();
uint8_t *LocalAddress = Section.Address + Offset;
unsigned NumBytes = 1 << Size;
uint64_t Addend = readBytesUnaligned(LocalAddress, NumBytes);
@@ -197,8 +196,7 @@ private:
uint32_t RelocType = Obj.getAnyRelocationType(RE);
bool IsPCRel = Obj.getAnyRelocationPCRel(RE);
unsigned Size = Obj.getAnyRelocationLength(RE);
- uint64_t Offset;
- RelI->getOffset(Offset);
+ uint64_t Offset = RelI->getOffset();
uint8_t *LocalAddress = Section.Address + Offset;
unsigned NumBytes = 1 << Size;
int64_t Addend = readBytesUnaligned(LocalAddress, NumBytes);
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Mon Jun 29 18:29:12 2015
@@ -967,15 +967,9 @@ std::error_code COFFObjectFile::getReloc
report_fatal_error("getRelocationAddress not implemented in COFFObjectFile");
}
-std::error_code COFFObjectFile::getRelocationOffset(DataRefImpl Rel,
- uint64_t &Res) const {
+uint64_t COFFObjectFile::getRelocationOffset(DataRefImpl Rel) const {
const coff_relocation *R = toRel(Rel);
- const support::ulittle32_t *VirtualAddressPtr;
- if (std::error_code EC =
- getObject(VirtualAddressPtr, Data, &R->VirtualAddress))
- return EC;
- Res = *VirtualAddressPtr;
- return std::error_code();
+ return R->VirtualAddress;
}
symbol_iterator COFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Jun 29 18:29:12 2015
@@ -612,8 +612,7 @@ void MachOObjectFile::moveRelocationNext
std::error_code MachOObjectFile::getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const {
- uint64_t Offset;
- getRelocationOffset(Rel, Offset);
+ uint64_t Offset = getRelocationOffset(Rel);
DataRefImpl Sec;
Sec.d.a = Rel.d.a;
@@ -622,13 +621,11 @@ std::error_code MachOObjectFile::getRelo
return std::error_code();
}
-std::error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
- uint64_t &Res) const {
+uint64_t MachOObjectFile::getRelocationOffset(DataRefImpl Rel) const {
assert(getHeader().filetype == MachO::MH_OBJECT &&
"Only implemented for MH_OBJECT");
MachO::any_relocation_info RE = getRelocation(Rel);
- Res = getAnyRelocationAddress(RE);
- return std::error_code();
+ return getAnyRelocationAddress(RE);
}
symbol_iterator
Modified: llvm/trunk/lib/Object/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Object.cpp (original)
+++ llvm/trunk/lib/Object/Object.cpp Mon Jun 29 18:29:12 2015
@@ -199,10 +199,7 @@ uint64_t LLVMGetRelocationAddress(LLVMRe
}
uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI) {
- uint64_t ret;
- if (std::error_code ec = (*unwrap(RI))->getOffset(ret))
- report_fatal_error(ec.message());
- return ret;
+ return (*unwrap(RI))->getOffset();
}
LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI) {
Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Mon Jun 29 18:29:12 2015
@@ -1451,8 +1451,8 @@ void DwarfLinker::findValidRelocsMachO(c
object::DataRefImpl RelocDataRef = Reloc.getRawDataRefImpl();
MachO::any_relocation_info MachOReloc = Obj.getRelocation(RelocDataRef);
unsigned RelocSize = 1 << Obj.getAnyRelocationLength(MachOReloc);
- uint64_t Offset64;
- if ((RelocSize != 4 && RelocSize != 8) || Reloc.getOffset(Offset64)) {
+ uint64_t Offset64 = Reloc.getOffset();
+ if ((RelocSize != 4 && RelocSize != 8)) {
reportWarning(" unsupported relocation in debug_info section.");
continue;
}
Modified: llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp (original)
+++ llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp Mon Jun 29 18:29:12 2015
@@ -100,9 +100,7 @@ static bool collectRelocatedSymbols(cons
StringRef RelocSymName;
if (error(RelocSymI->getName(RelocSymName)))
return true;
- uint64_t Offset;
- if (error(Reloc.getOffset(Offset)))
- return true;
+ uint64_t Offset = Reloc.getOffset();
if (Offset >= SymOffset && Offset < SymEnd) {
*I = RelocSymName;
++I;
@@ -126,9 +124,7 @@ static bool collectRelocationOffsets(
StringRef RelocSymName;
if (error(RelocSymI->getName(RelocSymName)))
return true;
- uint64_t Offset;
- if (error(Reloc.getOffset(Offset)))
- return true;
+ uint64_t Offset = Reloc.getOffset();
if (Offset >= SymOffset && Offset < SymEnd)
Collection[std::make_pair(SymName, Offset - SymOffset)] = RelocSymName;
}
Modified: llvm/trunk/tools/llvm-objdump/COFFDump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/COFFDump.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/COFFDump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/COFFDump.cpp Mon Jun 29 18:29:12 2015
@@ -177,9 +177,7 @@ static std::error_code resolveSymbol(con
for (std::vector<RelocationRef>::const_iterator I = Rels.begin(),
E = Rels.end();
I != E; ++I) {
- uint64_t Ofs;
- if (std::error_code EC = I->getOffset(Ofs))
- return EC;
+ uint64_t Ofs = I->getOffset();
if (Ofs == Offset) {
Sym = *I->getSymbol();
return std::error_code();
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Mon Jun 29 18:29:12 2015
@@ -796,8 +796,7 @@ static void DumpLiteralPointerSection(Ma
RE = O->getRelocation(Rel);
isExtern = O->getPlainRelocationExternal(RE);
if (isExtern) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
symbol_iterator RelocSym = Reloc.getSymbol();
Relocs.push_back(std::make_pair(RelocOffset, *RelocSym));
}
@@ -1763,8 +1762,7 @@ static int SymbolizerGetOpInfo(void *Dis
bool r_scattered = false;
uint32_t r_value, pair_r_value, r_type;
for (const RelocationRef &Reloc : info->S.relocations()) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
if (RelocOffset == sect_offset) {
Rel = Reloc.getRawDataRefImpl();
RE = info->O->getRelocation(Rel);
@@ -1841,8 +1839,7 @@ static int SymbolizerGetOpInfo(void *Dis
bool isExtern = false;
SymbolRef Symbol;
for (const RelocationRef &Reloc : info->S.relocations()) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
if (RelocOffset == sect_offset) {
Rel = Reloc.getRawDataRefImpl();
RE = info->O->getRelocation(Rel);
@@ -1911,8 +1908,7 @@ static int SymbolizerGetOpInfo(void *Dis
auto Reloc =
std::find_if(info->S.relocations().begin(), info->S.relocations().end(),
[&](const RelocationRef &Reloc) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
return RelocOffset == sect_offset;
});
@@ -2038,8 +2034,7 @@ static int SymbolizerGetOpInfo(void *Dis
auto Reloc =
std::find_if(info->S.relocations().begin(), info->S.relocations().end(),
[&](const RelocationRef &Reloc) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
return RelocOffset == sect_offset;
});
@@ -2429,8 +2424,7 @@ static const char *get_symbol_64(uint32_
bool isExtern = false;
SymbolRef Symbol;
for (const RelocationRef &Reloc : S.relocations()) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
if (RelocOffset == sect_offset) {
Rel = Reloc.getRawDataRefImpl();
RE = info->O->getRelocation(Rel);
@@ -5611,8 +5605,7 @@ static const char *GuessLiteralPointer(u
bool isExtern = false;
SymbolRef Symbol;
for (const RelocationRef &Reloc : info->S.relocations()) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
if (RelocOffset == sect_offset) {
Rel = Reloc.getRawDataRefImpl();
RE = info->O->getRelocation(Rel);
@@ -6106,8 +6099,7 @@ static void DisassembleMachO(StringRef F
// Parse relocations.
std::vector<std::pair<uint64_t, SymbolRef>> Relocs;
for (const RelocationRef &Reloc : Sections[SectIdx].relocations()) {
- uint64_t RelocOffset;
- Reloc.getOffset(RelocOffset);
+ uint64_t RelocOffset = Reloc.getOffset();
uint64_t SectionAddress = Sections[SectIdx].getAddress();
RelocOffset -= SectionAddress;
@@ -6510,8 +6502,7 @@ printMachOCompactUnwindSection(const Mac
// Next we need to look at the relocations to find out what objects are
// actually being referred to.
for (const RelocationRef &Reloc : CompactUnwind.relocations()) {
- uint64_t RelocAddress;
- Reloc.getOffset(RelocAddress);
+ uint64_t RelocAddress = Reloc.getOffset();
uint32_t EntryIdx = RelocAddress / EntrySize;
uint32_t OffsetInEntry = RelocAddress - EntryIdx * EntrySize;
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Mon Jun 29 18:29:12 2015
@@ -212,9 +212,8 @@ static const Target *getTarget(const Obj
}
bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) {
- uint64_t a_addr, b_addr;
- if (error(a.getOffset(a_addr))) return false;
- if (error(b.getOffset(b_addr))) return false;
+ uint64_t a_addr = a.getOffset();
+ uint64_t b_addr = b.getOffset();
return a_addr < b_addr;
}
@@ -890,7 +889,7 @@ static void DisassembleObject(const Obje
// Print relocation for instruction.
while (rel_cur != rel_end) {
bool hidden = false;
- uint64_t addr;
+ uint64_t addr = rel_cur->getOffset();
SmallString<16> name;
SmallString<32> val;
@@ -898,7 +897,6 @@ static void DisassembleObject(const Obje
if (error(rel_cur->getHidden(hidden))) goto skip_print_rel;
if (hidden) goto skip_print_rel;
- if (error(rel_cur->getOffset(addr))) goto skip_print_rel;
// Stop when rel_cur's address is past the current instruction.
if (addr >= Index + Size) break;
if (error(rel_cur->getTypeName(name))) goto skip_print_rel;
@@ -932,7 +930,7 @@ void llvm::PrintRelocations(const Object
outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
for (const RelocationRef &Reloc : Section.relocations()) {
bool hidden;
- uint64_t address;
+ uint64_t address = Reloc.getOffset();
SmallString<32> relocname;
SmallString<32> valuestr;
if (error(Reloc.getHidden(hidden)))
@@ -941,8 +939,6 @@ void llvm::PrintRelocations(const Object
continue;
if (error(Reloc.getTypeName(relocname)))
continue;
- if (error(Reloc.getOffset(address)))
- continue;
if (error(getRelocationValueString(Reloc, valuestr)))
continue;
outs() << format(Fmt.data(), address) << " " << relocname << " "
Modified: llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp Mon Jun 29 18:29:12 2015
@@ -214,9 +214,7 @@ ErrorOr<SymbolRef> Decoder::getRelocated
const SectionRef &Section,
uint64_t Offset) {
for (const auto &Relocation : Section.relocations()) {
- uint64_t RelocationOffset;
- if (auto Error = Relocation.getOffset(RelocationOffset))
- return Error;
+ uint64_t RelocationOffset = Relocation.getOffset();
if (RelocationOffset == Offset)
return *Relocation.getSymbol();
}
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Mon Jun 29 18:29:12 2015
@@ -121,9 +121,7 @@ std::error_code COFFDumper::resolveSymbo
uint64_t Offset, SymbolRef &Sym) {
const auto &Relocations = RelocMap[Section];
for (const auto &Relocation : Relocations) {
- uint64_t RelocationOffset;
- if (std::error_code EC = Relocation.getOffset(RelocationOffset))
- return EC;
+ uint64_t RelocationOffset = Relocation.getOffset();
if (RelocationOffset == Offset) {
Sym = *Relocation.getSymbol();
@@ -805,12 +803,10 @@ void COFFDumper::printRelocations() {
void COFFDumper::printRelocation(const SectionRef &Section,
const RelocationRef &Reloc) {
- uint64_t Offset;
+ uint64_t Offset = Reloc.getOffset();
uint64_t RelocType;
SmallString<32> RelocName;
StringRef SymbolName;
- if (error(Reloc.getOffset(Offset)))
- return;
if (error(Reloc.getType(RelocType)))
return;
if (error(Reloc.getTypeName(RelocName)))
Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Mon Jun 29 18:29:12 2015
@@ -461,10 +461,8 @@ void MachODumper::printRelocation(const
void MachODumper::printRelocation(const MachOObjectFile *Obj,
const RelocationRef &Reloc) {
- uint64_t Offset;
+ uint64_t Offset = Reloc.getOffset();
SmallString<32> RelocName;
- if (error(Reloc.getOffset(Offset)))
- return;
if (error(Reloc.getTypeName(RelocName)))
return;
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=241021&r1=241020&r2=241021&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Mon Jun 29 18:29:12 2015
@@ -199,9 +199,8 @@ bool error(std::error_code EC) {
}
bool relocAddressLess(RelocationRef a, RelocationRef b) {
- uint64_t a_addr, b_addr;
- if (error(a.getOffset(a_addr))) exit(ReturnValue);
- if (error(b.getOffset(b_addr))) exit(ReturnValue);
+ uint64_t a_addr = a.getOffset();
+ uint64_t b_addr = b.getOffset();
return a_addr < b_addr;
}
More information about the llvm-commits
mailing list