31
31
#include < memory>
32
32
#include < stdexcept>
33
33
34
- using namespace std ;
35
34
using namespace solidity ;
36
35
using namespace solidity ::util;
37
36
using namespace solidity ::frontend;
38
37
using namespace solidity ::smtutil;
39
38
40
39
CHCSmtLib2Interface::CHCSmtLib2Interface (
41
- map<h256, string> const & _queryResponses,
40
+ std:: map<h256, std:: string> const & _queryResponses,
42
41
ReadCallback::Callback _smtCallback,
43
42
SMTSolverChoice _enabledSolvers,
44
- optional<unsigned > _queryTimeout
43
+ std:: optional<unsigned > _queryTimeout
45
44
):
46
45
CHCSolverInterface(_queryTimeout),
47
- m_smtlib2(make_unique<SMTLib2Interface>(_queryResponses, _smtCallback, m_queryTimeout)),
46
+ m_smtlib2(std:: make_unique<SMTLib2Interface>(_queryResponses, _smtCallback, m_queryTimeout)),
48
47
m_queryResponses(std::move(_queryResponses)),
49
48
m_smtCallback(_smtCallback),
50
49
m_enabledSolvers(_enabledSolvers)
@@ -66,8 +65,8 @@ void CHCSmtLib2Interface::registerRelation(Expression const& _expr)
66
65
smtAssert (_expr.sort ->kind == Kind::Function);
67
66
if (!m_variables.count (_expr.name ))
68
67
{
69
- auto fSort = dynamic_pointer_cast<FunctionSort>(_expr.sort );
70
- string domain = toSmtLibSort (fSort ->domain );
68
+ auto fSort = std:: dynamic_pointer_cast<FunctionSort>(_expr.sort );
69
+ std:: string domain = toSmtLibSort (fSort ->domain );
71
70
// Relations are predicates which have implicit codomain Bool.
72
71
m_variables.insert (_expr.name );
73
72
write (
@@ -89,10 +88,10 @@ void CHCSmtLib2Interface::addRule(Expression const& _expr, std::string const& /*
89
88
);
90
89
}
91
90
92
- tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query (Expression const & _block)
91
+ std:: tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query (Expression const & _block)
93
92
{
94
- string query = dumpQuery (_block);
95
- string response = querySolver (query);
93
+ std:: string query = dumpQuery (_block);
94
+ std:: string response = querySolver (query);
96
95
97
96
CheckResult result;
98
97
// TODO proper parsing
@@ -108,7 +107,7 @@ tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface
108
107
return {result, Expression (true ), {}};
109
108
}
110
109
111
- void CHCSmtLib2Interface::declareVariable (string const & _name, SortPointer const & _sort)
110
+ void CHCSmtLib2Interface::declareVariable (std:: string const & _name, SortPointer const & _sort)
112
111
{
113
112
smtAssert (_sort);
114
113
if (_sort->kind == Kind::Function)
@@ -120,25 +119,25 @@ void CHCSmtLib2Interface::declareVariable(string const& _name, SortPointer const
120
119
}
121
120
}
122
121
123
- string CHCSmtLib2Interface::toSmtLibSort (Sort const & _sort)
122
+ std:: string CHCSmtLib2Interface::toSmtLibSort (Sort const & _sort)
124
123
{
125
124
if (!m_sortNames.count (&_sort))
126
125
m_sortNames[&_sort] = m_smtlib2->toSmtLibSort (_sort);
127
126
return m_sortNames.at (&_sort);
128
127
}
129
128
130
- string CHCSmtLib2Interface::toSmtLibSort (vector<SortPointer> const & _sorts)
129
+ std:: string CHCSmtLib2Interface::toSmtLibSort (std:: vector<SortPointer> const & _sorts)
131
130
{
132
- string ssort (" (" );
131
+ std:: string ssort (" (" );
133
132
for (auto const & sort: _sorts)
134
133
ssort += toSmtLibSort (*sort) + " " ;
135
134
ssort += " )" ;
136
135
return ssort;
137
136
}
138
137
139
- string CHCSmtLib2Interface::forall ()
138
+ std:: string CHCSmtLib2Interface::forall ()
140
139
{
141
- string vars (" (" );
140
+ std:: string vars (" (" );
142
141
for (auto const & [name, sort]: m_smtlib2->variables ())
143
142
{
144
143
solAssert (sort, " " );
@@ -149,17 +148,17 @@ string CHCSmtLib2Interface::forall()
149
148
return vars;
150
149
}
151
150
152
- void CHCSmtLib2Interface::declareFunction (string const & _name, SortPointer const & _sort)
151
+ void CHCSmtLib2Interface::declareFunction (std:: string const & _name, SortPointer const & _sort)
153
152
{
154
153
smtAssert (_sort);
155
154
smtAssert (_sort->kind == Kind::Function);
156
155
// TODO Use domain and codomain as key as well
157
156
if (!m_variables.count (_name))
158
157
{
159
- auto fSort = dynamic_pointer_cast<FunctionSort>(_sort);
158
+ auto fSort = std:: dynamic_pointer_cast<FunctionSort>(_sort);
160
159
smtAssert (fSort ->codomain );
161
- string domain = toSmtLibSort (fSort ->domain );
162
- string codomain = toSmtLibSort (*fSort ->codomain );
160
+ std:: string domain = toSmtLibSort (fSort ->domain );
161
+ std:: string codomain = toSmtLibSort (*fSort ->codomain );
163
162
m_variables.insert (_name);
164
163
write (
165
164
" (declare-fun |" +
@@ -173,12 +172,12 @@ void CHCSmtLib2Interface::declareFunction(string const& _name, SortPointer const
173
172
}
174
173
}
175
174
176
- void CHCSmtLib2Interface::write (string _data)
175
+ void CHCSmtLib2Interface::write (std:: string _data)
177
176
{
178
177
m_accumulatedOutput += std::move (_data) + " \n " ;
179
178
}
180
179
181
- string CHCSmtLib2Interface::querySolver (string const & _input)
180
+ std:: string CHCSmtLib2Interface::querySolver (std:: string const & _input)
182
181
{
183
182
util::h256 inputHash = util::keccak256 (_input);
184
183
if (m_queryResponses.count (inputHash))
@@ -212,7 +211,7 @@ std::string CHCSmtLib2Interface::dumpQuery(Expression const& _expr)
212
211
std::string CHCSmtLib2Interface::createHeaderAndDeclarations () {
213
212
std::stringstream s;
214
213
if (m_queryTimeout)
215
- s << " (set-option :timeout " + to_string (*m_queryTimeout) + " )\n " ;
214
+ s << " (set-option :timeout " + std:: to_string (*m_queryTimeout) + " )\n " ;
216
215
s << " (set-logic HORN)" << std::endl;
217
216
218
217
for (auto const & decl: m_smtlib2->userSorts () | ranges::views::values)
0 commit comments