From f41591b3ddfd3e5c065271058dadb3c6b7f31bbb Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 17 Jan 2018 21:02:23 +0100 Subject: [SMTChecker] A little refactoring on SSA vars --- libsolidity/formal/SymbolicIntVariable.h | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 libsolidity/formal/SymbolicIntVariable.h (limited to 'libsolidity/formal/SymbolicIntVariable.h') diff --git a/libsolidity/formal/SymbolicIntVariable.h b/libsolidity/formal/SymbolicIntVariable.h new file mode 100644 index 00000000..efe05af8 --- /dev/null +++ b/libsolidity/formal/SymbolicIntVariable.h @@ -0,0 +1,51 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ + +#pragma once + +#include + +#include + +namespace dev +{ +namespace solidity +{ + +/** + * Specialization of SymbolicVariable for Integers + */ +class SymbolicIntVariable : public SymbolicVariable +{ +public: + explicit SymbolicIntVariable(Declaration const* _decl, + smt::SolverInterface& _interface); + SymbolicIntVariable(SymbolicIntVariable const&) = default; + SymbolicIntVariable(SymbolicIntVariable&&) = default; + SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default; + SymbolicIntVariable& operator=(SymbolicIntVariable&&) = default; + + void setZeroValue(int _seq); + void setUnknownValue(int _seq); + +private: + smt::Expression minValue(IntegerType const& _t) const; + smt::Expression maxValue(IntegerType const& _t) const; +}; + +} +} -- cgit From 3b2851ee4163bcfbca9e4e23650dfeee1a06653a Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Sat, 17 Feb 2018 09:34:38 +0100 Subject: Integer min and max values placed under SymbolicIntVar instead of SMTChecker --- libsolidity/formal/SymbolicIntVariable.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libsolidity/formal/SymbolicIntVariable.h') diff --git a/libsolidity/formal/SymbolicIntVariable.h b/libsolidity/formal/SymbolicIntVariable.h index efe05af8..0066bb75 100644 --- a/libsolidity/formal/SymbolicIntVariable.h +++ b/libsolidity/formal/SymbolicIntVariable.h @@ -39,12 +39,13 @@ public: SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default; SymbolicIntVariable& operator=(SymbolicIntVariable&&) = default; + /// Sets the var to 0. void setZeroValue(int _seq); + /// Sets the valid interval for the var. void setUnknownValue(int _seq); -private: - smt::Expression minValue(IntegerType const& _t) const; - smt::Expression maxValue(IntegerType const& _t) const; + static smt::Expression minValue(IntegerType const& _t); + static smt::Expression maxValue(IntegerType const& _t); }; } -- cgit From cff0836c032ecee2710f1c17c49eec0a3b4aa9fc Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 28 Feb 2018 18:00:13 +0100 Subject: Fix PR comments --- libsolidity/formal/SymbolicIntVariable.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libsolidity/formal/SymbolicIntVariable.h') diff --git a/libsolidity/formal/SymbolicIntVariable.h b/libsolidity/formal/SymbolicIntVariable.h index 0066bb75..8a9b5d5d 100644 --- a/libsolidity/formal/SymbolicIntVariable.h +++ b/libsolidity/formal/SymbolicIntVariable.h @@ -29,11 +29,13 @@ namespace solidity /** * Specialization of SymbolicVariable for Integers */ -class SymbolicIntVariable : public SymbolicVariable +class SymbolicIntVariable: public SymbolicVariable { public: - explicit SymbolicIntVariable(Declaration const* _decl, - smt::SolverInterface& _interface); + SymbolicIntVariable( + Declaration const* _decl, + smt::SolverInterface& _interface + ); SymbolicIntVariable(SymbolicIntVariable const&) = default; SymbolicIntVariable(SymbolicIntVariable&&) = default; SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default; @@ -41,7 +43,7 @@ public: /// Sets the var to 0. void setZeroValue(int _seq); - /// Sets the valid interval for the var. + /// Sets the variable to the full valid value range. void setUnknownValue(int _seq); static smt::Expression minValue(IntegerType const& _t); -- cgit From 8b1b4b78c043d54f493dc9e2330bf9df5cf93755 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 28 Feb 2018 18:31:11 +0100 Subject: Fix PR comments --- libsolidity/formal/SymbolicIntVariable.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'libsolidity/formal/SymbolicIntVariable.h') diff --git a/libsolidity/formal/SymbolicIntVariable.h b/libsolidity/formal/SymbolicIntVariable.h index 8a9b5d5d..afa25f1b 100644 --- a/libsolidity/formal/SymbolicIntVariable.h +++ b/libsolidity/formal/SymbolicIntVariable.h @@ -36,10 +36,6 @@ public: Declaration const* _decl, smt::SolverInterface& _interface ); - SymbolicIntVariable(SymbolicIntVariable const&) = default; - SymbolicIntVariable(SymbolicIntVariable&&) = default; - SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default; - SymbolicIntVariable& operator=(SymbolicIntVariable&&) = default; /// Sets the var to 0. void setZeroValue(int _seq); -- cgit