From f94b793472a8427e0507862cd5595cc92e70f53c Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Wed, 2 May 2018 13:29:16 +0200 Subject: [PATCH] Add virtual destructors on base classes. --- libevmasm/ConstantOptimiser.h | 1 + libevmasm/PeepholeOptimiser.h | 2 ++ libjulia/optimiser/ASTCopier.h | 3 +++ libjulia/optimiser/ASTWalker.h | 2 ++ libsolidity/ast/AST.h | 4 ++++ libsolidity/ast/ASTVisitor.h | 2 ++ libsolidity/ast/Types.h | 1 + libsolidity/formal/SolverInterface.h | 1 + libsolidity/formal/SymbolicVariable.h | 1 + test/ExecutionFramework.h | 1 + test/libsolidity/AnalysisFramework.h | 1 + 11 files changed, 19 insertions(+) diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index 9b60b26b2..f0deb387d 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -67,6 +67,7 @@ public: explicit ConstantOptimisationMethod(Params const& _params, u256 const& _value): m_params(_params), m_value(_value) {} + virtual ~ConstantOptimisationMethod() = default; virtual bigint gasNeeded() const = 0; /// Executes the method, potentially appending to the assembly and returns a vector of /// assembly items the constant should be relpaced with in one sweep. diff --git a/libevmasm/PeepholeOptimiser.h b/libevmasm/PeepholeOptimiser.h index a74cc8b30..a651143dd 100644 --- a/libevmasm/PeepholeOptimiser.h +++ b/libevmasm/PeepholeOptimiser.h @@ -34,6 +34,7 @@ using AssemblyItems = std::vector; class PeepholeOptimisationMethod { public: + virtual ~PeepholeOptimisationMethod() = default; virtual size_t windowSize() const; virtual bool apply(AssemblyItems::const_iterator _in, std::back_insert_iterator _out); }; @@ -42,6 +43,7 @@ class PeepholeOptimiser { public: explicit PeepholeOptimiser(AssemblyItems& _items): m_items(_items) {} + virtual ~PeepholeOptimiser() = default; bool optimise(); diff --git a/libjulia/optimiser/ASTCopier.h b/libjulia/optimiser/ASTCopier.h index 36a1ced51..8681f2e0e 100644 --- a/libjulia/optimiser/ASTCopier.h +++ b/libjulia/optimiser/ASTCopier.h @@ -37,6 +37,7 @@ namespace julia class ExpressionCopier: public boost::static_visitor { public: + virtual ~ExpressionCopier() = default; virtual Expression operator()(Literal const& _literal) = 0; virtual Expression operator()(Identifier const& _identifier) = 0; virtual Expression operator()(FunctionalInstruction const& _instr) = 0; @@ -46,6 +47,7 @@ public: class StatementCopier: public boost::static_visitor { public: + virtual ~StatementCopier() = default; virtual Statement operator()(ExpressionStatement const& _statement) = 0; virtual Statement operator()(Instruction const& _instruction) = 0; virtual Statement operator()(Label const& _label) = 0; @@ -66,6 +68,7 @@ public: class ASTCopier: public ExpressionCopier, public StatementCopier { public: + virtual ~ASTCopier() = default; virtual Expression operator()(Literal const& _literal) override; virtual Statement operator()(Instruction const& _instruction) override; virtual Expression operator()(Identifier const& _identifier) override; diff --git a/libjulia/optimiser/ASTWalker.h b/libjulia/optimiser/ASTWalker.h index 978913813..f09c2ff1f 100644 --- a/libjulia/optimiser/ASTWalker.h +++ b/libjulia/optimiser/ASTWalker.h @@ -42,6 +42,7 @@ namespace julia class ASTWalker: public boost::static_visitor<> { public: + virtual ~ASTWalker() = default; virtual void operator()(Literal const&) {} virtual void operator()(Instruction const&) { solAssert(false, ""); } virtual void operator()(Identifier const&) {} @@ -82,6 +83,7 @@ protected: class ASTModifier: public boost::static_visitor<> { public: + virtual ~ASTModifier() = default; virtual void operator()(Literal&) {} virtual void operator()(Instruction&) { solAssert(false, ""); } virtual void operator()(Identifier&) {} diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index a53987bf5..fa0d69215 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -146,6 +146,7 @@ private: class Scopable { public: + virtual ~Scopable() = default; /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. /// Available only after name and type resolution step. ASTNode const* scope() const { return m_scope; } @@ -307,6 +308,7 @@ private: class VariableScope { public: + virtual ~VariableScope() = default; void addLocalVariable(VariableDeclaration const& _localVariable) { m_localVariables.push_back(&_localVariable); } std::vector const& localVariables() const { return m_localVariables; } @@ -320,6 +322,7 @@ private: class Documented { public: + virtual ~Documented() = default; explicit Documented(ASTPointer const& _documentation): m_documentation(_documentation) {} /// @return A shared pointer of an ASTString. @@ -336,6 +339,7 @@ protected: class ImplementationOptional { public: + virtual ~ImplementationOptional() = default; explicit ImplementationOptional(bool _implemented): m_implemented(_implemented) {} /// @return whether this node is fully implemented or not diff --git a/libsolidity/ast/ASTVisitor.h b/libsolidity/ast/ASTVisitor.h index b1389f0f1..6c0ce6f81 100644 --- a/libsolidity/ast/ASTVisitor.h +++ b/libsolidity/ast/ASTVisitor.h @@ -43,6 +43,7 @@ namespace solidity class ASTVisitor { public: + virtual ~ASTVisitor() = default; virtual bool visit(SourceUnit& _node) { return visitNode(_node); } virtual bool visit(PragmaDirective& _node) { return visitNode(_node); } virtual bool visit(ImportDirective& _node) { return visitNode(_node); } @@ -147,6 +148,7 @@ protected: class ASTConstVisitor { public: + virtual ~ASTConstVisitor() = default; virtual bool visit(SourceUnit const& _node) { return visitNode(_node); } virtual bool visit(PragmaDirective const& _node) { return visitNode(_node); } virtual bool visit(ImportDirective const& _node) { return visitNode(_node); } diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index a95366577..ca6822c98 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -138,6 +138,7 @@ private: class Type: private boost::noncopyable, public std::enable_shared_from_this { public: + virtual ~Type() = default; enum class Category { Integer, RationalNumber, StringLiteral, Bool, FixedPoint, Array, diff --git a/libsolidity/formal/SolverInterface.h b/libsolidity/formal/SolverInterface.h index e127bb551..167966847 100644 --- a/libsolidity/formal/SolverInterface.h +++ b/libsolidity/formal/SolverInterface.h @@ -193,6 +193,7 @@ DEV_SIMPLE_EXCEPTION(SolverError); class SolverInterface { public: + virtual ~SolverInterface() = default; virtual void reset() = 0; virtual void push() = 0; diff --git a/libsolidity/formal/SymbolicVariable.h b/libsolidity/formal/SymbolicVariable.h index e4e4ea8d4..e29ded269 100644 --- a/libsolidity/formal/SymbolicVariable.h +++ b/libsolidity/formal/SymbolicVariable.h @@ -40,6 +40,7 @@ public: Declaration const& _decl, smt::SolverInterface& _interface ); + virtual ~SymbolicVariable() = default; smt::Expression operator()(int _seq) const { diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index ee8da3226..4525cbf98 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -53,6 +53,7 @@ class ExecutionFramework public: ExecutionFramework(); + virtual ~ExecutionFramework() = default; virtual bytes const& compileAndRunWithoutCheck( std::string const& _sourceCode, diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index 05490a42a..a904617d5 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -52,6 +52,7 @@ protected: bool _insertVersionPragma = true, bool _allowMultipleErrors = false ); + virtual ~AnalysisFramework() = default; SourceUnit const* parseAndAnalyse(std::string const& _source); bool success(std::string const& _source);