From 0a9f607f7b63abf001c4fb119cb1f06a54951aeb Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 21 Jan 2015 23:26:11 +0000 Subject: [PATCH] Adopt new cl::HideUnrelatedOptions API added r226729. Summary: cl::HideUnrelatedOptions allows tools to hide all options not part of a specific OptionCategory. This is the common use case for cl::getRegisteredOptions, which should be deprecated in the future because it exposes implementation details of command line parsing. Reviewers: dexonsmith Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D7109 llvm-svn: 226741 --- clang/lib/Tooling/CommonOptionsParser.cpp | 10 +--------- clang/tools/clang-format/ClangFormat.cpp | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/clang/lib/Tooling/CommonOptionsParser.cpp b/clang/lib/Tooling/CommonOptionsParser.cpp index 91c74a4..9a484c1 100644 --- a/clang/lib/Tooling/CommonOptionsParser.cpp +++ b/clang/lib/Tooling/CommonOptionsParser.cpp @@ -112,15 +112,7 @@ CommonOptionsParser::CommonOptionsParser(int &argc, const char **argv, cl::desc("Additional argument to prepend to the compiler command line"), cl::cat(Category)); - // Hide unrelated options. - StringMap Options; - cl::getRegisteredOptions(Options); - for (StringMap::iterator I = Options.begin(), E = Options.end(); - I != E; ++I) { - if (I->second->Category != &Category && I->first() != "help" && - I->first() != "version") - I->second->setHiddenFlag(cl::ReallyHidden); - } + cl::HideUnrelatedOptions(Category); Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, argv)); diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index d44d407..f611f70 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -270,15 +270,7 @@ static void PrintVersion() { int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(); - // Hide unrelated options. - StringMap Options; - cl::getRegisteredOptions(Options); - for (StringMap::iterator I = Options.begin(), E = Options.end(); - I != E; ++I) { - if (I->second->Category != &ClangFormatCategory && I->first() != "help" && - I->first() != "version") - I->second->setHiddenFlag(cl::ReallyHidden); - } + cl::HideUnrelatedOptions(ClangFormatCategory); cl::SetVersionPrinter(PrintVersion); cl::ParseCommandLineOptions( -- 2.7.4