mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Refactor VariableUsage
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user