Skip to content

Avoid shadowing in (parts of) directory solvers/ [blocks: #2310] #3688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/solvers/flattening/boolbv_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ bvt boolbvt::convert_array(const exprt &expr)
expr.has_operands(),
"the bit width being nonzero implies that the array has a nonzero size "
"in which case the array shall have operands");
const exprt::operandst &operands=expr.operands();
const std::size_t op_width = width / operands.size();

bvt bv;
Expand Down
11 changes: 6 additions & 5 deletions src/solvers/flattening/boolbv_byte_extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
}

const exprt &op=expr.op();
const exprt &offset=expr.offset();
PRECONDITION(
expr.id() == ID_byte_extract_little_endian ||
expr.id() == ID_byte_extract_big_endian);
Expand Down Expand Up @@ -145,9 +144,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
// add implications

equal_exprt equality;
equality.lhs()=offset; // index operand
equality.lhs() = expr.offset(); // index operand

typet constant_type=offset.type(); // type of index operand
// type of index operand
const typet &constant_type = expr.offset().type();

bvt equal_bv;
equal_bv.resize(width);
Expand All @@ -171,9 +171,10 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
else
{
equal_exprt equality;
equality.lhs()=offset; // index operand
equality.lhs() = expr.offset(); // index operand

typet constant_type(offset.type()); // type of index operand
// type of index operand
const typet &constant_type = expr.offset().type();

for(std::size_t i=0; i<bytes; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/solvers/flattening/boolbv_cond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ bvt boolbvt::convert_cond(const cond_exprt &expr)

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/solvers/flattening/bv_dimacs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Author: Daniel Kroening, [email protected]

#include <solvers/sat/dimacs_cnf.h>

bool bv_dimacst::write_dimacs(const std::string &filename)
bool bv_dimacst::write_dimacs()
{
if(filename.empty() || filename == "-")
return write_dimacs(std::cout);
Expand Down
6 changes: 3 additions & 3 deletions src/solvers/flattening/bv_dimacs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class bv_dimacst : public bv_pointerst

virtual ~bv_dimacst()
{
write_dimacs(filename);
write_dimacs();
}

protected:
std::string filename;
bool write_dimacs(const std::string &filename);
const std::string filename;
bool write_dimacs();
bool write_dimacs(std::ostream &);
};

Expand Down
3 changes: 1 addition & 2 deletions src/solvers/lowering/byte_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,7 @@ exprt lower_byte_operators(const exprt &src, const namespacet &ns)
// destroys any sharing, should use hash table
Forall_operands(it, tmp)
{
exprt tmp=lower_byte_operators(*it, ns);
it->swap(tmp);
*it = lower_byte_operators(*it, ns);
}

if(src.id()==ID_byte_update_little_endian ||
Expand Down
5 changes: 2 additions & 3 deletions src/solvers/prop/prop_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,10 @@ literalt prop_conv_solvert::convert_bool(const exprt &expr)
"constraint_select_one should have at least two operands");

std::vector<literalt> op_bv;
op_bv.resize(op.size());
op_bv.reserve(op.size());

unsigned i=0;
forall_operands(it, expr)
op_bv[i++]=convert(*it);
op_bv.push_back(convert(*it));

// add constraints

Expand Down
48 changes: 20 additions & 28 deletions src/solvers/smt2/smt2_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Author: Daniel Kroening, [email protected]
// General todos
#define SMT2_TODO(S) PRECONDITION_WITH_DIAGNOSTICS(false, "TODO: " S)

void smt2_convt::print_assignment(std::ostream &out) const
void smt2_convt::print_assignment(std::ostream &os) const
{
// Boolean stuff

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

// others
}
Expand Down Expand Up @@ -93,41 +93,45 @@ void smt2_convt::write_header()
out << "(set-logic " << logic << ")" << "\n";
}

void smt2_convt::write_footer(std::ostream &out)
void smt2_convt::write_footer(std::ostream &os)
{
out << "\n";
os << "\n";

// add the assumptions, if any
if(!assumptions.empty())
{
out << "; assumptions\n";
os << "; assumptions\n";

forall_literals(it, assumptions)
{
out << "(assert ";
os << "(assert ";
convert_literal(*it);
out << ")" << "\n";
os << ")"
<< "\n";
}
}

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

out << "(check-sat)" << "\n";
out << "\n";
os << "(check-sat)"
<< "\n";
os << "\n";

if(solver!=solvert::BOOLECTOR)
{
for(const auto &id : smt2_identifiers)
out << "(get-value (|" << id << "|))" << "\n";
os << "(get-value (|" << id << "|))"
<< "\n";
}

out << "\n";
os << "\n";

out << "(exit)\n";
os << "(exit)\n";

out << "; end of SMT2 file" << "\n";
os << "; end of SMT2 file"
<< "\n";
}

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

boolbv_widtht boolbv_width(ns);

std::size_t result_width=boolbv_width(expr.type());
CHECK_RETURN(result_width != 0);

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

boolbv_widtht boolbv_width(ns);

std::size_t total_width=boolbv_width(union_type);
CHECK_RETURN_WITH_DIAGNOSTICS(
total_width != 0, "failed to get union width for union");
Expand Down Expand Up @@ -3633,8 +3633,6 @@ void smt2_convt::convert_with(const with_exprt &expr)

const exprt &value=expr.op2();

boolbv_widtht boolbv_width(ns);

std::size_t total_width=boolbv_width(union_type);
CHECK_RETURN_WITH_DIAGNOSTICS(
total_width != 0, "failed to get union width for with");
Expand Down Expand Up @@ -4453,8 +4451,6 @@ void smt2_convt::convert_type(const typet &type)
}
else
{
boolbv_widtht boolbv_width(ns);

std::size_t width=boolbv_width(type);
CHECK_RETURN_WITH_DIAGNOSTICS(
width != 0, "failed to get width of vector");
Expand All @@ -4471,8 +4467,6 @@ void smt2_convt::convert_type(const typet &type)
}
else if(type.id() == ID_union || type.id() == ID_union_tag)
{
boolbv_widtht boolbv_width(ns);

std::size_t width=boolbv_width(type);
CHECK_RETURN_WITH_DIAGNOSTICS(width != 0, "failed to get width of union");

Expand Down Expand Up @@ -4529,8 +4523,6 @@ void smt2_convt::convert_type(const typet &type)
}
else
{
boolbv_widtht boolbv_width(ns);

std::size_t width=boolbv_width(type);
CHECK_RETURN_WITH_DIAGNOSTICS(
width != 0, "failed to get width of complex");
Expand Down Expand Up @@ -4806,11 +4798,11 @@ void smt2_convt::collect_bindings(
seen_expressionst &map,
std::vector<exprt> &let_order)
{
seen_expressionst::iterator it = map.find(expr);
seen_expressionst::iterator entry = map.find(expr);

if(it!=map.end())
if(entry != map.end())
{
let_count_idt &count_id=it->second;
let_count_idt &count_id = entry->second;
++(count_id.count);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/smt2/smt2_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class smt2_convt:public prop_convt
virtual void set_to(const exprt &expr, bool value);
virtual exprt get(const exprt &expr) const;
virtual std::string decision_procedure_text() const { return "SMT2"; }
virtual void print_assignment(std::ostream &out) const;
virtual void print_assignment(std::ostream &) const;
virtual tvt l_get(literalt l) const;
virtual void set_assumptions(const bvt &bv) { assumptions=bv; }

Expand Down
4 changes: 2 additions & 2 deletions src/solvers/smt2/smt2_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ std::ostream &smt2_format_rec(std::ostream &out, const exprt &expr)
{
const std::size_t width = to_unsignedbv_type(expr_type).get_width();

const auto value = numeric_cast_v<mp_integer>(expr);
const auto int_value = numeric_cast_v<mp_integer>(expr);

out << "(_ bv" << value << " " << width << ")";
out << "(_ bv" << int_value << " " << width << ")";
}
else if(expr_type.id() == ID_bool)
{
Expand Down