[PATCH] D65515: [llvm-readobj/libObject] - Introduce a custom warning handler for `ELFFile<ELFT>` methods.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 07:33:41 PDT 2019


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added a subscriber: rupprecht.

Currently, we have a code duplication in llvm-readobj which was introduced in D63266 <https://reviews.llvm.org/D63266>.
The duplication was introduced to allow llvm-readobj to dump the partially
broken object. Methods in `ELFFile<ELFT>` perform a strict validation of the inputs,
what is itself good, but not for dumper tools, that might want to dump the information,
even if some pieces are broken/unexpected.

This patch introduces a warning handler which can be passed to `ELFFile<ELFT>` methods
and can allow skipping the non-critical errors when needed/possible.

For demonstration, I removed the duplication from llvm-readobj and implemented a warning using
the new custom warning handler. It also deduplicates the strings printed, making the output less verbose.


https://reviews.llvm.org/D65515

Files:
  include/llvm/Object/ELF.h
  test/tools/llvm-readobj/elf-invalid-shstrndx.test
  test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
  tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65515.212579.patch
Type: text/x-patch
Size: 10991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190731/06fc539f/attachment.bin>


More information about the llvm-commits mailing list