diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-02 06:20:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-02 06:20:28 +0800 |
commit | 9ec3fd1632e34abf6aca9d6d3bd0ac0fcfa34f62 (patch) | |
tree | 4ea6a5b9bce5279e9d4e06c7501bff0034f9a80b /libsolidity/formal/SMTChecker.cpp | |
parent | 0f39ed6a0de880f5923541760389492349e06424 (diff) | |
parent | 90f319615f12b5a025f4cbc07ac28deb1a61899d (diff) | |
download | dexon-solidity-9ec3fd1632e34abf6aca9d6d3bd0ac0fcfa34f62.tar.gz dexon-solidity-9ec3fd1632e34abf6aca9d6d3bd0ac0fcfa34f62.tar.zst dexon-solidity-9ec3fd1632e34abf6aca9d6d3bd0ac0fcfa34f62.zip |
Merge pull request #4646 from ethereum/smt_model_secondary_location
SMT model is sorted and printed as secondary location
Diffstat (limited to 'libsolidity/formal/SMTChecker.cpp')
-rw-r--r-- | libsolidity/formal/SMTChecker.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index 109c8dbe..17b50a38 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -252,14 +252,14 @@ void SMTChecker::checkUnderOverflow(smt::Expression _value, IntegerType const& _ _value < SymbolicIntVariable::minValue(_type), _location, "Underflow (resulting value less than " + formatNumber(_type.minValue()) + ")", - "value", + "<result>", &_value ); checkCondition( _value > SymbolicIntVariable::maxValue(_type), _location, "Overflow (resulting value larger than " + formatNumber(_type.maxValue()) + ")", - "value", + "<result>", &_value ); } @@ -437,7 +437,7 @@ void SMTChecker::arithmeticOperation(BinaryOperation const& _op) if (_op.getOperator() == Token::Div) { - checkCondition(right == 0, _op.location(), "Division by zero", "value", &right); + checkCondition(right == 0, _op.location(), "Division by zero", "<result>", &right); m_interface->addAssertion(right != 0); } @@ -601,15 +601,23 @@ void SMTChecker::checkCondition( message << _description << " happens here"; if (m_currentFunction) { - message << " for:\n"; + std::ostringstream modelMessage; + modelMessage << " for:\n"; solAssert(values.size() == expressionNames.size(), ""); + map<string, string> sortedModel; for (size_t i = 0; i < values.size(); ++i) if (expressionsToEvaluate.at(i).name != values.at(i)) - message << " " << expressionNames.at(i) << " = " << values.at(i) << "\n"; + sortedModel[expressionNames.at(i)] = values.at(i); + + for (auto const& eval: sortedModel) + modelMessage << " " << eval.first << " = " << eval.second << "\n"; + m_errorReporter.warning(_location, message.str() + loopComment, SecondarySourceLocation().append(modelMessage.str(), SourceLocation())); } else + { message << "."; - m_errorReporter.warning(_location, message.str() + loopComment); + m_errorReporter.warning(_location, message.str() + loopComment); + } break; } case smt::CheckResult::UNSATISFIABLE: |