@@ -911,6 +911,9 @@ void code_contractst::instrument_call_statement(
911
911
}
912
912
else if (callee_name == " free" )
913
913
{
914
+ source_locationt location_no_checks =
915
+ instruction_it->source_location ();
916
+ disable_pointer_checks (location_no_checks);
914
917
const auto free_car = add_inclusion_check (
915
918
body,
916
919
assigns,
@@ -920,10 +923,9 @@ void code_contractst::instrument_call_statement(
920
923
// skip all invalidation business if we're freeing invalid memory
921
924
goto_programt alias_checking_instructions, skip_program;
922
925
alias_checking_instructions.add (goto_programt::make_goto (
923
- skip_program.add (
924
- goto_programt::make_skip (instruction_it->source_location ())),
926
+ skip_program.add (goto_programt::make_skip (location_no_checks)),
925
927
not_exprt{free_car.validity_condition_var },
926
- instruction_it-> source_location () ));
928
+ location_no_checks ));
927
929
928
930
// Since the argument to free may be an "alias" (but not identical)
929
931
// to existing CARs' source_expr, structural equality wouldn't work.
@@ -943,8 +945,8 @@ void code_contractst::instrument_call_statement(
943
945
.symbol_expr ();
944
946
write_set_validity_addrs.insert (object_validity_var_addr);
945
947
946
- alias_checking_instructions.add (goto_programt::make_decl (
947
- object_validity_var_addr, instruction_it-> source_location () ));
948
+ alias_checking_instructions.add (
949
+ goto_programt::make_decl ( object_validity_var_addr, location_no_checks ));
948
950
// if the CAR was defined on the same_object as the one being `free`d,
949
951
// record its validity variable's address, otherwise record NULL
950
952
alias_checking_instructions.add (goto_programt::make_assignment (
@@ -956,7 +958,7 @@ void code_contractst::instrument_call_statement(
956
958
free_car.lower_bound_address_var , w_car.lower_bound_address_var )},
957
959
address_of_exprt{w_car.validity_condition_var },
958
960
null_pointer_exprt{to_pointer_type (object_validity_var_addr.type ())}},
959
- instruction_it-> source_location () ));
961
+ location_no_checks ));
960
962
}
961
963
962
964
alias_checking_instructions.destructive_append (skip_program);
@@ -972,24 +974,22 @@ void code_contractst::instrument_call_statement(
972
974
goto_programt invalidation_instructions;
973
975
skip_program.clear ();
974
976
invalidation_instructions.add (goto_programt::make_goto (
975
- skip_program.add (
976
- goto_programt::make_skip (instruction_it->source_location ())),
977
+ skip_program.add (goto_programt::make_skip (location_no_checks)),
977
978
not_exprt{free_car.validity_condition_var },
978
- instruction_it-> source_location () ));
979
+ location_no_checks ));
979
980
980
981
// invalidate all recorded CAR validity variables
981
982
for (const auto &w_car_validity_addr : write_set_validity_addrs)
982
983
{
983
984
goto_programt w_car_skip_program;
984
985
invalidation_instructions.add (goto_programt::make_goto (
985
- w_car_skip_program.add (
986
- goto_programt::make_skip (instruction_it->source_location ())),
986
+ w_car_skip_program.add (goto_programt::make_skip (location_no_checks)),
987
987
null_pointer (w_car_validity_addr),
988
- instruction_it-> source_location () ));
988
+ location_no_checks ));
989
989
invalidation_instructions.add (goto_programt::make_assignment (
990
990
dereference_exprt{w_car_validity_addr},
991
991
false_exprt{},
992
- instruction_it-> source_location () ));
992
+ location_no_checks ));
993
993
invalidation_instructions.destructive_append (w_car_skip_program);
994
994
}
995
995
@@ -1175,6 +1175,10 @@ void code_contractst::check_frame_conditions(
1175
1175
else if (instruction_it->is_dead ())
1176
1176
{
1177
1177
const auto &symbol = instruction_it->dead_symbol ();
1178
+ source_locationt location_no_checks =
1179
+ instruction_it->source_location ();
1180
+ disable_pointer_checks (location_no_checks);
1181
+
1178
1182
// CAR equality and hash are defined on source_expr alone,
1179
1183
// therefore this temporary CAR should be "found"
1180
1184
const auto &symbol_car = assigns.get_write_set ().find (
@@ -1228,10 +1232,13 @@ code_contractst::add_inclusion_check(
1228
1232
program, instruction_it, snapshot_instructions);
1229
1233
1230
1234
goto_programt assertion;
1231
- assertion.add (goto_programt::make_assertion (
1232
- assigns.generate_inclusion_check (car), instruction_it->source_location ()));
1233
- assertion.instructions .back ().source_location_nonconst ().set_comment (
1235
+ source_locationt location_no_checks =
1236
+ instruction_it->source_location_nonconst ();
1237
+ disable_pointer_checks (location_no_checks);
1238
+ location_no_checks.set_comment (
1234
1239
" Check that " + from_expr (ns, expr.id (), expr) + " is assignable" );
1240
+ assertion.add (goto_programt::make_assertion (
1241
+ assigns.generate_inclusion_check (car), location_no_checks));
1235
1242
insert_before_swap_and_advance (program, instruction_it, assertion);
1236
1243
1237
1244
return car;
0 commit comments