In order to make an option value truly optional, both the ValueOptional attribute and an empty-named value are required. Prior to this change, this empty-named value appears in
the command-line help text:
-some-option - some help text =v1 - description 1 =v2 - description 2 = -
This change improves the help text for these sort of options in a number of ways:
- ValueOptional options with an empty-named value now print their help text twice: both without and then with '=<value>' after the name. The latter version then lists the allowed values after it.
- Empty-named values with no help text in ValueOptional options are not listed in the permitted values.
-some-option - some help text -some-option=<value> - some help text =v1 - description 1 =v2 - description 2
- Otherwise empty-named options are printed as =<empty> rather than simply '='.
- Option values without help text do not have the '-' separator printed.
-some-option=<value> - some help text =v1 - description 1 =v2 =<empty> - description
It also tweaks the llvm-symbolizer -functions help text to not print a trailing ':' as that looks bad combined with 1) above.
I wonder if a small inline function for this would make sense. BTW, do you know why the width is not computed from the return value of getOptionInfo?