From f04568139a38541215f52752732fa673be9fb4a4 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 21 Jan 2015 22:45:52 +0000 Subject: [PATCH] Adding a new cl::HideUnrelatedOptions API to allow clang to migrate off cl::getRegisteredOptions. Summary: cl::getRegisteredOptions really exposes some of the innards of how command line parsing is implemented. Exposing new APIs that allow us to disentangle client code from implementation details will allow us to make more extensive changes to command line parsing. Reviewers: chandlerc, dexonsmith, beanz Reviewed By: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7100 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226729 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 9 +++++++++ lib/Support/CommandLine.cpp | 12 +++++++++++- unittests/Support/CommandLineTest.cpp | 11 +++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 1c06bf5f8c0..314dd951b2c 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1889,6 +1889,15 @@ bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl &Argv, bool MarkEOLs = false); +/// \brief Mark all options not part of this category as cl::ReallyHidden. +/// +/// \param Category the category 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(cl::OptionCategory &Category); + } // End namespace cl } // End namespace llvm diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 40570cab7cc..a774421b26c 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -1826,12 +1826,22 @@ void cl::AddExtraVersionPrinter(void (*func)()) { void cl::getRegisteredOptions(StringMap