[PATCH] D93900: [llvm-readef/obj] - Change the design structure of ELF dumper. NFCI.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 29 06:18:15 PST 2020


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay, rupprecht.
grimar requested review of this revision.
Herald added a project: LLVM.

This is a refactoring for design of stuff in `ELFDumper.cpp`.
The current design of ELF dumper is far from ideal.

Currently we have the `ELFDumper` class that redirects
most of calls to `ELFDumperStyle`, which can be either
`GNUStyle` or `LLVMStyle`. Both styles are inhireted from the
`DumpStyle` base class. So we have 4 classes and style classes
often have to call methods from the base class (`this->dumper()->...`).
It is not a convenient way.

Instead I suggest to use more straightforward structure that uses
inheritance instead of aggregation:
We can have the `ELFDumper` base class and 2 child classes:
`GNUStyleELFDumper` and `LLVMStyleELFDumper`.

With that we can avoid having a lot of redirection calls and helper methods.
The number of code lines changes from 7142 to 6922 (reduced by ~3%) and the
code overall looks cleaner.


https://reviews.llvm.org/D93900

Files:
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93900.313966.patch
Type: text/x-patch
Size: 88610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201229/7482e4b1/attachment.bin>


More information about the llvm-commits mailing list