diff options
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/Support/CommandLine.h')
-rw-r--r-- | contrib/llvm-project/llvm/include/llvm/Support/CommandLine.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/Support/CommandLine.h b/contrib/llvm-project/llvm/include/llvm/Support/CommandLine.h index 58ef176551b6..8929f9b1db15 100644 --- a/contrib/llvm-project/llvm/include/llvm/Support/CommandLine.h +++ b/contrib/llvm-project/llvm/include/llvm/Support/CommandLine.h @@ -243,6 +243,15 @@ extern ManagedStatic<SubCommand> TopLevelSubCommand; // A special subcommand that can be used to put an option into all subcommands. extern ManagedStatic<SubCommand> AllSubCommands; +class SubCommandGroup { + SmallVector<SubCommand *, 4> Subs; + +public: + SubCommandGroup(std::initializer_list<SubCommand *> IL) : Subs(IL) {} + + ArrayRef<SubCommand *> getSubCommands() const { return Subs; } +}; + //===----------------------------------------------------------------------===// // class Option { @@ -314,10 +323,6 @@ public: return getNumOccurrencesFlag() == cl::ConsumeAfter; } - bool isInAllSubCommands() const { - return Subs.contains(&SubCommand::getAll()); - } - //-------------------------------------------------------------------------=== // Accessor functions set by OptionModifiers // @@ -477,11 +482,19 @@ struct cat { // Specify the subcommand that this option belongs to. struct sub { - SubCommand ⋐ + SubCommand *Sub = nullptr; + SubCommandGroup *Group = nullptr; - sub(SubCommand &S) : Sub(S) {} + sub(SubCommand &S) : Sub(&S) {} + sub(SubCommandGroup &G) : Group(&G) {} - template <class Opt> void apply(Opt &O) const { O.addSubCommand(Sub); } + template <class Opt> void apply(Opt &O) const { + if (Sub) + O.addSubCommand(*Sub); + else if (Group) + for (SubCommand *SC : Group->getSubCommands()) + O.addSubCommand(*SC); + } }; // Specify a callback function to be called when an option is seen. |