// Support value comparison outside the template.
struct GenericOptionValue {
- virtual ~GenericOptionValue() = default;
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();
};
bool compare(const GenericOptionValue & /*V*/) const override {
return false;
}
+
+protected:
+ ~OptionValueBase() = default;
};
// Simple copy of the option value.
template <class DataType> class OptionValueCopy : public GenericOptionValue {
DataType Value;
bool Valid;
+
protected:
+ ~OptionValueCopy() = default;
OptionValueCopy(const OptionValueCopy&) = default;
OptionValueCopy &operator=(const OptionValueCopy&) = default;
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.
// 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() {}
void anchor() override;
};
-template <> struct OptionValue<std::string> : OptionValueCopy<std::string> {
+template <>
+struct OptionValue<std::string> final : OptionValueCopy<std::string> {
typedef StringRef WrapperType;
OptionValue() {}
public:
basic_parser_impl(Option &O) {}
- virtual ~basic_parser_impl() {}
enum ValueExpected getValueExpectedFlagDefault() const {
return ValueRequired;
virtual void anchor();
protected:
- basic_parser_impl(const basic_parser_impl&) = default;
-
+ ~basic_parser_impl() = default;
// A helper for basic_parser::printOptionDiff.
void printOptionName(const Option &O, size_t GlobalWidth) const;
};
// a typedef for the provided data type.
//
template <class DataType> class basic_parser : public basic_parser_impl {
-protected:
- // Workaround PR22763
- basic_parser(const basic_parser& RHS) : basic_parser_impl(RHS) {}
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<boolOrDefault>
-template <> class parser<boolOrDefault> final : public basic_parser<boolOrDefault> {
+template <>
+class parser<boolOrDefault> final : public basic_parser<boolOrDefault> {
public:
parser(Option &O) : basic_parser(O) {}
// parser<unsigned long long>
//
template <>
-class parser<unsigned long long> final : 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) {}
// 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);
}
// 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);
}