Skip to content

Commit 96d071c

Browse files
committed
Don't return error_code from function that never fails.
llvm-svn: 241021
1 parent 79cfd43 commit 96d071c

23 files changed

+49
-106
lines changed

llvm/include/llvm/Object/COFF.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,7 @@ class COFFObjectFile : public ObjectFile {
661661
void moveRelocationNext(DataRefImpl &Rel) const override;
662662
std::error_code getRelocationAddress(DataRefImpl Rel,
663663
uint64_t &Res) const override;
664-
std::error_code getRelocationOffset(DataRefImpl Rel,
665-
uint64_t &Res) const override;
664+
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
666665
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
667666
std::error_code getRelocationType(DataRefImpl Rel,
668667
uint64_t &Res) const override;

llvm/include/llvm/Object/ELFObjectFile.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
201201
void moveRelocationNext(DataRefImpl &Rel) const override;
202202
std::error_code getRelocationAddress(DataRefImpl Rel,
203203
uint64_t &Res) const override;
204-
std::error_code getRelocationOffset(DataRefImpl Rel,
205-
uint64_t &Res) const override;
204+
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
206205
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
207206
std::error_code getRelocationType(DataRefImpl Rel,
208207
uint64_t &Res) const override;
@@ -689,13 +688,10 @@ ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
689688
}
690689

691690
template <class ELFT>
692-
std::error_code
693-
ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel,
694-
uint64_t &Result) const {
691+
uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const {
695692
assert(EF.getHeader()->e_type == ELF::ET_REL &&
696693
"Only relocatable object files have relocation offsets");
697-
Result = getROffset(Rel);
698-
return std::error_code();
694+
return getROffset(Rel);
699695
}
700696

701697
template <class ELFT>

llvm/include/llvm/Object/MachO.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ class MachOObjectFile : public ObjectFile {
237237
void moveRelocationNext(DataRefImpl &Rel) const override;
238238
std::error_code getRelocationAddress(DataRefImpl Rel,
239239
uint64_t &Res) const override;
240-
std::error_code getRelocationOffset(DataRefImpl Rel,
241-
uint64_t &Res) const override;
240+
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
242241
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
243242
section_iterator getRelocationSection(DataRefImpl Rel) const;
244243
std::error_code getRelocationType(DataRefImpl Rel,

llvm/include/llvm/Object/ObjectFile.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RelocationRef {
5151
void moveNext();
5252

5353
std::error_code getAddress(uint64_t &Result) const;
54-
std::error_code getOffset(uint64_t &Result) const;
54+
uint64_t getOffset() const;
5555
symbol_iterator getSymbol() const;
5656
std::error_code getType(uint64_t &Result) const;
5757

@@ -240,8 +240,7 @@ class ObjectFile : public SymbolicFile {
240240
virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
241241
virtual std::error_code getRelocationAddress(DataRefImpl Rel,
242242
uint64_t &Res) const = 0;
243-
virtual std::error_code getRelocationOffset(DataRefImpl Rel,
244-
uint64_t &Res) const = 0;
243+
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
245244
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
246245
virtual std::error_code getRelocationType(DataRefImpl Rel,
247246
uint64_t &Res) const = 0;
@@ -457,8 +456,8 @@ inline std::error_code RelocationRef::getAddress(uint64_t &Result) const {
457456
return OwningObject->getRelocationAddress(RelocationPimpl, Result);
458457
}
459458

460-
inline std::error_code RelocationRef::getOffset(uint64_t &Result) const {
461-
return OwningObject->getRelocationOffset(RelocationPimpl, Result);
459+
inline uint64_t RelocationRef::getOffset() const {
460+
return OwningObject->getRelocationOffset(RelocationPimpl);
462461
}
463462

464463
inline symbol_iterator RelocationRef::getSymbol() const {

llvm/include/llvm/Object/RelocVisitor.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ class RelocVisitor {
267267
}
268268

269269
RelocToApply visitELF_386_PC32(RelocationRef R, uint64_t Value) {
270-
uint64_t Address;
271-
R.getOffset(Address);
270+
uint64_t Address = R.getOffset();
272271
return RelocToApply(Value - Address, 4);
273272
}
274273

@@ -282,8 +281,7 @@ class RelocVisitor {
282281
}
283282
RelocToApply visitELF_X86_64_PC32(RelocationRef R, uint64_t Value) {
284283
int64_t Addend = getELFAddend(R);
285-
uint64_t Address;
286-
R.getOffset(Address);
284+
uint64_t Address = R.getOffset();
287285
return RelocToApply(Value + Addend - Address, 4);
288286
}
289287
RelocToApply visitELF_X86_64_32(RelocationRef R, uint64_t Value) {

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
667667
if (Section.relocation_begin() != Section.relocation_end()) {
668668
uint64_t SectionSize = RelocatedSection->getSize();
669669
for (const RelocationRef &Reloc : Section.relocations()) {
670-
uint64_t Address;
671-
Reloc.getOffset(Address);
670+
uint64_t Address = Reloc.getOffset();
672671
uint64_t Type;
673672
Reloc.getType(Type);
674673
uint64_t SymAddr = 0;

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,8 @@ void RuntimeDyldELF::findOPDEntrySection(const ELFObjectFileBase &Obj,
779779
continue;
780780
}
781781

782-
uint64_t TargetSymbolOffset;
782+
uint64_t TargetSymbolOffset = i->getOffset();
783783
symbol_iterator TargetSymbol = i->getSymbol();
784-
check(i->getOffset(TargetSymbolOffset));
785784
ErrorOr<int64_t> AddendOrErr =
786785
Obj.getRelocationAddend(i->getRawDataRefImpl());
787786
Check(AddendOrErr.getError());
@@ -1124,8 +1123,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
11241123
}
11251124
}
11261125

1127-
uint64_t Offset;
1128-
Check(RelI->getOffset(Offset));
1126+
uint64_t Offset = RelI->getOffset();
11291127

11301128
DEBUG(dbgs() << "\t\tSectionID: " << SectionID << " Offset: " << Offset
11311129
<< "\n");

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ class RuntimeDyldMachO : public RuntimeDyldImpl {
7272

7373
bool IsPCRel = Obj.getAnyRelocationPCRel(RelInfo);
7474
unsigned Size = Obj.getAnyRelocationLength(RelInfo);
75-
uint64_t Offset;
76-
RI->getOffset(Offset);
75+
uint64_t Offset = RI->getOffset();
7776
MachO::RelocationInfoType RelType =
7877
static_cast<MachO::RelocationInfoType>(Obj.getAnyRelocationType(RelInfo));
7978

llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ class RuntimeDyldCOFFX86_64 : public RuntimeDyldCOFF {
127127
// Determine the Addend used to adjust the relocation value.
128128
uint64_t RelType;
129129
Check(RelI->getType(RelType));
130-
uint64_t Offset;
131-
Check(RelI->getOffset(Offset));
130+
uint64_t Offset = RelI->getOffset();
132131
uint64_t Addend = 0;
133132
SectionEntry &Section = Sections[SectionID];
134133
uintptr_t ObjTarget = Section.ObjAddress + Offset;

llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ class RuntimeDyldMachOARM
220220
SectionEntry &Section = Sections[SectionID];
221221
uint32_t RelocType = MachO.getAnyRelocationType(RE);
222222
bool IsPCRel = MachO.getAnyRelocationPCRel(RE);
223-
uint64_t Offset;
224-
RelI->getOffset(Offset);
223+
uint64_t Offset = RelI->getOffset();
225224
uint8_t *LocalAddress = Section.Address + Offset;
226225
int64_t Immediate = readBytesUnaligned(LocalAddress, 4); // Copy the whole instruction out.
227226
Immediate = ((Immediate >> 4) & 0xf000) | (Immediate & 0xfff);

0 commit comments

Comments
 (0)