/// 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
}
}
+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);