[PATCH] D64470: [Object/ELF] - Improve error reporting for notes.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 21:29:16 PDT 2019


MaskRay added inline comments.


================
Comment at: include/llvm/Object/ELF.h:225
+    assert(Shdr.sh_type == ELF::SHT_NOTE && "Shdr is not of type SHT_NOTE");
+    assert(!Err && "Err should have Error::success() value");
     if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
----------------
Alternatively,

```
assert(Shdr.sh_type == ELF::SHT_NOTE && "Shdr is not of type SHT_NOTE");
if (Err)
  return Elf_Note_Iterator(); // end() if Err is set
if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
  ...
}
return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64470/new/

https://reviews.llvm.org/D64470





More information about the llvm-commits mailing list