1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Replace another report_fatal_error with an ErrorOr.

llvm-svn: 285944
This commit is contained in:
Rafael Espindola 2016-11-03 17:37:28 +00:00
parent b8e8535a52
commit ac4361fcf8
2 changed files with 17 additions and 7 deletions

View File

@ -72,8 +72,8 @@ private:
const Elf_Ehdr *Header;
public:
template<typename T>
const T *getEntry(uint32_t Section, uint32_t Entry) const;
template <typename T>
ErrorOr<const T *> getEntry(uint32_t Section, uint32_t Entry) const;
template <typename T>
const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const;
@ -403,10 +403,11 @@ ErrorOr<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
template <class ELFT>
template <typename T>
const T *ELFFile<ELFT>::getEntry(uint32_t Section, uint32_t Entry) const {
ErrorOr<const T *> ELFFile<ELFT>::getEntry(uint32_t Section,
uint32_t Entry) const {
ErrorOr<const Elf_Shdr *> Sec = getSection(Section);
if (std::error_code EC = Sec.getError())
report_fatal_error(EC.message());
return EC;
return getEntry<T>(*Sec, Entry);
}

View File

@ -317,7 +317,10 @@ public:
const Elf_Rela *getRela(DataRefImpl Rela) const;
const Elf_Sym *getSymbol(DataRefImpl Sym) const {
return EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
auto Ret = EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
if (std::error_code EC = Ret.getError())
report_fatal_error(EC.message());
return *Ret;
}
const Elf_Shdr *getSection(DataRefImpl Sec) const {
@ -749,14 +752,20 @@ template <class ELFT>
const typename ELFObjectFile<ELFT>::Elf_Rel *
ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
return EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
if (std::error_code EC = Ret.getError())
report_fatal_error(EC.message());
return *Ret;
}
template <class ELFT>
const typename ELFObjectFile<ELFT>::Elf_Rela *
ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
return EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
if (std::error_code EC = Ret.getError())
report_fatal_error(EC.message());
return *Ret;
}
template <class ELFT>