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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Bieneman 2015-01-26 21:57:29 +00:00
parent 38c35f3e2c
commit 7006a12ba3
2 changed files with 23 additions and 0 deletions

View File

@ -1931,6 +1931,15 @@ bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
/// option category to display in the -help output. /// option category to display in the -help output.
void HideUnrelatedOptions(cl::OptionCategory &Category); 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 cl
} // End namespace llvm } // End namespace llvm

View File

@ -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, void LLVMParseCommandLineOptions(int argc, const char *const *argv,
const char *Overview) { const char *Overview) {
llvm::cl::ParseCommandLineOptions(argc, argv, Overview); llvm::cl::ParseCommandLineOptions(argc, argv, Overview);