Skip to content

Commit f0667ca

Browse files
committed
Add support for conversion of addition with pointer operand to new SMT backend.
1 parent a41bbb9 commit f0667ca

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,36 @@ static smt_termt convert_expr_to_smt(
598598
return convert_multiary_operator_to_terms(
599599
plus, converted, smt_bit_vector_theoryt::add);
600600
}
601+
else if(can_cast_type<pointer_typet>(plus.type()))
602+
{
603+
INVARIANT(
604+
plus.operands().size() == 2,
605+
"We are only handling a binary version of plus when it has a pointer "
606+
"operand");
607+
608+
exprt pointer;
609+
exprt scalar;
610+
for(auto &operand : plus.operands())
611+
{
612+
if(can_cast_type<pointer_typet>(operand.type()))
613+
{
614+
pointer = operand;
615+
}
616+
else
617+
{
618+
scalar = operand;
619+
}
620+
}
621+
622+
pointer_typet pointer_type =
623+
*type_try_dynamic_cast<pointer_typet>(pointer.type());
624+
auto base_type = pointer_type.base_type();
625+
auto pointer_size = pointer_sizes.at(base_type);
626+
627+
return smt_bit_vector_theoryt::add(
628+
converted.at(pointer),
629+
smt_bit_vector_theoryt::multiply(converted.at(scalar), pointer_size));
630+
}
601631
else
602632
{
603633
UNIMPLEMENTED_FEATURE(

0 commit comments

Comments
 (0)