[llvm] r285886 - [Object/ELF] - Make getSymbol() return Error.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 01:40:55 PDT 2016
Author: grimar
Date: Thu Nov 3 03:40:55 2016
New Revision: 285886
URL: http://llvm.org/viewvc/llvm-project?rev=285886&view=rev
Log:
[Object/ELF] - Make getSymbol() return Error.
That is consistent with other methods around
and helps to handle error on a caller side.
Differential revision: https://reviews.llvm.org/D26247
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/include/llvm/Object/Error.h
llvm/trunk/lib/Object/Error.cpp
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=285886&r1=285885&r2=285886&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Nov 3 03:40:55 2016
@@ -158,10 +158,11 @@ public:
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];
}
Modified: llvm/trunk/include/llvm/Object/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Error.h?rev=285886&r1=285885&r2=285886&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Error.h (original)
+++ llvm/trunk/include/llvm/Object/Error.h Thu Nov 3 03:40:55 2016
@@ -34,6 +34,7 @@ enum class object_error {
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) {
Modified: llvm/trunk/lib/Object/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=285886&r1=285885&r2=285886&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Error.cpp (original)
+++ llvm/trunk/lib/Object/Error.cpp Thu Nov 3 03:40:55 2016
@@ -50,6 +50,8 @@ std::string _object_error_category::mess
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.");
More information about the llvm-commits
mailing list