Skip to content

Commit 62723b7

Browse files
committed
Purge using namespace std in libsmtutil and libsolc
1 parent 1ac883b commit 62723b7

File tree

10 files changed

+145
-153
lines changed

10 files changed

+145
-153
lines changed

libsmtutil/CHCSmtLib2Interface.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,19 @@
3131
#include <memory>
3232
#include <stdexcept>
3333

34-
using namespace std;
3534
using namespace solidity;
3635
using namespace solidity::util;
3736
using namespace solidity::frontend;
3837
using namespace solidity::smtutil;
3938

4039
CHCSmtLib2Interface::CHCSmtLib2Interface(
41-
map<h256, string> const& _queryResponses,
40+
std::map<h256, std::string> const& _queryResponses,
4241
ReadCallback::Callback _smtCallback,
4342
SMTSolverChoice _enabledSolvers,
44-
optional<unsigned> _queryTimeout
43+
std::optional<unsigned> _queryTimeout
4544
):
4645
CHCSolverInterface(_queryTimeout),
47-
m_smtlib2(make_unique<SMTLib2Interface>(_queryResponses, _smtCallback, m_queryTimeout)),
46+
m_smtlib2(std::make_unique<SMTLib2Interface>(_queryResponses, _smtCallback, m_queryTimeout)),
4847
m_queryResponses(std::move(_queryResponses)),
4948
m_smtCallback(_smtCallback),
5049
m_enabledSolvers(_enabledSolvers)
@@ -66,8 +65,8 @@ void CHCSmtLib2Interface::registerRelation(Expression const& _expr)
6665
smtAssert(_expr.sort->kind == Kind::Function);
6766
if (!m_variables.count(_expr.name))
6867
{
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);
7170
// Relations are predicates which have implicit codomain Bool.
7271
m_variables.insert(_expr.name);
7372
write(
@@ -89,10 +88,10 @@ void CHCSmtLib2Interface::addRule(Expression const& _expr, std::string const& /*
8988
);
9089
}
9190

92-
tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query(Expression const& _block)
91+
std::tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query(Expression const& _block)
9392
{
94-
string query = dumpQuery(_block);
95-
string response = querySolver(query);
93+
std::string query = dumpQuery(_block);
94+
std::string response = querySolver(query);
9695

9796
CheckResult result;
9897
// TODO proper parsing
@@ -108,7 +107,7 @@ tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface
108107
return {result, Expression(true), {}};
109108
}
110109

111-
void CHCSmtLib2Interface::declareVariable(string const& _name, SortPointer const& _sort)
110+
void CHCSmtLib2Interface::declareVariable(std::string const& _name, SortPointer const& _sort)
112111
{
113112
smtAssert(_sort);
114113
if (_sort->kind == Kind::Function)
@@ -120,25 +119,25 @@ void CHCSmtLib2Interface::declareVariable(string const& _name, SortPointer const
120119
}
121120
}
122121

123-
string CHCSmtLib2Interface::toSmtLibSort(Sort const& _sort)
122+
std::string CHCSmtLib2Interface::toSmtLibSort(Sort const& _sort)
124123
{
125124
if (!m_sortNames.count(&_sort))
126125
m_sortNames[&_sort] = m_smtlib2->toSmtLibSort(_sort);
127126
return m_sortNames.at(&_sort);
128127
}
129128

130-
string CHCSmtLib2Interface::toSmtLibSort(vector<SortPointer> const& _sorts)
129+
std::string CHCSmtLib2Interface::toSmtLibSort(std::vector<SortPointer> const& _sorts)
131130
{
132-
string ssort("(");
131+
std::string ssort("(");
133132
for (auto const& sort: _sorts)
134133
ssort += toSmtLibSort(*sort) + " ";
135134
ssort += ")";
136135
return ssort;
137136
}
138137

139-
string CHCSmtLib2Interface::forall()
138+
std::string CHCSmtLib2Interface::forall()
140139
{
141-
string vars("(");
140+
std::string vars("(");
142141
for (auto const& [name, sort]: m_smtlib2->variables())
143142
{
144143
solAssert(sort, "");
@@ -149,17 +148,17 @@ string CHCSmtLib2Interface::forall()
149148
return vars;
150149
}
151150

152-
void CHCSmtLib2Interface::declareFunction(string const& _name, SortPointer const& _sort)
151+
void CHCSmtLib2Interface::declareFunction(std::string const& _name, SortPointer const& _sort)
153152
{
154153
smtAssert(_sort);
155154
smtAssert(_sort->kind == Kind::Function);
156155
// TODO Use domain and codomain as key as well
157156
if (!m_variables.count(_name))
158157
{
159-
auto fSort = dynamic_pointer_cast<FunctionSort>(_sort);
158+
auto fSort = std::dynamic_pointer_cast<FunctionSort>(_sort);
160159
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);
163162
m_variables.insert(_name);
164163
write(
165164
"(declare-fun |" +
@@ -173,12 +172,12 @@ void CHCSmtLib2Interface::declareFunction(string const& _name, SortPointer const
173172
}
174173
}
175174

176-
void CHCSmtLib2Interface::write(string _data)
175+
void CHCSmtLib2Interface::write(std::string _data)
177176
{
178177
m_accumulatedOutput += std::move(_data) + "\n";
179178
}
180179

181-
string CHCSmtLib2Interface::querySolver(string const& _input)
180+
std::string CHCSmtLib2Interface::querySolver(std::string const& _input)
182181
{
183182
util::h256 inputHash = util::keccak256(_input);
184183
if (m_queryResponses.count(inputHash))
@@ -212,7 +211,7 @@ std::string CHCSmtLib2Interface::dumpQuery(Expression const& _expr)
212211
std::string CHCSmtLib2Interface::createHeaderAndDeclarations() {
213212
std::stringstream s;
214213
if (m_queryTimeout)
215-
s << "(set-option :timeout " + to_string(*m_queryTimeout) + ")\n";
214+
s << "(set-option :timeout " + std::to_string(*m_queryTimeout) + ")\n";
216215
s << "(set-logic HORN)" << std::endl;
217216

218217
for (auto const& decl: m_smtlib2->userSorts() | ranges::views::values)

libsmtutil/CVC4Interface.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323

2424
#include <cvc4/util/bitvector.h>
2525

26-
using namespace std;
2726
using namespace solidity;
2827
using namespace solidity::util;
2928
using namespace solidity::smtutil;
3029

31-
CVC4Interface::CVC4Interface(optional<unsigned> _queryTimeout):
30+
CVC4Interface::CVC4Interface(std::optional<unsigned> _queryTimeout):
3231
SolverInterface(_queryTimeout),
3332
m_solver(&m_context)
3433
{
@@ -56,7 +55,7 @@ void CVC4Interface::pop()
5655
m_solver.pop();
5756
}
5857

59-
void CVC4Interface::declareVariable(string const& _name, SortPointer const& _sort)
58+
void CVC4Interface::declareVariable(std::string const& _name, SortPointer const& _sort)
6059
{
6160
smtAssert(_sort, "");
6261
m_variables[_name] = m_context.mkVar(_name.c_str(), cvc4Sort(*_sort));
@@ -86,10 +85,10 @@ void CVC4Interface::addAssertion(Expression const& _expr)
8685
}
8786
}
8887

89-
pair<CheckResult, vector<string>> CVC4Interface::check(vector<Expression> const& _expressionsToEvaluate)
88+
std::pair<CheckResult, std::vector<std::string>> CVC4Interface::check(std::vector<Expression> const& _expressionsToEvaluate)
9089
{
9190
CheckResult result;
92-
vector<string> values;
91+
std::vector<std::string> values;
9392
try
9493
{
9594
switch (m_solver.checkSat().isSat())
@@ -119,7 +118,7 @@ pair<CheckResult, vector<string>> CVC4Interface::check(vector<Expression> const&
119118
values.clear();
120119
}
121120

122-
return make_pair(result, values);
121+
return std::make_pair(result, values);
123122
}
124123

125124
CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
@@ -128,13 +127,13 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
128127
if (_expr.arguments.empty() && m_variables.count(_expr.name))
129128
return m_variables.at(_expr.name);
130129

131-
vector<CVC4::Expr> arguments;
130+
std::vector<CVC4::Expr> arguments;
132131
for (auto const& arg: _expr.arguments)
133132
arguments.push_back(toCVC4Expr(arg));
134133

135134
try
136135
{
137-
string const& n = _expr.name;
136+
std::string const& n = _expr.name;
138137
// Function application
139138
if (!arguments.empty() && m_variables.count(_expr.name))
140139
return m_context.mkExpr(CVC4::kind::APPLY_UF, m_variables.at(n), arguments);
@@ -145,7 +144,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
145144
return m_context.mkConst(true);
146145
else if (n == "false")
147146
return m_context.mkConst(false);
148-
else if (auto sortSort = dynamic_pointer_cast<SortSort>(_expr.sort))
147+
else if (auto sortSort = std::dynamic_pointer_cast<SortSort>(_expr.sort))
149148
return m_context.mkVar(n, cvc4Sort(*sortSort->inner));
150149
else
151150
try
@@ -224,7 +223,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
224223
}
225224
else if (n == "bv2int")
226225
{
227-
auto intSort = dynamic_pointer_cast<IntSort>(_expr.sort);
226+
auto intSort = std::dynamic_pointer_cast<IntSort>(_expr.sort);
228227
smtAssert(intSort, "");
229228
auto nat = m_context.mkExpr(CVC4::kind::BITVECTOR_TO_NAT, arguments[0]);
230229
if (!intSort->isSigned)
@@ -254,13 +253,13 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
254253
return m_context.mkExpr(CVC4::kind::STORE, arguments[0], arguments[1], arguments[2]);
255254
else if (n == "const_array")
256255
{
257-
shared_ptr<SortSort> sortSort = std::dynamic_pointer_cast<SortSort>(_expr.arguments[0].sort);
256+
std::shared_ptr<SortSort> sortSort = std::dynamic_pointer_cast<SortSort>(_expr.arguments[0].sort);
258257
smtAssert(sortSort, "");
259258
return m_context.mkConst(CVC4::ArrayStoreAll(cvc4Sort(*sortSort->inner), arguments[1]));
260259
}
261260
else if (n == "tuple_get")
262261
{
263-
shared_ptr<TupleSort> tupleSort = std::dynamic_pointer_cast<TupleSort>(_expr.arguments[0].sort);
262+
std::shared_ptr<TupleSort> tupleSort = std::dynamic_pointer_cast<TupleSort>(_expr.arguments[0].sort);
264263
smtAssert(tupleSort, "");
265264
CVC4::DatatypeType tt = m_context.mkTupleType(cvc4Sort(tupleSort->components));
266265
CVC4::Datatype const& dt = tt.getDatatype();
@@ -270,7 +269,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
270269
}
271270
else if (n == "tuple_constructor")
272271
{
273-
shared_ptr<TupleSort> tupleSort = std::dynamic_pointer_cast<TupleSort>(_expr.sort);
272+
std::shared_ptr<TupleSort> tupleSort = std::dynamic_pointer_cast<TupleSort>(_expr.sort);
274273
smtAssert(tupleSort, "");
275274
CVC4::DatatypeType tt = m_context.mkTupleType(cvc4Sort(tupleSort->components));
276275
CVC4::Datatype const& dt = tt.getDatatype();
@@ -328,9 +327,9 @@ CVC4::Type CVC4Interface::cvc4Sort(Sort const& _sort)
328327
return m_context.integerType();
329328
}
330329

331-
vector<CVC4::Type> CVC4Interface::cvc4Sort(vector<SortPointer> const& _sorts)
330+
std::vector<CVC4::Type> CVC4Interface::cvc4Sort(std::vector<SortPointer> const& _sorts)
332331
{
333-
vector<CVC4::Type> cvc4Sorts;
332+
std::vector<CVC4::Type> cvc4Sorts;
334333
for (auto const& _sort: _sorts)
335334
cvc4Sorts.push_back(cvc4Sort(*_sort));
336335
return cvc4Sorts;

0 commit comments

Comments
 (0)