diff options
Diffstat (limited to 'include/llvm/Support/CommandLine.h')
-rw-r--r-- | include/llvm/Support/CommandLine.h | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 64c5d96..bd1d1cb 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -352,9 +352,14 @@ struct cat { // Support value comparison outside the template. struct GenericOptionValue { - virtual ~GenericOptionValue() {} virtual bool compare(const GenericOptionValue &V) const = 0; +protected: + ~GenericOptionValue() = default; + GenericOptionValue() = default; + GenericOptionValue(const GenericOptionValue&) = default; + GenericOptionValue &operator=(const GenericOptionValue &) = default; + private: virtual void anchor(); }; @@ -380,6 +385,9 @@ struct OptionValueBase : public GenericOptionValue { bool compare(const GenericOptionValue & /*V*/) const override { return false; } + +protected: + ~OptionValueBase() = default; }; // Simple copy of the option value. @@ -387,6 +395,11 @@ template <class DataType> class OptionValueCopy : public GenericOptionValue { DataType Value; bool Valid; +protected: + ~OptionValueCopy() = default; + OptionValueCopy(const OptionValueCopy&) = default; + OptionValueCopy &operator=(const OptionValueCopy&) = default; + public: OptionValueCopy() : Valid(false) {} @@ -417,12 +430,19 @@ public: template <class DataType> struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> { typedef DataType WrapperType; + +protected: + ~OptionValueBase() = default; + OptionValueBase() = default; + OptionValueBase(const OptionValueBase&) = default; + OptionValueBase &operator=(const OptionValueBase&) = default; }; // Top-level option class. template <class DataType> -struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> { - OptionValue() {} +struct OptionValue final + : OptionValueBase<DataType, std::is_class<DataType>::value> { + OptionValue() = default; OptionValue(const DataType &V) { this->setValue(V); } // Some options may take their value from a different data type. @@ -435,7 +455,8 @@ struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> { // Other safe-to-copy-by-value common option types. enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE }; template <> -struct OptionValue<cl::boolOrDefault> : OptionValueCopy<cl::boolOrDefault> { +struct OptionValue<cl::boolOrDefault> final + : OptionValueCopy<cl::boolOrDefault> { typedef cl::boolOrDefault WrapperType; OptionValue() {} @@ -450,7 +471,8 @@ private: void anchor() override; }; -template <> struct OptionValue<std::string> : OptionValueCopy<std::string> { +template <> +struct OptionValue<std::string> final : OptionValueCopy<std::string> { typedef StringRef WrapperType; OptionValue() {} @@ -692,7 +714,6 @@ class basic_parser_impl { // non-template implementation of basic_parser<t> public: basic_parser_impl(Option &O) {} - virtual ~basic_parser_impl() {} enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; @@ -721,6 +742,7 @@ public: virtual void anchor(); protected: + ~basic_parser_impl() = default; // A helper for basic_parser::printOptionDiff. void printOptionName(const Option &O, size_t GlobalWidth) const; }; @@ -733,12 +755,16 @@ public: basic_parser(Option &O) : basic_parser_impl(O) {} typedef DataType parser_data_type; typedef OptionValue<DataType> OptVal; + +protected: + // Workaround Clang PR22793 + ~basic_parser() {} }; //-------------------------------------------------- // parser<bool> // -template <> class parser<bool> : public basic_parser<bool> { +template <> class parser<bool> final : public basic_parser<bool> { public: parser(Option &O) : basic_parser(O) {} @@ -765,7 +791,8 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<bool>); //-------------------------------------------------- // parser<boolOrDefault> -template <> class parser<boolOrDefault> : public basic_parser<boolOrDefault> { +template <> +class parser<boolOrDefault> final : public basic_parser<boolOrDefault> { public: parser(Option &O) : basic_parser(O) {} @@ -791,7 +818,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>); //-------------------------------------------------- // parser<int> // -template <> class parser<int> : public basic_parser<int> { +template <> class parser<int> final : public basic_parser<int> { public: parser(Option &O) : basic_parser(O) {} @@ -813,7 +840,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<int>); //-------------------------------------------------- // parser<unsigned> // -template <> class parser<unsigned> : public basic_parser<unsigned> { +template <> class parser<unsigned> final : public basic_parser<unsigned> { public: parser(Option &O) : basic_parser(O) {} @@ -836,7 +863,8 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned>); // parser<unsigned long long> // template <> -class parser<unsigned long long> : public basic_parser<unsigned long long> { +class parser<unsigned long long> final + : public basic_parser<unsigned long long> { public: parser(Option &O) : basic_parser(O) {} @@ -859,7 +887,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>); //-------------------------------------------------- // parser<double> // -template <> class parser<double> : public basic_parser<double> { +template <> class parser<double> final : public basic_parser<double> { public: parser(Option &O) : basic_parser(O) {} @@ -881,7 +909,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<double>); //-------------------------------------------------- // parser<float> // -template <> class parser<float> : public basic_parser<float> { +template <> class parser<float> final : public basic_parser<float> { public: parser(Option &O) : basic_parser(O) {} @@ -903,7 +931,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<float>); //-------------------------------------------------- // parser<std::string> // -template <> class parser<std::string> : public basic_parser<std::string> { +template <> class parser<std::string> final : public basic_parser<std::string> { public: parser(Option &O) : basic_parser(O) {} @@ -928,7 +956,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<std::string>); //-------------------------------------------------- // parser<char> // -template <> class parser<char> : public basic_parser<char> { +template <> class parser<char> final : public basic_parser<char> { public: parser(Option &O) : basic_parser(O) {} @@ -967,7 +995,7 @@ void printOptionDiff(const Option &O, const generic_parser_base &P, const DT &V, // This is instantiated for basic parsers when the parsed value has a different // type than the option value. e.g. HelpPrinter. template <class ParserDT, class ValDT> struct OptionDiffPrinter { - void print(const Option &O, const parser<ParserDT> P, const ValDT & /*V*/, + void print(const Option &O, const parser<ParserDT> &P, const ValDT & /*V*/, const OptionValue<ValDT> & /*Default*/, size_t GlobalWidth) { P.printOptionNoValue(O, GlobalWidth); } @@ -976,7 +1004,7 @@ template <class ParserDT, class ValDT> struct OptionDiffPrinter { // This is instantiated for basic parsers when the parsed value has the same // type as the option value. template <class DT> struct OptionDiffPrinter<DT, DT> { - void print(const Option &O, const parser<DT> P, const DT &V, + void print(const Option &O, const parser<DT> &P, const DT &V, const OptionValue<DT> &Default, size_t GlobalWidth) { P.printOptionDiff(O, V, Default, GlobalWidth); } |