r365675 - Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option class."
Don Hinton via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 10 10:57:05 PDT 2019
Author: dhinton
Date: Wed Jul 10 10:57:05 2019
New Revision: 365675
URL: http://llvm.org/viewvc/llvm-project?rev=365675&view=rev
Log:
Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option class."
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
Modified:
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=365675&r1=365674&r2=365675&view=diff
==============================================================================
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Wed Jul 10 10:57:05 2019
@@ -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()) {
More information about the cfe-commits
mailing list