@@ -170,7 +170,17 @@ class goto_checkt
170
170
void undefined_shift_check (const shift_exprt &, const guardt &);
171
171
void pointer_rel_check (const binary_relation_exprt &, const guardt &);
172
172
void pointer_overflow_check (const exprt &, const guardt &);
173
- void pointer_validity_check (const dereference_exprt &, const guardt &);
173
+
174
+ // / Generates VCCs for the validity of the given dereferencing operation.
175
+ // / \param expr the expression to be checked
176
+ // / \param src_expr The expression as found in the program,
177
+ // / prior to any rewriting
178
+ // / \param guard the condition under which the operation happens
179
+ void pointer_validity_check (
180
+ const dereference_exprt &expr,
181
+ const exprt &src_expr,
182
+ const guardt &guard);
183
+
174
184
conditionst address_check (const exprt &address, const exprt &size);
175
185
void integer_overflow_check (const exprt &, const guardt &);
176
186
void conversion_check (const exprt &, const guardt &);
@@ -1094,6 +1104,7 @@ void goto_checkt::pointer_overflow_check(
1094
1104
1095
1105
void goto_checkt::pointer_validity_check (
1096
1106
const dereference_exprt &expr,
1107
+ const exprt &src_expr,
1097
1108
const guardt &guard)
1098
1109
{
1099
1110
if (!enable_pointer_check)
@@ -1112,8 +1123,8 @@ void goto_checkt::pointer_validity_check(
1112
1123
c.assertion ,
1113
1124
" dereference failure: " + c.description ,
1114
1125
" pointer dereference" ,
1115
- expr .find_source_location (),
1116
- expr ,
1126
+ src_expr .find_source_location (),
1127
+ src_expr ,
1117
1128
guard);
1118
1129
}
1119
1130
}
@@ -1581,16 +1592,14 @@ bool goto_checkt::check_rec_member(const member_exprt &member, guardt &guard)
1581
1592
deref.pointer (), pointer_type (char_type ()));
1582
1593
1583
1594
const exprt new_address_casted = typecast_exprt::conditional_cast (
1584
- typecast_exprt{
1585
- plus_exprt{char_pointer,
1586
- typecast_exprt::conditional_cast (
1587
- member_offset_opt.value (), pointer_diff_type ())},
1588
- char_pointer.type ()},
1595
+ plus_exprt{char_pointer,
1596
+ typecast_exprt::conditional_cast (
1597
+ member_offset_opt.value (), pointer_diff_type ())},
1589
1598
new_pointer_type);
1590
1599
1591
1600
dereference_exprt new_deref{new_address_casted};
1592
1601
new_deref.add_source_location () = deref.source_location ();
1593
- pointer_validity_check (new_deref, guard);
1602
+ pointer_validity_check (new_deref, member, guard);
1594
1603
1595
1604
return true ;
1596
1605
}
@@ -1692,7 +1701,7 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard)
1692
1701
pointer_rel_check (to_binary_relation_expr (expr), guard);
1693
1702
else if (expr.id ()==ID_dereference)
1694
1703
{
1695
- pointer_validity_check (to_dereference_expr (expr), guard);
1704
+ pointer_validity_check (to_dereference_expr (expr), expr, guard);
1696
1705
}
1697
1706
}
1698
1707
0 commit comments