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