[PATCH] Adopt new cl::HideUnrelatedOptions API added r226729.

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Jan 21 15:14:52 PST 2015


LGTM.

> On 2015-Jan-21, at 15:02, Chris Bieneman <beanz at apple.com> wrote:
> 
> Hi dexonsmith,
> 
> 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.
> 
> http://reviews.llvm.org/D7109
> 
> Files:
>  lib/Tooling/CommonOptionsParser.cpp
>  tools/clang-format/ClangFormat.cpp
> 
> Index: lib/Tooling/CommonOptionsParser.cpp
> ===================================================================
> --- lib/Tooling/CommonOptionsParser.cpp
> +++ lib/Tooling/CommonOptionsParser.cpp
> @@ -112,15 +112,7 @@
>       cl::desc("Additional argument to prepend to the compiler command line"),
>       cl::cat(Category));
> 
> -  // Hide unrelated options.
> -  StringMap<cl::Option*> Options;
> -  cl::getRegisteredOptions(Options);
> -  for (StringMap<cl::Option *>::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));
> Index: tools/clang-format/ClangFormat.cpp
> ===================================================================
> --- tools/clang-format/ClangFormat.cpp
> +++ tools/clang-format/ClangFormat.cpp
> @@ -270,15 +270,7 @@
> int main(int argc, const char **argv) {
>   llvm::sys::PrintStackTraceOnErrorSignal();
> 
> -  // Hide unrelated options.
> -  StringMap<cl::Option*> Options;
> -  cl::getRegisteredOptions(Options);
> -  for (StringMap<cl::Option *>::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(
> 
> EMAIL PREFERENCES
>  http://reviews.llvm.org/settings/panel/emailpreferences/
> <D7109.18559.patch>





More information about the cfe-commits mailing list