[llvm] r285955 - Remove the last use of report_fatal_error from ELF.h.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 12:07:16 PDT 2016
Author: rafael
Date: Thu Nov 3 14:07:15 2016
New Revision: 285955
URL: http://llvm.org/viewvc/llvm-project?rev=285955&view=rev
Log:
Remove the last use of report_fatal_error from ELF.h.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
llvm/trunk/tools/obj2yaml/elf2yaml.cpp
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=285955&r1=285954&r2=285955&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Nov 3 14:07:15 2016
@@ -117,18 +117,12 @@ public:
return getSectionContentsAsArray<Elf_Sym>(Sec);
}
- Elf_Rela_Range relas(const Elf_Shdr *Sec) const {
- auto V = getSectionContentsAsArray<Elf_Rela>(Sec);
- if (!V)
- report_fatal_error(V.getError().message());
- return *V;
+ ErrorOr<Elf_Rela_Range> relas(const Elf_Shdr *Sec) const {
+ return getSectionContentsAsArray<Elf_Rela>(Sec);
}
- Elf_Rel_Range rels(const Elf_Shdr *Sec) const {
- auto V = getSectionContentsAsArray<Elf_Rel>(Sec);
- if (!V)
- report_fatal_error(V.getError().message());
- return *V;
+ ErrorOr<Elf_Rel_Range> rels(const Elf_Shdr *Sec) const {
+ return getSectionContentsAsArray<Elf_Rel>(Sec);
}
/// \brief Iterate over program header table.
Modified: llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h?rev=285955&r1=285954&r2=285955&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h (original)
+++ llvm/trunk/tools/llvm-readobj/ARMEHABIPrinter.h Thu Nov 3 14:07:15 2016
@@ -387,7 +387,7 @@ PrinterContext<ET>::FindExceptionTable(u
error(SymTabOrErr.getError());
const Elf_Shdr *SymTab = *SymTabOrErr;
- for (const Elf_Rel &R : ELF->rels(&Sec)) {
+ for (const Elf_Rel &R : unwrapOrError(ELF->rels(&Sec))) {
if (R.r_offset != static_cast<unsigned>(IndexTableOffset))
continue;
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=285955&r1=285954&r2=285955&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Thu Nov 3 14:07:15 2016
@@ -2067,7 +2067,7 @@ template <class ELFT> void MipsGOTParser
switch (PLTRelShdr->sh_type) {
case ELF::SHT_REL:
- for (const Elf_Rel &Rel : Obj->rels(PLTRelShdr)) {
+ for (const Elf_Rel &Rel : unwrapOrError(Obj->rels(PLTRelShdr))) {
const Elf_Sym *Sym =
unwrapOrError(Obj->getRelocationSymbol(&Rel, SymTable));
printPLTEntry(PLTShdr->sh_addr, PLTBegin, It, StrTable, Sym);
@@ -2076,7 +2076,7 @@ template <class ELFT> void MipsGOTParser
}
break;
case ELF::SHT_RELA:
- for (const Elf_Rela &Rel : Obj->relas(PLTRelShdr)) {
+ for (const Elf_Rela &Rel : unwrapOrError(Obj->relas(PLTRelShdr))) {
const Elf_Sym *Sym =
unwrapOrError(Obj->getRelocationSymbol(&Rel, SymTable));
printPLTEntry(PLTShdr->sh_addr, PLTBegin, It, StrTable, Sym);
@@ -2531,7 +2531,7 @@ template <class ELFT> void GNUStyle<ELFT
printRelocHeader(OS, ELFT::Is64Bits, (Sec.sh_type == ELF::SHT_RELA));
const Elf_Shdr *SymTab = unwrapOrError(Obj->getSection(Sec.sh_link));
if (Sec.sh_type == ELF::SHT_REL) {
- for (const auto &R : Obj->rels(&Sec)) {
+ for (const auto &R : unwrapOrError(Obj->rels(&Sec))) {
Elf_Rela Rela;
Rela.r_offset = R.r_offset;
Rela.r_info = R.r_info;
@@ -2539,7 +2539,7 @@ template <class ELFT> void GNUStyle<ELFT
printRelocation(Obj, SymTab, Rela, false);
}
} else {
- for (const auto &R : Obj->relas(&Sec))
+ for (const auto &R : unwrapOrError(Obj->relas(&Sec)))
printRelocation(Obj, SymTab, R, true);
}
}
@@ -3388,7 +3388,7 @@ void LLVMStyle<ELFT>::printRelocations(c
switch (Sec->sh_type) {
case ELF::SHT_REL:
- for (const Elf_Rel &R : Obj->rels(Sec)) {
+ for (const Elf_Rel &R : unwrapOrError(Obj->rels(Sec))) {
Elf_Rela Rela;
Rela.r_offset = R.r_offset;
Rela.r_info = R.r_info;
@@ -3397,7 +3397,7 @@ void LLVMStyle<ELFT>::printRelocations(c
}
break;
case ELF::SHT_RELA:
- for (const Elf_Rela &R : Obj->relas(Sec))
+ for (const Elf_Rela &R : unwrapOrError(Obj->relas(Sec)))
printRelocation(Obj, R, SymTab);
break;
}
Modified: llvm/trunk/tools/obj2yaml/elf2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/elf2yaml.cpp?rev=285955&r1=285954&r2=285955&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/elf2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/elf2yaml.cpp Thu Nov 3 14:07:15 2016
@@ -295,7 +295,10 @@ ELFDumper<ELFT>::dumpRelSection(const El
return EC;
const Elf_Shdr *SymTab = *SymTabOrErr;
- for (const Elf_Rel &Rel : Obj.rels(Shdr)) {
+ auto Rels = Obj.rels(Shdr);
+ if (std::error_code EC = Rels.getError())
+ return EC;
+ for (const Elf_Rel &Rel : *Rels) {
ELFYAML::Relocation R;
if (std::error_code EC = dumpRelocation(&Rel, SymTab, R))
return EC;
@@ -319,7 +322,10 @@ ELFDumper<ELFT>::dumpRelaSection(const E
return EC;
const Elf_Shdr *SymTab = *SymTabOrErr;
- for (const Elf_Rela &Rel : Obj.relas(Shdr)) {
+ auto Rels = Obj.relas(Shdr);
+ if (std::error_code EC = Rels.getError())
+ return EC;
+ for (const Elf_Rela &Rel : *Rels) {
ELFYAML::Relocation R;
if (std::error_code EC = dumpRelocation(&Rel, SymTab, R))
return EC;
More information about the llvm-commits
mailing list