Skip to content

Commit

Permalink
Merge pull request ethereum#4040 from aarlt/virtual-destructors
Browse files Browse the repository at this point in the history
Add virtual destructors on base classes.
  • Loading branch information
chriseth authored May 2, 2018
2 parents 5cce2e5 + f94b793 commit dc18cde
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions libevmasm/ConstantOptimiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ConstantOptimisationMethod

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.
Expand Down
2 changes: 2 additions & 0 deletions libevmasm/PeepholeOptimiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using AssemblyItems = std::vector<AssemblyItem>;
class PeepholeOptimisationMethod
{
public:
virtual ~PeepholeOptimisationMethod() = default;
virtual size_t windowSize() const;
virtual bool apply(AssemblyItems::const_iterator _in, std::back_insert_iterator<AssemblyItems> _out);
};
Expand All @@ -42,6 +43,7 @@ class PeepholeOptimiser
{
public:
explicit PeepholeOptimiser(AssemblyItems& _items): m_items(_items) {}
virtual ~PeepholeOptimiser() = default;

bool optimise();

Expand Down
3 changes: 3 additions & 0 deletions libjulia/optimiser/ASTCopier.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace julia
class ExpressionCopier: public boost::static_visitor<Expression>
{
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;
Expand All @@ -46,6 +47,7 @@ class ExpressionCopier: public boost::static_visitor<Expression>
class StatementCopier: public boost::static_visitor<Statement>
{
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;
Expand All @@ -66,6 +68,7 @@ class StatementCopier: public boost::static_visitor<Statement>
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;
Expand Down
2 changes: 2 additions & 0 deletions libjulia/optimiser/ASTWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&) {}
Expand Down Expand Up @@ -82,6 +83,7 @@ class ASTWalker: public boost::static_visitor<>
class ASTModifier: public boost::static_visitor<>
{
public:
virtual ~ASTModifier() = default;
virtual void operator()(Literal&) {}
virtual void operator()(Instruction&) { solAssert(false, ""); }
virtual void operator()(Identifier&) {}
Expand Down
4 changes: 4 additions & 0 deletions libsolidity/ast/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class SourceUnit: public ASTNode
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; }
Expand Down Expand Up @@ -307,6 +308,7 @@ class ImportDirective: public Declaration
class VariableScope
{
public:
virtual ~VariableScope() = default;
void addLocalVariable(VariableDeclaration const& _localVariable) { m_localVariables.push_back(&_localVariable); }
std::vector<VariableDeclaration const*> const& localVariables() const { return m_localVariables; }

Expand All @@ -320,6 +322,7 @@ class VariableScope
class Documented
{
public:
virtual ~Documented() = default;
explicit Documented(ASTPointer<ASTString> const& _documentation): m_documentation(_documentation) {}

/// @return A shared pointer of an ASTString.
Expand All @@ -336,6 +339,7 @@ class Documented
class ImplementationOptional
{
public:
virtual ~ImplementationOptional() = default;
explicit ImplementationOptional(bool _implemented): m_implemented(_implemented) {}

/// @return whether this node is fully implemented or not
Expand Down
2 changes: 2 additions & 0 deletions libsolidity/ast/ASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down Expand Up @@ -147,6 +148,7 @@ class ASTVisitor
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); }
Expand Down
1 change: 1 addition & 0 deletions libsolidity/ast/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class MemberList
class Type: private boost::noncopyable, public std::enable_shared_from_this<Type>
{
public:
virtual ~Type() = default;
enum class Category
{
Integer, RationalNumber, StringLiteral, Bool, FixedPoint, Array,
Expand Down
1 change: 1 addition & 0 deletions libsolidity/formal/SolverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ DEV_SIMPLE_EXCEPTION(SolverError);
class SolverInterface
{
public:
virtual ~SolverInterface() = default;
virtual void reset() = 0;

virtual void push() = 0;
Expand Down
1 change: 1 addition & 0 deletions libsolidity/formal/SymbolicVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SymbolicVariable
Declaration const& _decl,
smt::SolverInterface& _interface
);
virtual ~SymbolicVariable() = default;

smt::Expression operator()(int _seq) const
{
Expand Down
1 change: 1 addition & 0 deletions test/ExecutionFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ExecutionFramework

public:
ExecutionFramework();
virtual ~ExecutionFramework() = default;

virtual bytes const& compileAndRunWithoutCheck(
std::string const& _sourceCode,
Expand Down
1 change: 1 addition & 0 deletions test/libsolidity/AnalysisFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AnalysisFramework
bool _insertVersionPragma = true,
bool _allowMultipleErrors = false
);
virtual ~AnalysisFramework() = default;

SourceUnit const* parseAndAnalyse(std::string const& _source);
bool success(std::string const& _source);
Expand Down

0 comments on commit dc18cde

Please sign in to comment.