[PATCH] D59746: [LibTooling] Fix '-h' option
Don Hinton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 5 06:29:03 PDT 2019
hintonda added a comment.
In D59746#1456115 <https://reviews.llvm.org/D59746#1456115>, @alexfh wrote:
> Can you give a specific example of how this problem manifests?
Any tool using `tooling::CommonOptionsParser` with the `llvm::cl::OneOrMore` flag will have this problem, i.e., the `-h` flag will be seen, but no action taken because it was never wired up. Please note that we changed `clang-tidy` to use `cl::ZeroOrMore` a few years ago, so it'll spit out help with or without any arguments, including `-h`. However, if you pass a bad argument with `-h` you'll get an error, but no help.
Here are a few you can verify (first try with `-h`, then `-help`):
$ bin/clang-tidy -h -x
LLVM ERROR: CommonOptionsParser: failed to parse command-line arguments. [CommonOptionsParser]: clang-tidy: Unknown command line argument '-x'. Try: 'bin/clang-tidy -help'
clang-tidy: Did you mean '-h'?
$ bin/clang-tidy -help -x
USAGE: clang-tidy [options] <source0> [... <sourceN>]
<snip>
$ bin/clang-refactor -h
error: no refactoring action given
note: the following actions are supported:
local-rename
extract
$ bin/clang-refactor -help
OVERVIEW: Clang-based refactoring tool for C, C++ and Objective-C
USAGE: clang-refactor [options] <source0> [... <sourceN>]
<snip>
$ bin/clang-apply-replacements -h
clang-apply-replacements: Unknown command line argument '-h'. Try: 'bin/clang-apply-replacements -help'
clang-apply-replacements: Did you mean '-help'?
clang-apply-replacements: Not enough positional command line arguments specified!
Must specify at least 1 positional argument: See: bin/clang-apply-replacements -help
$ bin/clang-apply-replacements -help
USAGE: clang-apply-replacements [options] <Search Root Directory>
<snip>
$ bin/clang-change-namespace -h
clang-change-namespace: for the -old_namespace option: must be specified at least once!
clang-change-namespace: for the -new_namespace option: must be specified at least once!
clang-change-namespace: for the -file_pattern option: must be specified at least once!
LLVM ERROR: CommonOptionsParser: failed to parse command-line arguments. [CommonOptionsParser]: clang-change-namespace: Not enough positional command line arguments specified!
Must specify at least 1 positional argument: See: bin/clang-change-namespace -help
$ bin/clang-change-namespace -help
USAGE: clang-change-namespace [options] <source0> [... <sourceN>]
<snip>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59746/new/
https://reviews.llvm.org/D59746
More information about the cfe-commits
mailing list