[libOption] - Add flag allowing to print options aliases in help text.
ClosedPublic

Authored by grimar on Jul 17 2017, 3:56 AM.

Details

Summary

Goint to use it in LLD.
In short this is PR30422, previously LLD did not show
aliases in help text. With this it is possible.

Diff Detail

Repository
rL LLVM
grimar created this revision.Jul 17 2017, 3:56 AM
ruiu added a comment.Jul 17 2017, 3:45 PM

Please wait until we decide how we print out the lld options in the help message.

In D35476#812068, @ruiu wrote:

Please wait until we decide how we print out the lld options in the help message.

Ok. Going to rebase this after rL308293 though.

But just in case - the way we will choose for LLD (render all or some of aliases)
should not affect this patch (except if we choose possible way to ignore aliases
rendering at all, which I believe not an option).

Because this patch only implements aliases rendering, and hidden flags handling is
independent and already was implemented before this change.

grimar updated this revision to Diff 107061.Jul 18 2017, 4:30 AM
  • Rebased.
grimar updated this revision to Diff 107870.Jul 24 2017, 2:48 AM
grimar edited the summary of this revision. (Show Details)
  • Reimplemented.

ShowAliases flag allows to specify that alias should take HelpText from its
parent option. In that case we can have for example:

def auxiliary: S<"auxiliary">, HelpText<"Set DT_AUXILIARY field to the specified name">;
def alias_auxiliary: Separate<["-"], "f">, Alias<auxiliary>;

and show both options in help:

--auxiliary <value> Set DT_AUXILIARY field to the specified name
-f <value>              Set DT_AUXILIARY field to the specified name

Without that change we would render only first line in --help.

grimar updated this revision to Diff 107874.Jul 24 2017, 2:57 AM
  • Change argument name, added lost description.
ruiu added a comment.Jul 24 2017, 10:36 AM

The new behavior is probably fine, but I don't think you needed to change the parameter name.

In D35476#819118, @ruiu wrote:

The new behavior is probably fine, but I don't think you needed to change the parameter name.

I changed newly introduced ShowAliases to InferHelpText because first one is not completelly correctly
reflects the action performed.

If we have HelpText specified for alias:
def alias_version_V: Flag<["-"], "V">, Alias<version>, HelpText<"blah blah">;
then regardless of ShowAliases flag value, this option will be shown.
Because old logic prints all options with HelpText at first place (and I did not change it here).

Probably we can name it ShowAllAliases ? With description saying it will trigger rendering all
aliases regardless they have HelpText explicitly set or not.

grimar updated this revision to Diff 108052.Jul 25 2017, 5:03 AM
  • Updated in according to my latest comment. (renamed argument to ShowAllAliases).
ruiu accepted this revision.Jul 25 2017, 11:07 AM

LGTM

include/llvm/Option/OptTable.h
194–197 ↗(On Diff #108052)

If true, display all options including aliases that don't have help texts. By default, we display only options that are not hidden and have help texts.

lib/Option/OptTable.cpp
478–481 ↗(On Diff #108052)

If an alias doesn't have a help text, show a help text for the aliased option instead.

This revision is now accepted and ready to land.Jul 25 2017, 11:07 AM
This revision was automatically updated to reflect the committed changes.