@@ -1238,11 +1238,18 @@ static smt_termt convert_expr_to_smt(
1238
1238
1239
1239
static smt_termt convert_expr_to_smt (
1240
1240
const object_size_exprt &object_size,
1241
- const sub_expression_mapt &converted)
1241
+ const sub_expression_mapt &converted,
1242
+ const smt_object_sizet::make_applicationt &call_object_size)
1242
1243
{
1243
- UNIMPLEMENTED_FEATURE (
1244
- " Generation of SMT formula for object_size expression: " +
1245
- object_size.pretty ());
1244
+ const smt_termt &pointer = converted.at (object_size.pointer ());
1245
+ const auto pointer_sort = pointer.get_sort ().cast <smt_bit_vector_sortt>();
1246
+ INVARIANT (
1247
+ pointer_sort, " Pointers should be encoded as bit vector sorted terms." );
1248
+ const std::size_t pointer_width = pointer_sort->bit_width ();
1249
+ return call_object_size (
1250
+ std::vector<smt_termt>{smt_bit_vector_theoryt::extract (
1251
+ pointer_width - 1 ,
1252
+ pointer_width - config.bv_encoding .object_bits )(pointer)});
1246
1253
}
1247
1254
1248
1255
static smt_termt
@@ -1292,7 +1299,7 @@ static smt_termt dispatch_expr_to_smt_conversion(
1292
1299
const exprt &expr,
1293
1300
const sub_expression_mapt &converted,
1294
1301
const smt_object_mapt &object_map,
1295
- const smt_object_sizet::make_applicationt &object_size )
1302
+ const smt_object_sizet::make_applicationt &call_object_size )
1296
1303
{
1297
1304
if (const auto symbol = expr_try_dynamic_cast<symbol_exprt>(expr))
1298
1305
{
@@ -1590,7 +1597,7 @@ static smt_termt dispatch_expr_to_smt_conversion(
1590
1597
}
1591
1598
if (const auto object_size = expr_try_dynamic_cast<object_size_exprt>(expr))
1592
1599
{
1593
- return convert_expr_to_smt (*object_size, converted);
1600
+ return convert_expr_to_smt (*object_size, converted, call_object_size );
1594
1601
}
1595
1602
if (const auto let = expr_try_dynamic_cast<let_exprt>(expr))
1596
1603
{
0 commit comments