aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/formal
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-04-30 22:30:41 +0800
committerchriseth <chris@ethereum.org>2018-05-15 20:28:08 +0800
commit4117e859eb5780873177cf1c93eb8379e17ed247 (patch)
tree037215fc1ac785a087ac3d9935b1c1aa37a187e1 /libsolidity/formal
parent2dbb35d4a8fc4321d59a670343b439232c92eaa9 (diff)
downloaddexon-solidity-4117e859eb5780873177cf1c93eb8379e17ed247.tar.gz
dexon-solidity-4117e859eb5780873177cf1c93eb8379e17ed247.tar.zst
dexon-solidity-4117e859eb5780873177cf1c93eb8379e17ed247.zip
[SMTChecker] Declaring all state vars before any function is visited
Diffstat (limited to 'libsolidity/formal')
-rw-r--r--libsolidity/formal/SMTChecker.cpp15
-rw-r--r--libsolidity/formal/SMTChecker.h2
2 files changed, 15 insertions, 2 deletions
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp
index 358f1c58..425c5c1e 100644
--- a/libsolidity/formal/SMTChecker.cpp
+++ b/libsolidity/formal/SMTChecker.cpp
@@ -58,12 +58,23 @@ void SMTChecker::analyze(SourceUnit const& _source)
_source.accept(*this);
}
+bool SMTChecker::visit(ContractDefinition const& _contract)
+{
+ for (auto _var : _contract.stateVariables())
+ if (_var->type()->isValueType())
+ createVariable(*_var);
+ return true;
+}
+
+void SMTChecker::endVisit(ContractDefinition const&)
+{
+ m_stateVariables.clear();
+}
+
void SMTChecker::endVisit(VariableDeclaration const& _varDecl)
{
if (_varDecl.isLocalVariable() && _varDecl.type()->isValueType() &&_varDecl.value())
assignment(_varDecl, *_varDecl.value(), _varDecl.location());
- else if (_varDecl.isStateVariable() && _varDecl.type()->isValueType())
- createVariable(_varDecl);
}
bool SMTChecker::visit(FunctionDefinition const& _function)
diff --git a/libsolidity/formal/SMTChecker.h b/libsolidity/formal/SMTChecker.h
index 6e64235e..50d40ab9 100644
--- a/libsolidity/formal/SMTChecker.h
+++ b/libsolidity/formal/SMTChecker.h
@@ -50,6 +50,8 @@ private:
// because the order of expression evaluation is undefined
// TODO: or just force a certain order, but people might have a different idea about that.
+ virtual bool visit(ContractDefinition const& _node) override;
+ virtual void endVisit(ContractDefinition const& _node) override;
virtual void endVisit(VariableDeclaration const& _node) override;
virtual bool visit(FunctionDefinition const& _node) override;
virtual void endVisit(FunctionDefinition const& _node) override;