Jeff Reedy's answer worked great for me, so I accepted his answer, however, I would like to give more detailed information about how you configured it, as well as other information that I found.
As before, I have my options in a declarative form above my main function, however I added a declarative OptionCategory and included this in the declarations of each option in this category:
cl::OptionCategory CompilerCategory("Compiler Options", "Options for controlling the compilation process."); static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::cat(CompilerCategory)); static cl::list<std::string> InputFilenames("i", cl::desc("Input files"), cl::value_desc("filenames"), cl::OneOrMore, cl::cat(CompilerCategory));
Then I have a call to HideUnrelatedOptions inside main just before ParseCommandLineOptions :
int main(int argc, char *argv[]) { cl::HideUnrelatedOptions( CompilerCategory ); cl::ParseCommandLineOptions(argc, argv, " My compiler\n"); ...
Now my OPTIONS output looks much better:
OPTIONS: Compiler Options: Options for controlling the compilation process. -i=<filenames> - Input files -o=<filename> - Output filename 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
This basically marks all options as cl::ReallyHidden , so they don't even show up with -help-hidden :).
Other useful information I found was in the CommandLine Reference Guide .
I know that LLVM is in a constant stream, so just in case the page has gone into the future, here is an example:
using namespace llvm; int main(int argc, char **argv) { cl::OptionCategory AnotherCategory("Some options"); StringMap<cl::Option*> Map; cl::getRegisteredOptions(Map);
This basically shows the power of the system and demonstrates how to change specific parameters as you wish.