@@ -1046,20 +1046,37 @@ static smt_termt convert_expr_to_smt(
1046
1046
1047
1047
static smt_termt convert_expr_to_smt (
1048
1048
const is_invalid_pointer_exprt &is_invalid_pointer,
1049
+ const smt_object_mapt &object_map,
1049
1050
const sub_expression_mapt &converted)
1050
1051
{
1051
- UNIMPLEMENTED_FEATURE (
1052
- " Generation of SMT formula for is invalid pointer expression: " +
1053
- is_invalid_pointer.pretty ());
1052
+ const exprt &pointer_expr (to_unary_expr (is_invalid_pointer).op ());
1053
+ const bitvector_typet *pointer_type =
1054
+ type_try_dynamic_cast<bitvector_typet>(pointer_expr.type ());
1055
+ INVARIANT (pointer_type, " Pointer object should have a bitvector-based type." );
1056
+ const std::size_t object_bits = config.bv_encoding .object_bits ;
1057
+ const std::size_t width = pointer_type->get_width ();
1058
+ INVARIANT (
1059
+ width >= object_bits,
1060
+ " Width should be at least as big as the number of object bits." );
1061
+
1062
+ const auto extract_op = smt_bit_vector_theoryt::extract (
1063
+ width - 1 , width - object_bits)(converted.at (pointer_expr));
1064
+
1065
+ const auto &invalid_pointer = object_map.at (make_invalid_pointer_expr ());
1066
+
1067
+ const smt_termt invalid_pointer_address = smt_bit_vector_constant_termt (
1068
+ invalid_pointer.unique_id , config.bv_encoding .object_bits );
1069
+
1070
+ return smt_core_theoryt::equal (invalid_pointer_address, extract_op);
1054
1071
}
1055
1072
1056
1073
static smt_termt convert_expr_to_smt (
1057
- const string_constantt &is_invalid_pointer ,
1074
+ const string_constantt &string_constant ,
1058
1075
const sub_expression_mapt &converted)
1059
1076
{
1060
1077
UNIMPLEMENTED_FEATURE (
1061
- " Generation of SMT formula for is invalid pointer expression: " +
1062
- is_invalid_pointer .pretty ());
1078
+ " Generation of SMT formula for string constant expression: " +
1079
+ string_constant .pretty ());
1063
1080
}
1064
1081
1065
1082
static smt_termt convert_expr_to_smt (
@@ -1643,7 +1660,7 @@ static smt_termt dispatch_expr_to_smt_conversion(
1643
1660
const auto is_invalid_pointer =
1644
1661
expr_try_dynamic_cast<is_invalid_pointer_exprt>(expr))
1645
1662
{
1646
- return convert_expr_to_smt (*is_invalid_pointer, converted);
1663
+ return convert_expr_to_smt (*is_invalid_pointer, object_map, converted);
1647
1664
}
1648
1665
if (const auto string_constant = expr_try_dynamic_cast<string_constantt>(expr))
1649
1666
{
0 commit comments