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 @@ -992,6 +992,50 @@ extern template class basic_parser; //-------------------------------------------------- +// parser +// +template <> class parser final : public basic_parser { +public: + parser(Option &O) : basic_parser(O) {} + + // parse - Return true on error. + bool parse(Option &O, StringRef ArgName, StringRef Arg, long &Val); + + // getValueName - Overload in subclass to provide a better default value. + StringRef getValueName() const override { return "long"; } + + void printOptionDiff(const Option &O, long V, OptVal Default, + size_t GlobalWidth) const; + + // An out-of-line virtual method to provide a 'home' for this class. + void anchor() override; +}; + +extern template class basic_parser; + +//-------------------------------------------------- +// parser +// +template <> class parser : public basic_parser { +public: + parser(Option &O) : basic_parser(O) {} + + // parse - Return true on error. + bool parse(Option &O, StringRef ArgName, StringRef Arg, long long &Val); + + // getValueName - Overload in subclass to provide a better default value. + StringRef getValueName() const override { return "long"; } + + void printOptionDiff(const Option &O, long long V, OptVal Default, + size_t GlobalWidth) const; + + // An out-of-line virtual method to provide a 'home' for this class. + void anchor() override; +}; + +extern template class basic_parser; + +//-------------------------------------------------- // parser // template <> class parser : public basic_parser { 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 @@ -57,6 +57,8 @@ template class basic_parser; template class basic_parser; template class basic_parser; +template class basic_parser; +template class basic_parser; template class basic_parser; template class basic_parser; template class basic_parser; @@ -82,6 +84,8 @@ void parser::anchor() {} void parser::anchor() {} void parser::anchor() {} +void parser::anchor() {} +void parser::anchor() {} void parser::anchor() {} void parser::anchor() {} void parser::anchor() {} @@ -1806,6 +1810,24 @@ return false; } +// parser implementation +// +bool parser::parse(Option &O, StringRef ArgName, StringRef Arg, + long &Value) { + if (Arg.getAsInteger(0, Value)) + return O.error("'" + Arg + "' value invalid for long argument!"); + return false; +} + +// parser implementation +// +bool parser::parse(Option &O, StringRef ArgName, StringRef Arg, + long long &Value) { + if (Arg.getAsInteger(0, Value)) + return O.error("'" + Arg + "' value invalid for llong argument!"); + return false; +} + // parser implementation // bool parser::parse(Option &O, StringRef ArgName, StringRef Arg, @@ -2015,6 +2037,8 @@ PRINT_OPT_DIFF(bool) PRINT_OPT_DIFF(boolOrDefault) PRINT_OPT_DIFF(int) +PRINT_OPT_DIFF(long) +PRINT_OPT_DIFF(long long) PRINT_OPT_DIFF(unsigned) PRINT_OPT_DIFF(unsigned long) PRINT_OPT_DIFF(unsigned long long)