Index: include/llvm/Support/CommandLine.h =================================================================== --- include/llvm/Support/CommandLine.h +++ include/llvm/Support/CommandLine.h @@ -21,10 +21,12 @@ #define LLVM_SUPPORT_COMMANDLINE_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/ManagedStatic.h" #include #include #include @@ -171,6 +173,42 @@ extern OptionCategory GeneralCategory; //===----------------------------------------------------------------------===// +// SubCommand class +// +class SubCommand { +private: + const char *const Name; + const char *const Description; + + void registerSubCommand(); + +public: + SubCommand(const char *const Name, const char *const Description = nullptr) + : Name(Name), Description(Description), ConsumeAfterOpt(nullptr) { + registerSubCommand(); + } + SubCommand() + : Name(nullptr), Description(nullptr), ConsumeAfterOpt(nullptr) {} + + operator bool() const; + + const char *getName() const { return Name; } + const char *getDescription() const { return Description; } + + SmallVector