@@ -911,6 +911,8 @@ void code_contractst::instrument_call_statement(
911911 }
912912 else if (callee_name == " free" )
913913 {
914+ source_locationt location_no_checks = instruction_it->source_location ();
915+ disable_pointer_checks (location_no_checks);
914916 const auto free_car = add_inclusion_check (
915917 body,
916918 assigns,
@@ -920,10 +922,9 @@ void code_contractst::instrument_call_statement(
920922 // skip all invalidation business if we're freeing invalid memory
921923 goto_programt alias_checking_instructions, skip_program;
922924 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)),
925926 not_exprt{free_car.validity_condition_var },
926- instruction_it-> source_location () ));
927+ location_no_checks ));
927928
928929 // Since the argument to free may be an "alias" (but not identical)
929930 // to existing CARs' source_expr, structural equality wouldn't work.
@@ -943,8 +944,8 @@ void code_contractst::instrument_call_statement(
943944 .symbol_expr ();
944945 write_set_validity_addrs.insert (object_validity_var_addr);
945946
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 ));
948949 // if the CAR was defined on the same_object as the one being `free`d,
949950 // record its validity variable's address, otherwise record NULL
950951 alias_checking_instructions.add (goto_programt::make_assignment (
@@ -956,7 +957,7 @@ void code_contractst::instrument_call_statement(
956957 free_car.lower_bound_address_var , w_car.lower_bound_address_var )},
957958 address_of_exprt{w_car.validity_condition_var },
958959 null_pointer_exprt{to_pointer_type (object_validity_var_addr.type ())}},
959- instruction_it-> source_location () ));
960+ location_no_checks ));
960961 }
961962
962963 alias_checking_instructions.destructive_append (skip_program);
@@ -972,24 +973,22 @@ void code_contractst::instrument_call_statement(
972973 goto_programt invalidation_instructions;
973974 skip_program.clear ();
974975 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)),
977977 not_exprt{free_car.validity_condition_var },
978- instruction_it-> source_location () ));
978+ location_no_checks ));
979979
980980 // invalidate all recorded CAR validity variables
981981 for (const auto &w_car_validity_addr : write_set_validity_addrs)
982982 {
983983 goto_programt w_car_skip_program;
984984 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)),
987986 null_pointer (w_car_validity_addr),
988- instruction_it-> source_location () ));
987+ location_no_checks ));
989988 invalidation_instructions.add (goto_programt::make_assignment (
990989 dereference_exprt{w_car_validity_addr},
991990 false_exprt{},
992- instruction_it-> source_location () ));
991+ location_no_checks ));
993992 invalidation_instructions.destructive_append (w_car_skip_program);
994993 }
995994
@@ -1175,6 +1174,9 @@ void code_contractst::check_frame_conditions(
11751174 else if (instruction_it->is_dead ())
11761175 {
11771176 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+
11781180 // CAR equality and hash are defined on source_expr alone,
11791181 // therefore this temporary CAR should be "found"
11801182 const auto &symbol_car = assigns.get_write_set ().find (
@@ -1228,10 +1230,13 @@ code_contractst::add_inclusion_check(
12281230 program, instruction_it, snapshot_instructions);
12291231
12301232 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 (
12341237 " 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));
12351240 insert_before_swap_and_advance (program, instruction_it, assertion);
12361241
12371242 return car;
0 commit comments