[all-commits] [llvm/llvm-project] 3a2043: [llvm-readelf/obj] - Cleanup the interface of `Dum...

Georgii Rymar via All-commits all-commits at lists.llvm.org
Thu Sep 3 02:18:21 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 3a204318c6cd6a6b54081e58ced012e2ec120cc9
      https://github.com/llvm/llvm-project/commit/3a204318c6cd6a6b54081e58ced012e2ec120cc9
  Author: Georgii Rymar <grimar at accesssoftek.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M llvm/tools/llvm-readobj/ELFDumper.cpp

  Log Message:
  -----------
  [llvm-readelf/obj] - Cleanup the interface of `DumpStyle`. NFCI.

We have 2 DumpStyles currently:
`class GNUStyle : public DumpStyle<ELFT>` and `class LLVMStyle : public DumpStyle<ELFT>`.

The problem of `DumpStyle` interface is that almost for each method
we provide `const ELFFile<ELFT> *` as argument. But in fact each of
dump styles keeps `ELFDumper<ELFT> *Dumper` which can be used to get an object from.

But since we use the `Obj` too often, I've decided to introduce a one more reference member
instead of reading it from the `Dumper` each time:
`const ELFFile<ELFT> &Obj;` This is kind of similar to `FileName` member which we have already:
it is also used to store a the file name which can be read from `Dumper->getElfObject()->getFileName()`.

I had to adjust the code which previously worked with a pointer to an object
and now works with a reference.

In a follow-up I am going to try to get rid of `const ELFObjectFile<ELFT>` arguments
which are still passed to a set of functions.

Differential revision: https://reviews.llvm.org/D87040




More information about the All-commits mailing list