diff options
author | Don Hinton <hintonda@gmail.com> | 2019-05-07 18:57:01 +0000 |
---|---|---|
committer | Don Hinton <hintonda@gmail.com> | 2019-05-07 18:57:01 +0000 |
commit | 102ec0977d17069812c505c4b1faae0266a34625 (patch) | |
tree | 6677c6eddd517278b7dd9db50926fad9cdc11a1b /llvm/include/llvm/Support/CommandLine.h | |
parent | fb381607f00eeda03ac76cdd0ec37e407bc31021 (diff) | |
download | bcm5719-llvm-102ec0977d17069812c505c4b1faae0266a34625.tar.gz bcm5719-llvm-102ec0977d17069812c505c4b1faae0266a34625.zip |
[CommandLine] Allow Options to specify multiple OptionCategory's.
Summary:
It's not uncommon for separate components to share common
Options, e.g., it's common for related Passes to share Options in
addition to the Pass specific ones.
With this change, components can use OptionCategory's to simply help
output even if some of the options are shared.
Reviewed By: MaskRay
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61574
llvm-svn: 360179
Diffstat (limited to 'llvm/include/llvm/Support/CommandLine.h')
-rw-r--r-- | llvm/include/llvm/Support/CommandLine.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 74f5de6621e..68cbebe5de8 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -281,7 +281,8 @@ public: 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 - OptionCategory *Category; // The Category this option belongs to + SmallVector<OptionCategory *, 2> + Categories; // The Categories this option belongs to SmallPtrSet<SubCommand *, 4> Subs; // The subcommands this option belongs to. bool FullyInitialized = false; // Has addArgument been called? @@ -333,14 +334,16 @@ public: void setFormattingFlag(enum FormattingFlags V) { Formatting = V; } void setMiscFlag(enum MiscFlags M) { Misc |= M; } void setPosition(unsigned pos) { Position = pos; } - void setCategory(OptionCategory &C) { Category = &C; } + void addCategory(OptionCategory &C); void addSubCommand(SubCommand &S) { Subs.insert(&S); } protected: explicit Option(enum NumOccurrencesFlag OccurrencesFlag, enum OptionHidden Hidden) : Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden), - Formatting(NormalFormatting), Misc(0), Category(&GeneralCategory) {} + Formatting(NormalFormatting), Misc(0) { + Categories.push_back(&GeneralCategory); + } inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } @@ -451,7 +454,7 @@ struct cat { cat(OptionCategory &c) : Category(c) {} - template <class Opt> void apply(Opt &O) const { O.setCategory(Category); } + template <class Opt> void apply(Opt &O) const { O.addCategory(Category); } }; // sub - Specify the subcommand that this option belongs to. @@ -1770,7 +1773,7 @@ class alias : public Option { if (!Subs.empty()) error("cl::alias must not have cl::sub(), aliased option's cl::sub() will be used!"); Subs = AliasFor->Subs; - Category = AliasFor->Category; + Categories = AliasFor->Categories; addArgument(); } |