[PATCH] D91530: [llvm-readobj] - Introduce `forEachRelocationDo` helper. NFCI.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 17:42:47 PST 2020


MaskRay added inline comments.


================
Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:3790
     printRelocHeaderFields<ELFT>(OS, Sec.sh_type);
-    this->printRelocationsHelper(Sec);
+    this->forEachRelocationDo(
+        Sec, opts::RawRelr,
----------------
`this->printRelocationsHelper(Sec);` has been expanded into
```
this->forEachRelocationDo(
        Sec, opts::RawRelr,
        [&](const Relocation<ELFT> &R, unsigned Ndx, const Elf_Shdr &Sec,
            const Elf_Shdr *SymTab) { printReloc(R, Ndx, Sec, SymTab); },
        [&](const Elf_Relr &R) { printRelrReloc(R); });
```
multiple times. Isn't the previous version clearer?

Can you elaborate on the claim in the description?

> Our printStackSize implementation currently uses API like RelocationRef, object::symbol_iterator. It is not ideal as it doesn't allow to handle possible error conditions properly.


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

https://reviews.llvm.org/D91530



More information about the llvm-commits mailing list