diff options
| author | Chris Bieneman <beanz@apple.com> | 2015-01-26 21:57:29 +0000 |
|---|---|---|
| committer | Chris Bieneman <beanz@apple.com> | 2015-01-26 21:57:29 +0000 |
| commit | 0104325776cc77e3e109b6d085bf4378e725d763 (patch) | |
| tree | 40e6bc1c4604205d79a34086f7e928a9a36cc338 /llvm | |
| parent | 8e0dec7c80577bdcf4c5fa90f2ba5e2a6a2210d2 (diff) | |
| download | bcm5719-llvm-0104325776cc77e3e109b6d085bf4378e725d763.tar.gz bcm5719-llvm-0104325776cc77e3e109b6d085bf4378e725d763.zip | |
Add new HideUnrelatedOptions API that takes a SmallVectorImpl.
Need a new API for clang-modernize that allows specifying a list of option categories to remain visible. This will allow clang-modernize to move off getRegisteredOptions.
llvm-svn: 227140
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Support/CommandLine.h | 9 | ||||
| -rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 2d75c59cf20..e53ac06a3cd 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -1931,6 +1931,15 @@ bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, /// option category to display in the -help output. void HideUnrelatedOptions(cl::OptionCategory &Category); +/// \brief Mark all options not part of the categories as cl::ReallyHidden. +/// +/// \param Categories the categories of options to keep displaying. +/// +/// Some tools (like clang-format) like to be able to hide all options that are +/// not specific to the tool. This function allows a tool to specify a single +/// option category to display in the -help output. +void HideUnrelatedOptions(SmallVectorImpl<cl::OptionCategory *> &Categories); + } // End namespace cl } // End namespace llvm diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 87f2261def5..4cd6f0c5f0a 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1861,6 +1861,20 @@ void cl::HideUnrelatedOptions(cl::OptionCategory &Category) { } } +void cl::HideUnrelatedOptions( + SmallVectorImpl<cl::OptionCategory *> &Categories) { + auto CategoriesBegin = Categories.begin(); + auto CategoriesEnd = Categories.end(); + StringMap<cl::Option *> Options; + cl::getRegisteredOptions(Options); + for (auto &I : Options) { + if (std::find(CategoriesBegin, CategoriesEnd, I.second->Category) == + CategoriesEnd && + I.second->Category != &GenericCategory) + I.second->setHiddenFlag(cl::ReallyHidden); + } +} + void LLVMParseCommandLineOptions(int argc, const char *const *argv, const char *Overview) { llvm::cl::ParseCommandLineOptions(argc, argv, Overview); |

