That is consistent with other methods around
and helps to handle error on a caller side.
Differential revision: https://reviews.llvm.org/D26247
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285886
91177308-0d34-0410-b5e6-
96231b3b80d8
ArrayRef<Elf_Word> ShndxTable) const;
ErrorOr<const Elf_Shdr *> getSection(uint32_t Index) const;
- const Elf_Sym *getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
+ ErrorOr<const Elf_Sym *> getSymbol(const Elf_Shdr *Sec,
+ uint32_t Index) const {
Elf_Sym_Range Symbols = symbols(Sec);
if (Index >= Symbols.size())
- report_fatal_error("Invalid symbol index");
+ return object_error::invalid_symbol_index;
return &Symbols[Index];
}
string_table_non_null_end,
invalid_section_index,
bitcode_section_not_found,
+ invalid_symbol_index,
};
inline std::error_code make_error_code(object_error e) {
return "Invalid section index";
case object_error::bitcode_section_not_found:
return "Bitcode section not found in object file";
+ case object_error::invalid_symbol_index:
+ return "Invalid symbol index";
}
llvm_unreachable("An enumerator of object_error does not have a message "
"defined.");