[PATCH] D26247: [Object/ELF] - Make getSymbol() return Error.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 09:52:42 PDT 2016


LGTM

On November 2, 2016 11:38:56 AM EDT, George Rimar <grimar at accesssoftek.com> wrote:
>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];
>   }
> 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161102/694d9433/attachment.html>


More information about the llvm-commits mailing list