mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix code style problems
This commit is contained in:
parent
8ea8a1eb99
commit
92689e4256
@ -22,7 +22,7 @@
|
|||||||
#include <libsolutil/StringUtils.h>
|
#include <libsolutil/StringUtils.h>
|
||||||
#include <libsolutil/Visitor.h>
|
#include <libsolutil/Visitor.h>
|
||||||
|
|
||||||
#include "liblangutil/Common.h"
|
#include <liblangutil/Common.h>
|
||||||
|
|
||||||
|
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
@ -107,7 +107,8 @@ std::tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Inte
|
|||||||
// TODO proper parsing
|
// TODO proper parsing
|
||||||
if (boost::starts_with(response, "sat"))
|
if (boost::starts_with(response, "sat"))
|
||||||
result = CheckResult::UNSATISFIABLE;
|
result = CheckResult::UNSATISFIABLE;
|
||||||
else if (boost::starts_with(response, "unsat")) {
|
else if (boost::starts_with(response, "unsat"))
|
||||||
|
{
|
||||||
result = CheckResult::SATISFIABLE;
|
result = CheckResult::SATISFIABLE;
|
||||||
return {result, Expression(true), graphFromZ3Proof(response)};
|
return {result, Expression(true), graphFromZ3Proof(response)};
|
||||||
}
|
}
|
||||||
@ -201,7 +202,8 @@ std::string CHCSmtLib2Interface::querySolver(std::string const& _input)
|
|||||||
auto result = m_smtCallback(ReadCallback::kindString(ReadCallback::Kind::SMTQuery) + " " + solverBinary, _input);
|
auto result = m_smtCallback(ReadCallback::kindString(ReadCallback::Kind::SMTQuery) + " " + solverBinary, _input);
|
||||||
if (result.success)
|
if (result.success)
|
||||||
{
|
{
|
||||||
if (m_enabledSolvers.z3 and boost::starts_with(result.responseOrErrorMessage, "unsat")) {
|
if (m_enabledSolvers.z3 and boost::starts_with(result.responseOrErrorMessage, "unsat"))
|
||||||
|
{
|
||||||
solverBinary += " fp.xform.slice=false fp.xform.inline_linear=false fp.xform.inline_eager=false";
|
solverBinary += " fp.xform.slice=false fp.xform.inline_linear=false fp.xform.inline_eager=false";
|
||||||
std::string extendedQuery = "(set-option :produce-proofs true)" + _input + "\n(get-proof)";
|
std::string extendedQuery = "(set-option :produce-proofs true)" + _input + "\n(get-proof)";
|
||||||
auto secondResult = m_smtCallback(ReadCallback::kindString(ReadCallback::Kind::SMTQuery) + " " + solverBinary, extendedQuery);
|
auto secondResult = m_smtCallback(ReadCallback::kindString(ReadCallback::Kind::SMTQuery) + " " + solverBinary, extendedQuery);
|
||||||
@ -257,7 +259,8 @@ std::string CHCSmtLib2Interface::SMTLib2Expression::toString() const
|
|||||||
}, data);
|
}, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
using SMTLib2Expression = CHCSmtLib2Interface::SMTLib2Expression;
|
using SMTLib2Expression = CHCSmtLib2Interface::SMTLib2Expression;
|
||||||
bool isNumber(std::string const& _expr)
|
bool isNumber(std::string const& _expr)
|
||||||
{
|
{
|
||||||
@ -270,7 +273,7 @@ namespace {
|
|||||||
bool isAtom(SMTLib2Expression const & expr)
|
bool isAtom(SMTLib2Expression const & expr)
|
||||||
{
|
{
|
||||||
return std::holds_alternative<std::string>(expr.data);
|
return std::holds_alternative<std::string>(expr.data);
|
||||||
};
|
}
|
||||||
|
|
||||||
std::string const& asAtom(SMTLib2Expression const& expr)
|
std::string const& asAtom(SMTLib2Expression const& expr)
|
||||||
{
|
{
|
||||||
@ -293,7 +296,8 @@ namespace {
|
|||||||
|
|
||||||
SortPointer toSort(SMTLib2Expression const& expr)
|
SortPointer toSort(SMTLib2Expression const& expr)
|
||||||
{
|
{
|
||||||
if (isAtom(expr)) {
|
if (isAtom(expr))
|
||||||
|
{
|
||||||
auto const& name = asAtom(expr);
|
auto const& name = asAtom(expr);
|
||||||
if (name == "Int")
|
if (name == "Int")
|
||||||
return SortProvider::sintSort;
|
return SortProvider::sintSort;
|
||||||
@ -307,7 +311,8 @@ namespace {
|
|||||||
return std::make_shared<Sort>(*it->first);
|
return std::make_shared<Sort>(*it->first);
|
||||||
} else {
|
} else {
|
||||||
auto const& args = asSubExpressions(expr);
|
auto const& args = asSubExpressions(expr);
|
||||||
if (asAtom(args[0]) == "Array") {
|
if (asAtom(args[0]) == "Array")
|
||||||
|
{
|
||||||
assert(args.size() == 3);
|
assert(args.size() == 3);
|
||||||
auto domainSort = toSort(args[1]);
|
auto domainSort = toSort(args[1]);
|
||||||
auto codomainSort = toSort(args[2]);
|
auto codomainSort = toSort(args[2]);
|
||||||
@ -333,13 +338,14 @@ namespace {
|
|||||||
[&](std::vector<SMTLib2Expression> const& _subExpr) {
|
[&](std::vector<SMTLib2Expression> const& _subExpr) {
|
||||||
SortPointer sort;
|
SortPointer sort;
|
||||||
std::vector<smtutil::Expression> arguments;
|
std::vector<smtutil::Expression> arguments;
|
||||||
if (isAtom(_subExpr.front())) {
|
if (isAtom(_subExpr.front()))
|
||||||
|
{
|
||||||
std::string const& op = std::get<std::string>(_subExpr.front().data);
|
std::string const& op = std::get<std::string>(_subExpr.front().data);
|
||||||
std::set<std::string> boolOperators{"and", "or", "not", "=", "<", ">", "<=", ">=", "=>"};
|
std::set<std::string> boolOperators{"and", "or", "not", "=", "<", ">", "<=", ">=", "=>"};
|
||||||
for (size_t i = 1; i < _subExpr.size(); i++)
|
for (size_t i = 1; i < _subExpr.size(); i++)
|
||||||
arguments.emplace_back(toSMTUtilExpression(_subExpr[i]));
|
arguments.emplace_back(toSMTUtilExpression(_subExpr[i]));
|
||||||
sort = contains(boolOperators, op) ? SortProvider::boolSort : arguments.back().sort;
|
sort = contains(boolOperators, op) ? SortProvider::boolSort : arguments.back().sort;
|
||||||
return smtutil::Expression(op, move(arguments), move(sort));
|
return smtutil::Expression(op, std::move(arguments), std::move(sort));
|
||||||
} else {
|
} else {
|
||||||
// check for const array
|
// check for const array
|
||||||
if (_subExpr.size() == 2 and !isAtom(_subExpr[0]))
|
if (_subExpr.size() == 2 and !isAtom(_subExpr[0]))
|
||||||
@ -387,7 +393,7 @@ namespace {
|
|||||||
// simulate whitespace because we do not want to read the next token
|
// simulate whitespace because we do not want to read the next token
|
||||||
// since it might block.
|
// since it might block.
|
||||||
m_token = ' ';
|
m_token = ' ';
|
||||||
return {move(subExpressions)};
|
return {std::move(subExpressions)};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return {parseToken()};
|
return {parseToken()};
|
||||||
@ -632,7 +638,8 @@ CHCSolverInterface::CexGraph CHCSmtLib2Interface::graphFromSMTLib2Expression(SMT
|
|||||||
return graph;
|
return graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHCSolverInterface::CexGraph CHCSmtLib2Interface::graphFromZ3Proof(const std::string & _proof) {
|
CHCSolverInterface::CexGraph CHCSmtLib2Interface::graphFromZ3Proof(std::string const& _proof)
|
||||||
|
{
|
||||||
std::stringstream ss(_proof);
|
std::stringstream ss(_proof);
|
||||||
std::string answer;
|
std::string answer;
|
||||||
ss >> answer;
|
ss >> answer;
|
||||||
@ -646,9 +653,11 @@ CHCSolverInterface::CexGraph CHCSmtLib2Interface::graphFromZ3Proof(const std::st
|
|||||||
auto& commands = std::get<SMTLib2Expression::args_t>(all.data);
|
auto& commands = std::get<SMTLib2Expression::args_t>(all.data);
|
||||||
for (auto& command: commands) {
|
for (auto& command: commands) {
|
||||||
// std::cout << command.toString() << '\n' << std::endl;
|
// std::cout << command.toString() << '\n' << std::endl;
|
||||||
if (!isAtom(command)) {
|
if (!isAtom(command))
|
||||||
|
{
|
||||||
auto const& head = std::get<SMTLib2Expression::args_t>(command.data)[0];
|
auto const& head = std::get<SMTLib2Expression::args_t>(command.data)[0];
|
||||||
if (isAtom(head) && std::get<std::string>(head.data) == "proof") {
|
if (isAtom(head) && std::get<std::string>(head.data) == "proof")
|
||||||
|
{
|
||||||
// std::cout << "Proof expression!\n" << command.toString() << std::endl;
|
// std::cout << "Proof expression!\n" << command.toString() << std::endl;
|
||||||
inlineLetExpressions(command);
|
inlineLetExpressions(command);
|
||||||
// std::cout << "Cleaned Proof expression!\n" << command.toString() << std::endl;
|
// std::cout << "Cleaned Proof expression!\n" << command.toString() << std::endl;
|
||||||
|
@ -115,7 +115,8 @@ void SMTLib2Interface::addAssertion(Expression const& _expr)
|
|||||||
write("(assert " + toSExpr(_expr) + ")");
|
write("(assert " + toSExpr(_expr) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace { // Helpers for querying solvers using SMT callback
|
namespace // Helpers for querying solvers using SMT callback
|
||||||
|
{
|
||||||
auto resultFromSolverResponse (std::string const& response) {
|
auto resultFromSolverResponse (std::string const& response) {
|
||||||
CheckResult result;
|
CheckResult result;
|
||||||
// TODO proper parsing
|
// TODO proper parsing
|
||||||
@ -159,8 +160,7 @@ namespace { // Helpers for querying solvers using SMT callback
|
|||||||
|
|
||||||
std::pair<CheckResult, std::vector<std::string>> SMTLib2Interface::check(std::vector<Expression> const& _expressionsToEvaluate)
|
std::pair<CheckResult, std::vector<std::string>> SMTLib2Interface::check(std::vector<Expression> const& _expressionsToEvaluate)
|
||||||
{
|
{
|
||||||
auto query = boost::algorithm::join(m_accumulatedOutput, "\n") +
|
auto query = boost::algorithm::join(m_accumulatedOutput, "\n") + checkSatAndGetValuesCommand(_expressionsToEvaluate);
|
||||||
checkSatAndGetValuesCommand(_expressionsToEvaluate);
|
|
||||||
|
|
||||||
std::vector<std::string> solverCommands;
|
std::vector<std::string> solverCommands;
|
||||||
if (m_enabledSolvers.z3)
|
if (m_enabledSolvers.z3)
|
||||||
@ -195,9 +195,8 @@ std::pair<CheckResult, std::vector<std::string>> SMTLib2Interface::check(std::ve
|
|||||||
else if (result == CheckResult::UNKNOWN && lastResult == CheckResult::ERROR)
|
else if (result == CheckResult::UNKNOWN && lastResult == CheckResult::ERROR)
|
||||||
lastResult = result;
|
lastResult = result;
|
||||||
}
|
}
|
||||||
if (lastResult == CheckResult::ERROR) {
|
if (lastResult == CheckResult::ERROR)
|
||||||
m_unhandledQueries.push_back(query);
|
m_unhandledQueries.push_back(query);
|
||||||
}
|
|
||||||
return std::make_pair(lastResult, finalValues);
|
return std::make_pair(lastResult, finalValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user