Skip to content

Commit 890e039

Browse files
authored
Merge pull request #6873 from diffblue/smt2_backend_tweaks
SMT2 backend tweaks
2 parents 7b19f1d + 862affb commit 890e039

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,13 @@ std::string smt2_convt::type2id(const typet &type) const
937937
{
938938
return "p" + std::to_string(to_pointer_type(type).get_width());
939939
}
940+
else if(type.id() == ID_struct_tag)
941+
{
942+
if(use_datatypes)
943+
return datatype_map.at(type);
944+
else
945+
return "S" + std::to_string(boolbv_width(type));
946+
}
940947
else
941948
{
942949
UNREACHABLE;
@@ -3587,7 +3594,19 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
35873594
}
35883595
else if(expr.type().id()==ID_pointer)
35893596
{
3590-
SMT2_TODO("pointer subtraction");
3597+
if(
3598+
expr.op0().type().id() == ID_pointer &&
3599+
(expr.op1().type().id() == ID_unsignedbv ||
3600+
expr.op1().type().id() == ID_signedbv))
3601+
{
3602+
// rewrite p-o to p+(-o)
3603+
return convert_plus(
3604+
plus_exprt(expr.op0(), unary_minus_exprt(expr.op1())));
3605+
}
3606+
else
3607+
UNEXPECTEDCASE(
3608+
"unsupported operand types for -: " + expr.op0().type().id_string() +
3609+
" and " + expr.op1().type().id_string());
35913610
}
35923611
else if(expr.type().id()==ID_vector)
35933612
{
@@ -4839,7 +4858,7 @@ void smt2_convt::find_symbols(const exprt &expr)
48394858

48404859
for(std::size_t i=0; i<tmp.operands().size(); i++)
48414860
{
4842-
out << "(assert (= (select " << id;
4861+
out << "(assert (= (select " << id << ' ';
48434862
convert_expr(from_integer(i, array_type.size().type()));
48444863
out << ") "; // select
48454864
convert_expr(tmp.operands()[i]);

0 commit comments

Comments
 (0)