Recommit r231221: "Devirtualize ~parser<T> by making it protected in base classes and making derived classes final"

Reverted in r231254 due to a self-hosting crash of Clang (see Clang
PR22793). Workaround the crash by using {} instead of = default to
define a dtor.

llvm-svn: 231274
This commit is contained in:
David Blaikie 2015-03-04 18:52:32 +00:00
parent f3f185486c
commit 1c47111a85
1 changed files with 16 additions and 10 deletions

View File

@ -714,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;
@ -743,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;
};
@ -755,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) {}
@ -787,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) {}
@ -813,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) {}
@ -835,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) {}
@ -858,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) {}
@ -881,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) {}
@ -903,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) {}
@ -925,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) {}
@ -950,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) {}