Skip to content

Commit 47da701

Browse files
author
Daniel Kroening
authored
Merge pull request #3688 from tautschnig/vs-shadow-solvers
Avoid shadowing in (parts of) directory solvers/ [blocks: #2310]
2 parents 0a56e98 + 1883da9 commit 47da701

10 files changed

+38
-48
lines changed

src/solvers/flattening/boolbv_array.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ bvt boolbvt::convert_array(const exprt &expr)
2727
expr.has_operands(),
2828
"the bit width being nonzero implies that the array has a nonzero size "
2929
"in which case the array shall have operands");
30-
const exprt::operandst &operands=expr.operands();
3130
const std::size_t op_width = width / operands.size();
3231

3332
bvt bv;

src/solvers/flattening/boolbv_byte_extract.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
103103
}
104104

105105
const exprt &op=expr.op();
106-
const exprt &offset=expr.offset();
107106
PRECONDITION(
108107
expr.id() == ID_byte_extract_little_endian ||
109108
expr.id() == ID_byte_extract_big_endian);
@@ -145,9 +144,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
145144
// add implications
146145

147146
equal_exprt equality;
148-
equality.lhs()=offset; // index operand
147+
equality.lhs() = expr.offset(); // index operand
149148

150-
typet constant_type=offset.type(); // type of index operand
149+
// type of index operand
150+
const typet &constant_type = expr.offset().type();
151151

152152
bvt equal_bv;
153153
equal_bv.resize(width);
@@ -171,9 +171,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
171171
else
172172
{
173173
equal_exprt equality;
174-
equality.lhs()=offset; // index operand
174+
equality.lhs() = expr.offset(); // index operand
175175

176-
typet constant_type(offset.type()); // type of index operand
176+
// type of index operand
177+
const typet &constant_type = expr.offset().type();
177178

178179
for(std::size_t i=0; i<bytes; i++)
179180
{

src/solvers/flattening/boolbv_cond.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ bvt boolbvt::convert_cond(const cond_exprt &expr)
7474

7575
const bvt &op = convert_bv(value, bv.size());
7676

77-
for(std::size_t i=0; i<bv.size(); i++)
78-
bv[i]=prop.lselect(cond_literal, op[i], bv[i]);
77+
for(std::size_t j = 0; j < bv.size(); j++)
78+
bv[j] = prop.lselect(cond_literal, op[j], bv[j]);
7979
}
8080
}
8181

src/solvers/flattening/bv_dimacs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Author: Daniel Kroening, [email protected]
1616

1717
#include <solvers/sat/dimacs_cnf.h>
1818

19-
bool bv_dimacst::write_dimacs(const std::string &filename)
19+
bool bv_dimacst::write_dimacs()
2020
{
2121
if(filename.empty() || filename == "-")
2222
return write_dimacs(std::cout);

src/solvers/flattening/bv_dimacs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class bv_dimacst : public bv_pointerst
2424

2525
virtual ~bv_dimacst()
2626
{
27-
write_dimacs(filename);
27+
write_dimacs();
2828
}
2929

3030
protected:
31-
std::string filename;
32-
bool write_dimacs(const std::string &filename);
31+
const std::string filename;
32+
bool write_dimacs();
3333
bool write_dimacs(std::ostream &);
3434
};
3535

src/solvers/lowering/byte_operators.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,7 @@ exprt lower_byte_operators(const exprt &src, const namespacet &ns)
648648
// destroys any sharing, should use hash table
649649
Forall_operands(it, tmp)
650650
{
651-
exprt tmp=lower_byte_operators(*it, ns);
652-
it->swap(tmp);
651+
*it = lower_byte_operators(*it, ns);
653652
}
654653

655654
if(src.id()==ID_byte_update_little_endian ||

src/solvers/prop/prop_conv.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,10 @@ literalt prop_conv_solvert::convert_bool(const exprt &expr)
238238
"constraint_select_one should have at least two operands");
239239

240240
std::vector<literalt> op_bv;
241-
op_bv.resize(op.size());
241+
op_bv.reserve(op.size());
242242

243-
unsigned i=0;
244243
forall_operands(it, expr)
245-
op_bv[i++]=convert(*it);
244+
op_bv.push_back(convert(*it));
246245

247246
// add constraints
248247

src/solvers/smt2/smt2_conv.cpp

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ Author: Daniel Kroening, [email protected]
4040
// General todos
4141
#define SMT2_TODO(S) PRECONDITION_WITH_DIAGNOSTICS(false, "TODO: " S)
4242

43-
void smt2_convt::print_assignment(std::ostream &out) const
43+
void smt2_convt::print_assignment(std::ostream &os) const
4444
{
4545
// Boolean stuff
4646

4747
for(std::size_t v=0; v<boolean_assignment.size(); v++)
48-
out << "b" << v << "=" << boolean_assignment[v] << "\n";
48+
os << "b" << v << "=" << boolean_assignment[v] << "\n";
4949

5050
// others
5151
}
@@ -93,41 +93,45 @@ void smt2_convt::write_header()
9393
out << "(set-logic " << logic << ")" << "\n";
9494
}
9595

96-
void smt2_convt::write_footer(std::ostream &out)
96+
void smt2_convt::write_footer(std::ostream &os)
9797
{
98-
out << "\n";
98+
os << "\n";
9999

100100
// add the assumptions, if any
101101
if(!assumptions.empty())
102102
{
103-
out << "; assumptions\n";
103+
os << "; assumptions\n";
104104

105105
forall_literals(it, assumptions)
106106
{
107-
out << "(assert ";
107+
os << "(assert ";
108108
convert_literal(*it);
109-
out << ")" << "\n";
109+
os << ")"
110+
<< "\n";
110111
}
111112
}
112113

113114
// fix up the object sizes
114115
for(const auto &object : object_sizes)
115116
define_object_size(object.second, object.first);
116117

117-
out << "(check-sat)" << "\n";
118-
out << "\n";
118+
os << "(check-sat)"
119+
<< "\n";
120+
os << "\n";
119121

120122
if(solver!=solvert::BOOLECTOR)
121123
{
122124
for(const auto &id : smt2_identifiers)
123-
out << "(get-value (|" << id << "|))" << "\n";
125+
os << "(get-value (|" << id << "|))"
126+
<< "\n";
124127
}
125128

126-
out << "\n";
129+
os << "\n";
127130

128-
out << "(exit)\n";
131+
os << "(exit)\n";
129132

130-
out << "; end of SMT2 file" << "\n";
133+
os << "; end of SMT2 file"
134+
<< "\n";
131135
}
132136

133137
void smt2_convt::define_object_size(
@@ -1503,8 +1507,6 @@ void smt2_convt::convert_expr(const exprt &expr)
15031507
DATA_INVARIANT(
15041508
expr.operands().size() == 1, "width expression should have one operand");
15051509

1506-
boolbv_widtht boolbv_width(ns);
1507-
15081510
std::size_t result_width=boolbv_width(expr.type());
15091511
CHECK_RETURN(result_width != 0);
15101512

@@ -2671,8 +2673,6 @@ void smt2_convt::convert_union(const union_exprt &expr)
26712673
const union_typet &union_type = to_union_type(ns.follow(expr.type()));
26722674
const exprt &op=expr.op();
26732675

2674-
boolbv_widtht boolbv_width(ns);
2675-
26762676
std::size_t total_width=boolbv_width(union_type);
26772677
CHECK_RETURN_WITH_DIAGNOSTICS(
26782678
total_width != 0, "failed to get union width for union");
@@ -3633,8 +3633,6 @@ void smt2_convt::convert_with(const with_exprt &expr)
36333633

36343634
const exprt &value=expr.op2();
36353635

3636-
boolbv_widtht boolbv_width(ns);
3637-
36383636
std::size_t total_width=boolbv_width(union_type);
36393637
CHECK_RETURN_WITH_DIAGNOSTICS(
36403638
total_width != 0, "failed to get union width for with");
@@ -4453,8 +4451,6 @@ void smt2_convt::convert_type(const typet &type)
44534451
}
44544452
else
44554453
{
4456-
boolbv_widtht boolbv_width(ns);
4457-
44584454
std::size_t width=boolbv_width(type);
44594455
CHECK_RETURN_WITH_DIAGNOSTICS(
44604456
width != 0, "failed to get width of vector");
@@ -4471,8 +4467,6 @@ void smt2_convt::convert_type(const typet &type)
44714467
}
44724468
else if(type.id() == ID_union || type.id() == ID_union_tag)
44734469
{
4474-
boolbv_widtht boolbv_width(ns);
4475-
44764470
std::size_t width=boolbv_width(type);
44774471
CHECK_RETURN_WITH_DIAGNOSTICS(width != 0, "failed to get width of union");
44784472

@@ -4529,8 +4523,6 @@ void smt2_convt::convert_type(const typet &type)
45294523
}
45304524
else
45314525
{
4532-
boolbv_widtht boolbv_width(ns);
4533-
45344526
std::size_t width=boolbv_width(type);
45354527
CHECK_RETURN_WITH_DIAGNOSTICS(
45364528
width != 0, "failed to get width of complex");
@@ -4806,11 +4798,11 @@ void smt2_convt::collect_bindings(
48064798
seen_expressionst &map,
48074799
std::vector<exprt> &let_order)
48084800
{
4809-
seen_expressionst::iterator it = map.find(expr);
4801+
seen_expressionst::iterator entry = map.find(expr);
48104802

4811-
if(it!=map.end())
4803+
if(entry != map.end())
48124804
{
4813-
let_count_idt &count_id=it->second;
4805+
let_count_idt &count_id = entry->second;
48144806
++(count_id.count);
48154807
return;
48164808
}

src/solvers/smt2/smt2_conv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class smt2_convt:public prop_convt
118118
virtual void set_to(const exprt &expr, bool value);
119119
virtual exprt get(const exprt &expr) const;
120120
virtual std::string decision_procedure_text() const { return "SMT2"; }
121-
virtual void print_assignment(std::ostream &out) const;
121+
virtual void print_assignment(std::ostream &) const;
122122
virtual tvt l_get(literalt l) const;
123123
virtual void set_assumptions(const bvt &bv) { assumptions=bv; }
124124

src/solvers/smt2/smt2_format.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ std::ostream &smt2_format_rec(std::ostream &out, const exprt &expr)
5454
{
5555
const std::size_t width = to_unsignedbv_type(expr_type).get_width();
5656

57-
const auto value = numeric_cast_v<mp_integer>(expr);
57+
const auto int_value = numeric_cast_v<mp_integer>(expr);
5858

59-
out << "(_ bv" << value << " " << width << ")";
59+
out << "(_ bv" << int_value << " " << width << ")";
6060
}
6161
else if(expr_type.id() == ID_bool)
6262
{

0 commit comments

Comments
 (0)