File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
src/solvers/smt2_incremental Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -598,6 +598,43 @@ static smt_termt convert_expr_to_smt(
598
598
return convert_multiary_operator_to_terms (
599
599
plus, converted, smt_bit_vector_theoryt::add);
600
600
}
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
+ // We need to ensure that we follow this code path only if the expression
623
+ // our assumptions about the structure of the addition expression hold.
624
+ INVARIANT (
625
+ !can_cast_type<pointer_typet>(scalar.type ()),
626
+ " An addition expression with both operands being pointers when they are "
627
+ " not dereferenced is malformed" );
628
+
629
+ const pointer_typet pointer_type =
630
+ *type_try_dynamic_cast<pointer_typet>(pointer.type ());
631
+ const auto base_type = pointer_type.base_type ();
632
+ const auto pointer_size = pointer_sizes.at (base_type);
633
+
634
+ return smt_bit_vector_theoryt::add (
635
+ converted.at (pointer),
636
+ smt_bit_vector_theoryt::multiply (converted.at (scalar), pointer_size));
637
+ }
601
638
else
602
639
{
603
640
UNIMPLEMENTED_FEATURE (
You can’t perform that action at this time.
0 commit comments