[PATCH] D73982: [yaml2obj] Refactor command line parsing
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 00:23:25 PST 2020
MaskRay added a comment.
In D73982#1858729 <https://reviews.llvm.org/D73982#1858729>, @grimar wrote:
> With this patch applied I observe the different behavior between `--help-list` and `-help-list`:
>
> umb at ubuntu:~/LLVM/LLVM/llvm-project/build/bin$ ./yaml2obj -help-list
> OVERVIEW: Create an object file from YAML description
> USAGE: yaml2obj [options] <input file>
>
> OPTIONS:
>
> Generic Options:
>
> --help - Display available options (--help-hidden for more)
> --help-list - Display list of available options (--help-list-hidden for more)
> --version - Display the version of this program
>
> yaml2obj Options:
>
> --docnum=<uint> - Read specified document from input (default = 1)
> -o=<filename> - Output filename
>
>
>
> umb at ubuntu:~/LLVM/LLVM/llvm-project/build/bin$ ./yaml2obj --help-list
> OVERVIEW: Create an object file from YAML description
> USAGE: yaml2obj [options] <input file>
>
> OPTIONS:
> --docnum=<uint> - Read specified document from input (default = 1)
> --help - Display available options (--help-hidden for more)
> -o=<filename> - Output filename
> --version - Display the version of this program
>
>
> The original behavior was:
>
> umb at ubuntu:~/LLVM/LLVM/llvm-project/build/bin$ ./yaml2obj --help-list
> USAGE: yaml2obj [options] <input>
>
> OPTIONS:
> --color - Use colors in output (default=autodetect)
> --docnum=<uint> - Read specified document from input (default = 1)
> --help - Display available options (--help-hidden for more)
> -o=<filename> - Output filename
> --version - Display the version of this program
> umb at ubuntu:~/LLVM/LLVM/llvm-project/build/bin$ ./yaml2obj -help-list
> USAGE: yaml2obj [options] <input>
>
> OPTIONS:
> --color - Use colors in output (default=autodetect)
> --docnum=<uint> - Read specified document from input (default = 1)
> --help - Display available options (--help-hidden for more)
> -o=<filename> - Output filename
> --version - Display the version of this program
>
`--help-list` is `-h -e -l -p ...` now. ParseCommandLineOptions prints help information after parsing `-h` and quits, so `-e` is not rejected.
This change is to make cl::Prefix short options more reliable (cannot conflict with long option names). (We only have one yaml2obj specific long option, so there should not be any problem..)
================
Comment at: llvm/test/tools/yaml2obj/output-file.yaml:6
+
+# RUN: rm -f %t
+# RUN: yaml2obj %s -o %t
----------------
grimar wrote:
> The test name is "invalid output file", but the new test case checks the
> valid usage of the "-o" option isn't?
>
> Perhaps you can rename the test file and keep the new test here.
> Also it probably deserves a comment about what is tested.
It was already renamed :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73982/new/
https://reviews.llvm.org/D73982
More information about the llvm-commits
mailing list