llvm.org GIT mirror llvm / d77057e
Replace another report_fatal_error with an ErrorOr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285944 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 3 years ago
2 changed file(s) with 17 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
7171 const Elf_Ehdr *Header;
7272
7373 public:
74 template
75 const T *getEntry(uint32_t Section, uint32_t Entry) const;
74 template
75 ErrorOr getEntry(uint32_t Section, uint32_t Entry) const;
7676 template
7777 const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const;
7878
402402
403403 template
404404 template
405 const T *ELFFile::getEntry(uint32_t Section, uint32_t Entry) const {
405 ErrorOr ELFFile::getEntry(uint32_t Section,
406 uint32_t Entry) const {
406407 ErrorOr Sec = getSection(Section);
407408 if (std::error_code EC = Sec.getError())
408 report_fatal_error(EC.message());
409 return EC;
409410 return getEntry(*Sec, Entry);
410411 }
411412
316316 const Elf_Rela *getRela(DataRefImpl Rela) const;
317317
318318 const Elf_Sym *getSymbol(DataRefImpl Sym) const {
319 return EF.template getEntry(Sym.d.a, Sym.d.b);
319 auto Ret = EF.template getEntry(Sym.d.a, Sym.d.b);
320 if (std::error_code EC = Ret.getError())
321 report_fatal_error(EC.message());
322 return *Ret;
320323 }
321324
322325 const Elf_Shdr *getSection(DataRefImpl Sec) const {
748751 const typename ELFObjectFile::Elf_Rel *
749752 ELFObjectFile::getRel(DataRefImpl Rel) const {
750753 assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
751 return EF.template getEntry(Rel.d.a, Rel.d.b);
754 auto Ret = EF.template getEntry(Rel.d.a, Rel.d.b);
755 if (std::error_code EC = Ret.getError())
756 report_fatal_error(EC.message());
757 return *Ret;
752758 }
753759
754760 template
755761 const typename ELFObjectFile::Elf_Rela *
756762 ELFObjectFile::getRela(DataRefImpl Rela) const {
757763 assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
758 return EF.template getEntry(Rela.d.a, Rela.d.b);
764 auto Ret = EF.template getEntry(Rela.d.a, Rela.d.b);
765 if (std::error_code EC = Ret.getError())
766 report_fatal_error(EC.message());
767 return *Ret;
759768 }
760769
761770 template