Skip to content

Commit 061ce17

Browse files
committed
Convert pointer_offset_exprt to SMT
1 parent d4d3aa1 commit 061ce17

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,27 @@ static smt_termt convert_expr_to_smt(
11651165
return extract_op;
11661166
}
11671167

1168+
static smt_termt convert_expr_to_smt(
1169+
const pointer_offset_exprt &pointer_offset,
1170+
const sub_expression_mapt &converted)
1171+
{
1172+
const auto type =
1173+
type_try_dynamic_cast<bitvector_typet>(pointer_offset.type());
1174+
INVARIANT(type, "Pointer offset should have a bitvector-based type.");
1175+
const auto converted_expr = converted.at(pointer_offset.pointer());
1176+
const std::size_t width = type->get_width();
1177+
std::size_t offset_bits = width - config.bv_encoding.object_bits;
1178+
if(offset_bits > width)
1179+
offset_bits = width;
1180+
const auto extract_op =
1181+
smt_bit_vector_theoryt::extract(offset_bits - 1, 0)(converted_expr);
1182+
if(width > offset_bits)
1183+
{
1184+
return smt_bit_vector_theoryt::zero_extend(width - offset_bits)(extract_op);
1185+
}
1186+
return extract_op;
1187+
}
1188+
11681189
static smt_termt convert_expr_to_smt(
11691190
const shl_overflow_exprt &shl_overflow,
11701191
const sub_expression_mapt &converted)
@@ -1456,11 +1477,12 @@ static smt_termt dispatch_expr_to_smt_conversion(
14561477
{
14571478
return convert_expr_to_smt(*member_extraction, converted);
14581479
}
1459-
#if 0
1460-
else if(expr.id()==ID_pointer_offset)
1480+
else if(
1481+
const auto pointer_offset =
1482+
expr_try_dynamic_cast<pointer_offset_exprt>(expr))
14611483
{
1484+
return convert_expr_to_smt(*pointer_offset, converted);
14621485
}
1463-
#endif
14641486
else if(
14651487
const auto pointer_object =
14661488
expr_try_dynamic_cast<pointer_object_exprt>(expr))

0 commit comments

Comments
 (0)