[llvm-readobj, libSupport] - Refine the implementation of the code that dumps build...
authorGeorgii Rymar <grimar@accesssoftek.com>
Mon, 30 Nov 2020 12:38:42 +0000 (15:38 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 2 Dec 2020 10:51:32 +0000 (13:51 +0300)
commit137a25f04a515e5ea8f24c897e34b4cd236239a8
tree27100256641d3b6268a70af90003c6d983cc5442
parent14557cdf9427341e60b9bd34807c46b2ee826f99
[llvm-readobj, libSupport] - Refine the implementation of the code that dumps build attributes.

This implementation of `ELFDumper<ELFT>::printAttributes()` in llvm-readobj has issues:
1) It crashes when the content of the attribute section is empty.
2) It uses `unwrapOrError` and `reportWarning` calls, though
   ideally we want to use `reportUniqueWarning`.
3) It contains a TODO about redundant format version check.

`lib/Support/ELFAttributeParser.cpp` uses a hardcoded constant instead of the named constant.

This patch fixes all these issues.

Differential revision: https://reviews.llvm.org/D92318
llvm/lib/Support/ELFAttributeParser.cpp
llvm/test/tools/llvm-readobj/ELF/RISCV/attributes-invalid.test
llvm/tools/llvm-readobj/ELFDumper.cpp