@@ -76,29 +76,29 @@ bvt bv_pointerst::object_literals(const bvt &bv, const pointer_typet &type)
76
76
PRECONDITION (width == bv.size ());
77
77
78
78
const auto result = prop.new_variables (width);
79
- bvt match_found ;
79
+ bvt match_found_disjuncts ;
80
80
81
81
for (std::size_t i = 0 ; i < numbered_pointers.size (); i++)
82
82
{
83
83
auto cond = bv_utils.equal (
84
84
bv,
85
85
bv_utilst::concatenate (
86
86
bv_utilst::build_constant (i, width - 1 ), {const_literal (true )}));
87
- match_found .push_back (cond);
87
+ match_found_disjuncts .push_back (cond);
88
88
bv_utils.cond_implies_equal (
89
89
cond,
90
90
bv_utilst::zero_extension (numbered_pointers[i].first , width),
91
91
result);
92
92
}
93
93
94
- auto within_bounds = prop.lor (match_found );
94
+ auto match_found = prop.lor (match_found_disjuncts );
95
95
96
96
// The top bit distinguishes 'object only' vs. 'table encoded'.
97
97
// When outside of the table, return an invalid object.
98
98
return bv_utils.select (
99
99
bv.back (),
100
100
bv_utils.select (
101
- within_bounds ,
101
+ match_found ,
102
102
result,
103
103
bv_utilst::build_constant (pointer_logic.get_invalid_object (), width)),
104
104
bv);
@@ -110,21 +110,28 @@ bvt bv_pointerst::offset_literals(const bvt &bv, const pointer_typet &type)
110
110
PRECONDITION (width == bv.size ());
111
111
112
112
const auto result = prop.new_variables (width);
113
+ bvt match_found_disjuncts;
113
114
114
115
for (std::size_t i = 0 ; i < numbered_pointers.size (); i++)
115
116
{
116
117
auto cond = bv_utils.equal (
117
118
bv,
118
119
bv_utilst::concatenate (
119
120
bv_utilst::build_constant (i, width - 1 ), {const_literal (true )}));
121
+ match_found_disjuncts.push_back (cond);
120
122
bv_utils.cond_implies_equal (
121
123
cond,
122
124
bv_utilst::sign_extension (numbered_pointers[i].second , width),
123
125
result);
124
126
}
125
127
128
+ auto match_found = prop.lor (match_found_disjuncts);
129
+
126
130
// the top bit distinguishes 'object only' vs. 'table encoded'
127
- return bv_utils.select (bv.back (), result, bv_utilst::zeros (width));
131
+ return bv_utils.select (
132
+ bv.back (),
133
+ bv_utils.select (match_found, result, bv_utilst::zeros (width)),
134
+ bv_utilst::zeros (width));
128
135
}
129
136
130
137
bvt bv_pointerst::object_offset_encoding (
@@ -436,11 +443,11 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
436
443
op_type.id () == ID_c_enum || op_type.id () == ID_c_enum_tag)
437
444
{
438
445
// Cast from a bitvector type to pointer.
439
- // We just do a zero extension.
440
-
446
+ // We interpret as NULL + offset, where the offset is
447
+ // derived from the bitvector by zero extension.
441
448
const bvt &op_bv=convert_bv (op);
442
-
443
- return bv_utils. zero_extension (op_bv, bits);
449
+ return object_offset_encoding (
450
+ bv_utilst::zeros (bits), bv_utilst:: zero_extension (op_bv, bits), type );
444
451
}
445
452
}
446
453
else if (expr.id ()==ID_if)
0 commit comments