SMT model variables are sorted and printed as secondary source location

This commit is contained in:
Leonardo Alt 2018-08-01 23:27:46 +02:00
parent b6a2655513
commit 90f319615f
2 changed files with 12 additions and 4 deletions

View File

@ -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:

View File

@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(simple_assert)
function f(uint a) public pure { assert(a == 2); }
}
)";
CHECK_WARNING(text, "Assertion violation happens here for");
CHECK_WARNING(text, "Assertion violation happens here");
}
BOOST_AUTO_TEST_CASE(simple_assert_with_require)