]> granicus.if.org Git - clang/commitdiff
Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option...
authorDon Hinton <hintonda@gmail.com>
Wed, 10 Jul 2019 17:57:05 +0000 (17:57 +0000)
committerDon Hinton <hintonda@gmail.com>
Wed, 10 Jul 2019 17:57:05 +0000 (17:57 +0000)
Previously reverted in 364141 due to buildbot breakage, and fixed here
by making GeneralCategory global a ManagedStatic.

Summary:
This change processes `OptionCategory`s and `SubCommand`s as they
are seen instead of caching them in the Option class and processing
them later.  Doing so simplifies the work needed to be done by the Global
parser and significantly reduces the size of the Option class to a mere 64
bytes.

Removing  the `OptionCategory` cache saved 24 bytes, and removing
the `SubCommand` cache saved an additional 48 bytes, for a total of a
72 byte reduction.

Reviewed By: serge-sans-paille

Tags: #llvm, #clang

Differential Revision: https://reviews.llvm.org/D62105

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365675 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-refactor/ClangRefactor.cpp

index f7ca39fcfec35bce2790a6878f14606bc54d6d5e..08963001ccf57e9b721e752f8734116263856e4b 100644 (file)
@@ -38,11 +38,9 @@ namespace opts {
 static cl::OptionCategory CommonRefactorOptions("Refactoring options");
 
 static cl::opt<bool> Verbose("v", cl::desc("Use verbose output"),
-                             cl::cat(cl::GeneralCategory),
                              cl::sub(*cl::AllSubCommands));
 
 static cl::opt<bool> Inplace("i", cl::desc("Inplace edit <file>s"),
-                             cl::cat(cl::GeneralCategory),
                              cl::sub(*cl::AllSubCommands));
 
 } // end namespace opts
@@ -611,7 +609,7 @@ int main(int argc, const char **argv) {
   ClangRefactorTool RefactorTool;
 
   CommonOptionsParser Options(
-      argc, argv, cl::GeneralCategory, cl::ZeroOrMore,
+      argc, argv, *cl::GeneralCategory, cl::ZeroOrMore,
       "Clang-based refactoring tool for C, C++ and Objective-C");
 
   if (auto Err = RefactorTool.Init()) {