I'd like to use llvm::cl as it seems quite easy to use, but there
currently seems to be
a major drawback: if I do -help then all options from all llvm libs that
I have included
are shown, but I just have an input file and output file to specify.
I've always found this incredibly annoying, as have others. I *think*
this is a "patches welcome" problem.
Is it possible to
disable the existing options? For example by assigning each option a flag.
One flag could be for llvm options, another for hidden llvm options and one
for my application (if llvm uses 2 there are 30 left ;-). These flags
could replace the hidden and
"really hidden" states. Options would be hidden if their flag is not set
in an int passed to
cl::ParseCommandLineOptions (perhaps 2 sets of flags, one for -help and
one for -help-hidden).
It is not currently possible, but this is one solution.
Another possibility would be to specify the list of registered options
each of my options (default is the static one in CommandLine.cpp) and this
could be passed to cl::ParseCommandLineOptions.
I think what we really need is what quite a few other tools (gdb and
git come to mind) do. We should provide help/argument namespaces with
a way to control the output.
There are really two cases I can think of here. The first is tools
like opt and bugpoint where there are a bunch of useful options. In
this case it would be nice to directly show the options that are tool
specific, and then show categories for other options pulled in from
The second case is tools like llvm-as and the one you are writing that
link to the llvm passes, but don't care about the other options
because they have _no_ effect on the behavior of the program. In this
case You should be able to completely disable options that have no
effect on output.
With this you would end up with output such as:
% opt -help
OVERVIEW: llvm .bc -> .bc modular optimizer and analysis printer
USAGE: opt [options] <input bitcode file>
-O<n> -blah blah blah
-<pass> - run <pass> see -help passes for a list of passes.
-help [category] - Show help for category
One could then type:
% opt -help passes
And get the long list of passes.
It would also be nice to make all the llvm tools use the same option
names when they mean the same thing. For instance some tools use
-mtriple and others use -triple.
- Michael Spencer