mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Devirtualize OptionValue::~OptionValue in favor of protected in the base, with final derived classes
These objects are never polymorphically owned, so there's no need for virtual dtors - just make the dtor protected in the base classes, and make the derived classes final. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231217 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -352,9 +352,11 @@ struct cat {
|
|||||||
|
|
||||||
// Support value comparison outside the template.
|
// Support value comparison outside the template.
|
||||||
struct GenericOptionValue {
|
struct GenericOptionValue {
|
||||||
virtual ~GenericOptionValue() {}
|
|
||||||
virtual bool compare(const GenericOptionValue &V) const = 0;
|
virtual bool compare(const GenericOptionValue &V) const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~GenericOptionValue() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
};
|
};
|
||||||
@@ -380,6 +382,9 @@ struct OptionValueBase : public GenericOptionValue {
|
|||||||
bool compare(const GenericOptionValue & /*V*/) const override {
|
bool compare(const GenericOptionValue & /*V*/) const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~OptionValueBase() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Simple copy of the option value.
|
// Simple copy of the option value.
|
||||||
@@ -387,6 +392,9 @@ template <class DataType> class OptionValueCopy : public GenericOptionValue {
|
|||||||
DataType Value;
|
DataType Value;
|
||||||
bool Valid;
|
bool Valid;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~OptionValueCopy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionValueCopy() : Valid(false) {}
|
OptionValueCopy() : Valid(false) {}
|
||||||
|
|
||||||
@@ -417,12 +425,16 @@ public:
|
|||||||
template <class DataType>
|
template <class DataType>
|
||||||
struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> {
|
struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> {
|
||||||
typedef DataType WrapperType;
|
typedef DataType WrapperType;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~OptionValueBase() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Top-level option class.
|
// Top-level option class.
|
||||||
template <class DataType>
|
template <class DataType>
|
||||||
struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> {
|
struct OptionValue final
|
||||||
OptionValue() {}
|
: OptionValueBase<DataType, std::is_class<DataType>::value> {
|
||||||
|
OptionValue() = default;
|
||||||
|
|
||||||
OptionValue(const DataType &V) { this->setValue(V); }
|
OptionValue(const DataType &V) { this->setValue(V); }
|
||||||
// Some options may take their value from a different data type.
|
// Some options may take their value from a different data type.
|
||||||
@@ -435,7 +447,8 @@ struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> {
|
|||||||
// Other safe-to-copy-by-value common option types.
|
// Other safe-to-copy-by-value common option types.
|
||||||
enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE };
|
enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE };
|
||||||
template <>
|
template <>
|
||||||
struct OptionValue<cl::boolOrDefault> : OptionValueCopy<cl::boolOrDefault> {
|
struct OptionValue<cl::boolOrDefault> final
|
||||||
|
: OptionValueCopy<cl::boolOrDefault> {
|
||||||
typedef cl::boolOrDefault WrapperType;
|
typedef cl::boolOrDefault WrapperType;
|
||||||
|
|
||||||
OptionValue() {}
|
OptionValue() {}
|
||||||
@@ -450,7 +463,8 @@ private:
|
|||||||
void anchor() override;
|
void anchor() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct OptionValue<std::string> : OptionValueCopy<std::string> {
|
template <>
|
||||||
|
struct OptionValue<std::string> final : OptionValueCopy<std::string> {
|
||||||
typedef StringRef WrapperType;
|
typedef StringRef WrapperType;
|
||||||
|
|
||||||
OptionValue() {}
|
OptionValue() {}
|
||||||
|
Reference in New Issue
Block a user