From b21ab43cfc3fa0dacf5c95f04e58b6d804b59a16 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 18 Nov 2013 09:31:53 +0000 Subject: Revert r194865 and r194874. This change is incorrect. If you delete virtual destructor of both a base class and a subclass, then the following code: Base *foo = new Child(); delete foo; will not cause the destructor for members of Child class. As a result, I observe plently of memory leaks. Notable examples I investigated are: ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194997 91177308-0d34-0410-b5e6-96231b3b80d8 --- examples/ExceptionDemo/ExceptionDemo.cpp | 4 +--- examples/Kaleidoscope/Chapter2/toy.cpp | 16 +--------------- examples/Kaleidoscope/Chapter3/toy.cpp | 4 +--- examples/Kaleidoscope/Chapter4/toy.cpp | 4 +--- examples/Kaleidoscope/Chapter5/toy.cpp | 4 +--- examples/Kaleidoscope/Chapter6/toy.cpp | 4 +--- examples/Kaleidoscope/Chapter7/toy.cpp | 4 +--- 7 files changed, 7 insertions(+), 33 deletions(-) (limited to 'examples') diff --git a/examples/ExceptionDemo/ExceptionDemo.cpp b/examples/ExceptionDemo/ExceptionDemo.cpp index c935206..61b1750 100644 --- a/examples/ExceptionDemo/ExceptionDemo.cpp +++ b/examples/ExceptionDemo/ExceptionDemo.cpp @@ -1577,11 +1577,9 @@ public: std::runtime_error::operator=(toCopy))); } - ~OurCppRunException (void) throw (); + ~OurCppRunException (void) throw () {} }; -OurCppRunException::~OurCppRunException() throw () {} - /// Throws foreign C++ exception. /// @param ignoreIt unused parameter that allows function to match implied diff --git a/examples/Kaleidoscope/Chapter2/toy.cpp b/examples/Kaleidoscope/Chapter2/toy.cpp index 43eeb1c..2dc6711 100644 --- a/examples/Kaleidoscope/Chapter2/toy.cpp +++ b/examples/Kaleidoscope/Chapter2/toy.cpp @@ -79,39 +79,28 @@ static int gettok() { /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST(); + virtual ~ExprAST() {} }; -ExprAST::~ExprAST() {} - /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { public: NumberExprAST(double val) {} - virtual ~NumberExprAST(); }; -NumberExprAST::~NumberExprAST() {} - /// VariableExprAST - Expression class for referencing a variable, like "a". class VariableExprAST : public ExprAST { std::string Name; public: VariableExprAST(const std::string &name) : Name(name) {} - virtual ~VariableExprAST(); }; -VariableExprAST::~VariableExprAST() {} - /// BinaryExprAST - Expression class for a binary operator. class BinaryExprAST : public ExprAST { public: BinaryExprAST(char op, ExprAST *lhs, ExprAST *rhs) {} - virtual ~BinaryExprAST(); }; -BinaryExprAST::~BinaryExprAST() {} - /// CallExprAST - Expression class for function calls. class CallExprAST : public ExprAST { std::string Callee; @@ -119,11 +108,8 @@ class CallExprAST : public ExprAST { public: CallExprAST(const std::string &callee, std::vector &args) : Callee(callee), Args(args) {} - virtual ~CallExprAST(); }; -CallExprAST::~CallExprAST() {} - /// PrototypeAST - This class represents the "prototype" for a function, /// which captures its name, and its argument names (thus implicitly the number /// of arguments the function takes). diff --git a/examples/Kaleidoscope/Chapter3/toy.cpp b/examples/Kaleidoscope/Chapter3/toy.cpp index d25aa5d..0fb64e3 100644 --- a/examples/Kaleidoscope/Chapter3/toy.cpp +++ b/examples/Kaleidoscope/Chapter3/toy.cpp @@ -84,12 +84,10 @@ static int gettok() { /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST(); + virtual ~ExprAST() {} virtual Value *Codegen() = 0; }; -ExprAST::~ExprAST() {} - /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { double Val; diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp index a52b555..0e41cc1 100644 --- a/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/examples/Kaleidoscope/Chapter4/toy.cpp @@ -91,12 +91,10 @@ static int gettok() { /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST(); + virtual ~ExprAST() {} virtual Value *Codegen() = 0; }; -ExprAST::~ExprAST() {} - /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { double Val; diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp index 2770a38..d5a88a5 100644 --- a/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/examples/Kaleidoscope/Chapter5/toy.cpp @@ -100,12 +100,10 @@ static int gettok() { /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST(); + virtual ~ExprAST() {} virtual Value *Codegen() = 0; }; -ExprAST::~ExprAST() {} - /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { double Val; diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp index 2a0f212..4d6a128 100644 --- a/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/examples/Kaleidoscope/Chapter6/toy.cpp @@ -105,12 +105,10 @@ static int gettok() { /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST(); + virtual ~ExprAST() {} virtual Value *Codegen() = 0; }; -ExprAST::~ExprAST() {} - /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { double Val; diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp index 0062801..beb0c00 100644 --- a/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/examples/Kaleidoscope/Chapter7/toy.cpp @@ -109,12 +109,10 @@ static int gettok() { /// ExprAST - Base class for all expression nodes. class ExprAST { public: - virtual ~ExprAST(); + virtual ~ExprAST() {} virtual Value *Codegen() = 0; }; -ExprAST::~ExprAST() {} - /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { double Val; -- cgit v1.1