[SMTChecker] Refactor VariableUsage

This commit is contained in:
Leonardo Alt
2019-04-05 11:38:37 +02:00
parent a7ff3e42ea
commit 79d8a4e13a
10 changed files with 244 additions and 100 deletions
+16 -14
View File
@@ -17,33 +17,35 @@
#pragma once
#include <map>
#include <set>
#include <libsolidity/ast/ASTVisitor.h>
#include <vector>
#include <set>
namespace dev
{
namespace solidity
{
class ASTNode;
class VariableDeclaration;
/**
* This class collects information about which local variables of value type
* are modified in which parts of the AST.
* This class computes information about which variables are modified in a certain subtree.
*/
class VariableUsage
class VariableUsage: private ASTConstVisitor
{
public:
explicit VariableUsage(ASTNode const& _node);
std::vector<VariableDeclaration const*> touchedVariables(ASTNode const& _node) const;
/// @param _outerCallstack the current callstack in the callers context.
std::set<VariableDeclaration const*> touchedVariables(ASTNode const& _node, std::vector<FunctionDefinition const*> const& _outerCallstack);
private:
// Variable touched by a specific AST node.
std::map<ASTNode const*, VariableDeclaration const*> m_touchedVariable;
std::map<ASTNode const*, std::vector<ASTNode const*>> m_children;
void endVisit(Identifier const& _node) override;
void endVisit(FunctionCall const& _node) override;
bool visit(FunctionDefinition const& _node) override;
void endVisit(FunctionDefinition const& _node) override;
void endVisit(ModifierInvocation const& _node) override;
void endVisit(PlaceholderStatement const& _node) override;
std::set<VariableDeclaration const*> m_touchedVariables;
std::vector<FunctionDefinition const*> m_functionPath;
};
}