[PATCH] D72843: [llvm-readelf][llvm-readobj] - Fix the indentation when printing dynamic tags.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 04:44:38 PST 2020


grimar added a comment.

In D72843#1826184 <https://reviews.llvm.org/D72843#1826184>, @jhenderson wrote:

> In both cases, I'm struggling to follow why specific numbers are used, e.g. where does the "-1" "-3" etc come from?


These numbers depends on a column names used.
Imagine we have two cases. In the first, column names are
"Type" and "Value" vs "FooType" and "Value" for the second case.

The number of indentation whitespaces would be different for these cases,
just because "FooType" is 3 characters longer.

In this patch, LLVM style-part uses
`"Type" << std::string(MaxTagSize - 3, ' ') << "Name/Value\n";`.

The identation we want to print is `MaxTagSize - 3` because it is == 
[`MaxTagSize` - the length of `Type` (4) + a single trailing whitespace (1)].

For the GNU style I've used `-1` because it wraps tag names into '(`, ')', e.g:

  Tag        Type                   Name/Value
  0x00000001 (NEEDED)               Shared library: [D]

Hence the identation length is increased by 2 because of 2 round brackets printed additionally.


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

https://reviews.llvm.org/D72843





More information about the llvm-commits mailing list