[PATCH] D26247: [Object/ELF] - Make getSymbol() return Error.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 2 08:38:56 PDT 2016
grimar created this revision.
grimar added reviewers: rafael, ruiu.
grimar added subscribers: llvm-commits, grimar, evgeny777.
That is consisten with other methods around
and helps to handle error on a caller side.
https://reviews.llvm.org/D26247
Files:
include/llvm/Object/ELF.h
include/llvm/Object/Error.h
lib/Object/Error.cpp
Index: lib/Object/Error.cpp
===================================================================
--- lib/Object/Error.cpp
+++ lib/Object/Error.cpp
@@ -50,6 +50,8 @@
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.");
Index: include/llvm/Object/Error.h
===================================================================
--- include/llvm/Object/Error.h
+++ include/llvm/Object/Error.h
@@ -34,6 +34,7 @@
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) {
Index: include/llvm/Object/ELF.h
===================================================================
--- include/llvm/Object/ELF.h
+++ include/llvm/Object/ELF.h
@@ -167,10 +167,11 @@
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];
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26247.76713.patch
Type: text/x-patch
Size: 1595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161102/7cb7e90e/attachment.bin>
More information about the llvm-commits
mailing list