From: Don Hinton Date: Wed, 10 Jul 2019 17:57:05 +0000 (+0000) Subject: Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9b7c138eccf70cfc06901343464c62f27568930;p=llvm 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365675 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 3cc2c3c0121..036830282a5 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -187,24 +187,27 @@ enum MiscFlags { // Miscellaneous flags to adjust argument // class OptionCategory { private: - StringRef const Name; - StringRef const Description; + StringRef Name = "General Category"; + StringRef Description; void registerCategory(); public: - OptionCategory(StringRef const Name, - StringRef const Description = "") + OptionCategory(StringRef Name, + StringRef Description = "") : Name(Name), Description(Description) { registerCategory(); } + OptionCategory() = default; StringRef getName() const { return Name; } StringRef getDescription() const { return Description; } + + SmallPtrSet