Index: include/llvm/Support/CommandLine.h =================================================================== --- include/llvm/Support/CommandLine.h +++ include/llvm/Support/CommandLine.h @@ -349,6 +349,8 @@ virtual void printOptionValue(size_t GlobalWidth, bool Force) const = 0; + virtual void setDefault() = 0; + static void printHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy); @@ -1318,6 +1320,20 @@ } } + template ::value>::type> + void setDefaultImpl() { + const OptionValue &V = this->getDefault(); + if (V.hasValue()) + this->setValue(V.getValue()); + } + + template ::value>::type> + void setDefaultImpl(...) {} + + void setDefault() override { setDefaultImpl(); } + void done() { addArgument(); Parser.initialize(); @@ -1493,6 +1509,8 @@ void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override { } + void setDefault() override {} + void done() { addArgument(); Parser.initialize(); @@ -1634,6 +1652,8 @@ void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override { } + void setDefault() override {} + void done() { addArgument(); Parser.initialize(); @@ -1684,6 +1704,8 @@ void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override { } + void setDefault() override { AliasFor->setDefault(); } + ValueExpected getValueExpectedFlagDefault() const override { return AliasFor->getValueExpectedFlag(); }