@@ -693,54 +693,38 @@ void dfcc_instrumentt::instrument_lhs(
693
693
check_source_location.set_comment (
694
694
" Check that " + from_expr_using_mode (ns, mode, lhs) + " is assignable" );
695
695
696
- if (cfg_info.must_check_lhs (target))
697
- {
698
- // ```
699
- // IF !write_set GOTO skip_target;
700
- // DECL check_assign: bool;
701
- // CALL check_assign = check_assignment(write_set, &lhs, sizeof(lhs));
702
- // ASSERT(check_assign);
703
- // DEAD check_assign;
704
- // skip_target: SKIP;
705
- // ----
706
- // ASSIGN lhs := rhs;
707
- // ```
696
+ // ```
697
+ // IF !write_set GOTO skip_target;
698
+ // DECL check_assign: bool;
699
+ // CALL check_assign = check_assignment(write_set, &lhs, sizeof(lhs));
700
+ // ASSERT(check_assign);
701
+ // DEAD check_assign;
702
+ // skip_target: SKIP;
703
+ // ----
704
+ // ASSIGN lhs := rhs;
705
+ // ```
708
706
709
- const auto check_var = dfcc_utilst::create_symbol (
710
- goto_model.symbol_table ,
711
- bool_typet (),
712
- function_id,
713
- " __check_lhs_assignment" ,
714
- lhs_source_location);
707
+ const auto check_var = dfcc_utilst::create_symbol (
708
+ goto_model.symbol_table ,
709
+ bool_typet (),
710
+ function_id,
711
+ " __check_lhs_assignment" ,
712
+ lhs_source_location);
715
713
716
- payload.add (goto_programt::make_decl (check_var, lhs_source_location));
714
+ payload.add (goto_programt::make_decl (check_var, lhs_source_location));
717
715
718
- payload.add (goto_programt::make_function_call (
719
- library.write_set_check_assignment_call (
720
- check_var,
721
- write_set,
722
- typecast_exprt::conditional_cast (
723
- address_of_exprt (lhs), pointer_type (empty_typet{})),
724
- dfcc_utilst::make_sizeof_expr (lhs, ns),
725
- lhs_source_location),
726
- lhs_source_location));
727
-
728
- payload.add (
729
- goto_programt::make_assertion (check_var, check_source_location));
730
- payload.add (goto_programt::make_dead (check_var, check_source_location));
731
- }
732
- else
733
- {
734
- // ```
735
- // IF !write_set GOTO skip_target;
736
- // ASSERT(true);
737
- // skip_target: SKIP;
738
- // ----
739
- // ASSIGN lhs := rhs;
740
- // ```
741
- payload.add (
742
- goto_programt::make_assertion (true_exprt (), check_source_location));
743
- }
716
+ payload.add (goto_programt::make_function_call (
717
+ library.write_set_check_assignment_call (
718
+ check_var,
719
+ write_set,
720
+ typecast_exprt::conditional_cast (
721
+ address_of_exprt (lhs), pointer_type (empty_typet{})),
722
+ dfcc_utilst::make_sizeof_expr (lhs, ns),
723
+ lhs_source_location),
724
+ lhs_source_location));
725
+
726
+ payload.add (goto_programt::make_assertion (check_var, check_source_location));
727
+ payload.add (goto_programt::make_dead (check_var, check_source_location));
744
728
745
729
auto label_instruction =
746
730
payload.add (goto_programt::make_skip (lhs_source_location));
@@ -786,7 +770,8 @@ void dfcc_instrumentt::instrument_assign(
786
770
auto &write_set = cfg_info.get_write_set (target);
787
771
788
772
// check the lhs
789
- instrument_lhs (function_id, target, lhs, goto_program, cfg_info);
773
+ if (cfg_info.must_check_lhs (target))
774
+ instrument_lhs (function_id, target, lhs, goto_program, cfg_info);
790
775
791
776
// handle dead_object updates (created by __builtin_alloca for instance)
792
777
// Remark: we do not really need to track this deallocation since the default
@@ -1018,7 +1003,7 @@ void dfcc_instrumentt::instrument_function_call(
1018
1003
auto &write_set = cfg_info.get_write_set (target);
1019
1004
1020
1005
// Instrument the lhs if any.
1021
- if (target->call_lhs ().is_not_nil ())
1006
+ if (target->call_lhs ().is_not_nil () && cfg_info. must_check_lhs (target) )
1022
1007
{
1023
1008
instrument_lhs (
1024
1009
function_id, target, target->call_lhs (), goto_program, cfg_info);
0 commit comments