[clang-tools-extra] r227388 - NFC. Migrating clang-tools-extra to the cl::HideUnrelatedOptions API.
Chris Bieneman
beanz at apple.com
Wed Jan 28 14:45:27 PST 2015
Author: cbieneman
Date: Wed Jan 28 16:45:26 2015
New Revision: 227388
URL: http://llvm.org/viewvc/llvm-project?rev=227388&view=rev
Log:
NFC. Migrating clang-tools-extra to the cl::HideUnrelatedOptions API.
Modified:
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp
Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=227388&r1=227387&r2=227388&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (original)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Wed Jan 28 16:45:26 2015
@@ -31,20 +31,18 @@ using namespace clang::replace;
static cl::opt<std::string> Directory(cl::Positional, cl::Required,
cl::desc("<Search Root Directory>"));
+static cl::OptionCategory ReplacementCategory("Replacement Options");
static cl::OptionCategory FormattingCategory("Formatting Options");
+const cl::OptionCategory *VisibleCategories[] = {&ReplacementCategory,
+ &FormattingCategory};
+
static cl::opt<bool> RemoveTUReplacementFiles(
"remove-change-desc-files",
cl::desc("Remove the change description files regardless of successful\n"
"merging/replacing."),
- cl::init(false));
+ cl::init(false), cl::cat(ReplacementCategory));
-// Update this list of options to show in -help as new options are added.
-// Should add even those options marked as 'Hidden'. Any option not listed
-// here will get marked 'ReallyHidden' so they don't appear in any -help text.
-const char *OptionsToShow[] = { "help", "version",
- "remove-change-desc-files", "format",
- "style-config", "style" };
static cl::opt<bool> DoFormat(
"format",
@@ -196,13 +194,7 @@ bool applyFormatting(const std::vector<t
}
int main(int argc, char **argv) {
- // Only include our options in -help output.
- StringMap<cl::Option*> &OptMap = cl::getRegisteredOptions();
- const char **EndOpts = std::end(OptionsToShow);
- for (const auto &Opt : OptMap) {
- if (std::find(OptionsToShow, EndOpts, Opt.getKey()) == EndOpts)
- Opt.getValue()->setHiddenFlag(cl::ReallyHidden);
- }
+ cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories));
cl::SetVersionPrinter(&printVersion);
cl::ParseCommandLineOptions(argc, argv);
Modified: clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp?rev=227388&r1=227387&r2=227388&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp Wed Jan 28 16:45:26 2015
@@ -305,21 +305,7 @@ int main(int argc, const char **argv) {
TransformManager.registerTransforms();
- // Hide all options we don't define ourselves. Move pre-defined 'help',
- // 'help-list', and 'version' to our general category.
- llvm::StringMap<cl::Option*> &Options = cl::getRegisteredOptions();
- const cl::OptionCategory **CategoryEnd =
- VisibleCategories + llvm::array_lengthof(VisibleCategories);
- for (llvm::StringMap<cl::Option *>::iterator I = Options.begin(),
- E = Options.end();
- I != E; ++I) {
- if (I->first() == "help" || I->first() == "version" ||
- I->first() == "help-list")
- I->second->setCategory(GeneralCategory);
- else if (std::find(VisibleCategories, CategoryEnd, I->second->Category) ==
- CategoryEnd)
- I->second->setHiddenFlag(cl::ReallyHidden);
- }
+ cl::HideUnrelatedOptions(llvm::makeArrayRef(VisibleCategories));
cl::SetVersionPrinter(&printVersion);
// Parse options and generate compilations.
More information about the cfe-commits
mailing list