diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -193,14 +193,10 @@ StringRef const Name; StringRef const Description; - void registerCategory(); - public: OptionCategory(StringRef const Name, StringRef const Description = "") - : Name(Name), Description(Description) { - registerCategory(); - } + : Name(Name), Description(Description) {} StringRef getName() const { return Name; } StringRef getDescription() const { return Description; } @@ -286,10 +282,11 @@ StringRef ArgStr; // The argument string itself (ex: "help", "o") StringRef HelpStr; // The descriptive text message for -help StringRef ValueStr; // String describing what the value of this option is - SmallVector - Categories; // The Categories this option belongs to SmallPtrSet Subs; // The subcommands this option belongs to. + // Return the set of OptionCategories that this Option belongs to. + SmallPtrSet &getCategories(); + inline enum NumOccurrencesFlag getNumOccurrencesFlag() const { return (enum NumOccurrencesFlag)Occurrences; } @@ -347,7 +344,6 @@ : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), FullyInitialized(false), Position(0), AdditionalVals(0) { - Categories.push_back(&GeneralCategory); } inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } @@ -1843,8 +1839,9 @@ if (!Subs.empty()) error("cl::alias must not have cl::sub(), aliased option's cl::sub() will be used!"); Subs = AliasFor->Subs; - Categories = AliasFor->Categories; - addArgument(); + for(OptionCategory *Cat: AliasFor->getCategories()) + addCategory(*Cat); + addArgument(); } public: diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -155,7 +155,7 @@ SmallVector DefaultOptions; // This collects the different option categories that have been registered. - SmallPtrSet RegisteredOptionCategories; + std::map