diff options
author | Chris Bieneman <beanz@apple.com> | 2015-01-21 22:45:52 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2015-01-21 22:45:52 +0000 |
commit | 9e13af7ac377f682d55b3bb3edd3471d247cbd36 (patch) | |
tree | 04068061e56256d8ff5321bc39b92059c107b916 /llvm/lib/Support/CommandLine.cpp | |
parent | b16b09b154f2a8468dcfaa9a8eb5297d59cbd7cd (diff) | |
download | bcm5719-llvm-9e13af7ac377f682d55b3bb3edd3471d247cbd36.tar.gz bcm5719-llvm-9e13af7ac377f682d55b3bb3edd3471d247cbd36.zip |
Adding a new cl::HideUnrelatedOptions API to allow clang to migrate off cl::getRegisteredOptions.
Summary: cl::getRegisteredOptions really exposes some of the innards of how command line parsing is implemented. Exposing new APIs that allow us to disentangle client code from implementation details will allow us to make more extensive changes to command line parsing.
Reviewers: chandlerc, dexonsmith, beanz
Reviewed By: dexonsmith
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D7100
llvm-svn: 226729
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 40570cab7cc..a774421b26c 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1826,12 +1826,22 @@ void cl::AddExtraVersionPrinter(void (*func)()) { void cl::getRegisteredOptions(StringMap<Option *> &Map) { // Get all the options. SmallVector<Option *, 4> PositionalOpts; // NOT USED - SmallVector<Option *, 4> SinkOpts; // NOT USED + SmallVector<Option *, 4> SinkOpts; // NOT USED assert(Map.size() == 0 && "StringMap must be empty"); GetOptionInfo(PositionalOpts, SinkOpts, Map); return; } +void cl::HideUnrelatedOptions(cl::OptionCategory &Category) { + StringMap<cl::Option *> Options; + cl::getRegisteredOptions(Options); + for (auto &I : Options) { + if (I.second->Category != &Category && I.first() != "help" && + I.first() != "version") + I.second->setHiddenFlag(cl::ReallyHidden); + } +} + void LLVMParseCommandLineOptions(int argc, const char *const *argv, const char *Overview) { llvm::cl::ParseCommandLineOptions(argc, argv, Overview); |