Devirtualize ArgList's dtor now that -Wvirtual-dtor and C++11 allow a better way to describe this situation

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240238 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2015-06-21 06:51:35 +00:00
parent fa6a5de95b
commit caca524562
2 changed files with 7 additions and 14 deletions

View File

@ -14,6 +14,7 @@
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/OptSpecifier.h" #include "llvm/Option/OptSpecifier.h"
#include "llvm/Option/Option.h" #include "llvm/Option/Option.h"
#include <list> #include <list>
@ -23,7 +24,6 @@
namespace llvm { namespace llvm {
namespace opt { namespace opt {
class Arg;
class ArgList; class ArgList;
class Option; class Option;
@ -110,10 +110,9 @@ private:
protected: protected:
// Default ctor provided explicitly as it is not provided implicitly due to // Default ctor provided explicitly as it is not provided implicitly due to
// the presence of the (deleted) copy ctor above. // the presence of the (deleted) copy ctor above.
ArgList() { } ArgList() = default;
// Virtual to provide a vtable anchor and because -Wnon-virtua-dtor warns, not // Protect the dtor to ensure this type is never destroyed polymorphically.
// because this type is ever actually destroyed polymorphically. ~ArgList() = default;
virtual ~ArgList();
public: public:
@ -299,7 +298,7 @@ public:
/// @} /// @}
}; };
class InputArgList : public ArgList { class InputArgList final : public ArgList {
private: private:
/// List of argument strings used by the contained Args. /// List of argument strings used by the contained Args.
/// ///
@ -320,7 +319,7 @@ private:
public: public:
InputArgList(const char* const *ArgBegin, const char* const *ArgEnd); InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);
~InputArgList() override; ~InputArgList();
const char *getArgString(unsigned Index) const override { const char *getArgString(unsigned Index) const override {
return ArgStrings[Index]; return ArgStrings[Index];
@ -346,7 +345,7 @@ public:
/// DerivedArgList - An ordered collection of driver arguments, /// DerivedArgList - An ordered collection of driver arguments,
/// whose storage may be in another argument list. /// whose storage may be in another argument list.
class DerivedArgList : public ArgList { class DerivedArgList final : public ArgList {
const InputArgList &BaseArgs; const InputArgList &BaseArgs;
/// The list of arguments we synthesized. /// The list of arguments we synthesized.
@ -355,7 +354,6 @@ class DerivedArgList : public ArgList {
public: public:
/// Construct a new derived arg list from \p BaseArgs. /// Construct a new derived arg list from \p BaseArgs.
DerivedArgList(const InputArgList &BaseArgs); DerivedArgList(const InputArgList &BaseArgs);
~DerivedArgList() override;
const char *getArgString(unsigned Index) const override { const char *getArgString(unsigned Index) const override {
return BaseArgs.getArgString(Index); return BaseArgs.getArgString(Index);

View File

@ -33,9 +33,6 @@ void arg_iterator::SkipToNextArg() {
} }
} }
ArgList::~ArgList() {
}
void ArgList::append(Arg *A) { void ArgList::append(Arg *A) {
Args.push_back(A); Args.push_back(A);
} }
@ -358,8 +355,6 @@ const char *InputArgList::MakeArgStringRef(StringRef Str) const {
DerivedArgList::DerivedArgList(const InputArgList &BaseArgs) DerivedArgList::DerivedArgList(const InputArgList &BaseArgs)
: BaseArgs(BaseArgs) {} : BaseArgs(BaseArgs) {}
DerivedArgList::~DerivedArgList() {}
const char *DerivedArgList::MakeArgStringRef(StringRef Str) const { const char *DerivedArgList::MakeArgStringRef(StringRef Str) const {
return BaseArgs.MakeArgString(Str); return BaseArgs.MakeArgString(Str);
} }