]> granicus.if.org Git - llvm/commit
[CommandLine] Improve help text for cl::values style options
authorJames Henderson <jh7370@my.bristol.ac.uk>
Thu, 31 Jan 2019 13:58:48 +0000 (13:58 +0000)
committerJames Henderson <jh7370@my.bristol.ac.uk>
Thu, 31 Jan 2019 13:58:48 +0000 (13:58 +0000)
commit0213867bef699a903909e04174520c04e385c60e
tree502c78ab5c4c6dd6e14a0d0b20378f7aacbe01e4
parent9dd06c1d78fa2ef8f46e61f66745af12a7d8c2ac
[CommandLine] Improve help text for cl::values style options

In order to make an option value truly optional, both the ValueOptional
and an empty-named value are required. This empty-named value appears in
the command-line help text, which is not ideal.

This change improves the help text for these sort of options in a number
of ways:
1) 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.
2) Empty-named values with no help text in ValueOptional options are not
listed in the permitted values.
3) Otherwise empty-named options are printed as =<empty> rather than
simply '='.
4) Option values without help text do not have the '-' separator
printed.

It also tweaks the llvm-symbolizer -functions help text to not print a
trailing ':' as that looks bad combined with 1) above.

Reviewed by: thopre, ruiu

Differential Revision: https://reviews.llvm.org/D57030

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352750 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/CommandLine.cpp
tools/llvm-symbolizer/llvm-symbolizer.cpp
unittests/Support/CommandLineTest.cpp