@@ -85,7 +85,10 @@ void symex_assignt::assign_rec(
85
85
{
86
86
const typet &type = to_member_expr (lhs).struct_op ().type ();
87
87
if (type.id () == ID_struct || type.id () == ID_struct_tag)
88
- assign_struct_member (to_member_expr (lhs), full_lhs, rhs, guard);
88
+ {
89
+ assign_struct_member<use_update ()>(
90
+ to_member_expr (lhs), full_lhs, rhs, guard);
91
+ }
89
92
else if (type.id () == ID_union || type.id () == ID_union_tag)
90
93
{
91
94
// should have been replaced by byte_extract
@@ -499,6 +502,7 @@ void symex_assignt::assign_array(
499
502
}
500
503
}
501
504
505
+ template <bool use_update>
502
506
void symex_assignt::assign_struct_member (
503
507
const member_exprt &lhs,
504
508
const exprt &full_lhs,
@@ -534,35 +538,30 @@ void symex_assignt::assign_struct_member(
534
538
535
539
const irep_idt &component_name=lhs.get_component_name ();
536
540
537
- #ifdef USE_UPDATE
538
-
539
- // turn
540
- // a.c=e
541
- // into
542
- // a'==UPDATE(a, .c, e)
543
-
544
- update_exprt new_rhs (lhs_struct.type ());
545
- new_rhs.old ()=lhs_struct;
546
- new_rhs.designator ().push_back (member_designatort (component_name));
547
- new_rhs.new_value ()=rhs;
548
-
549
- exprt new_full_lhs=add_to_lhs (full_lhs, lhs);
550
-
551
- symex_assign_rec (
552
- state, lhs_struct, new_full_lhs, new_rhs, guard, assignment_type);
553
-
554
- #else
555
- // turn
556
- // a.c=e
557
- // into
558
- // a'==a WITH [c:=e]
541
+ if (use_update)
542
+ {
543
+ // turn
544
+ // a.c=e
545
+ // into
546
+ // a'==UPDATE(a, .c, e)
547
+ const update_exprt new_rhs{
548
+ lhs_struct, member_designatort (component_name), rhs};
549
+ const exprt new_full_lhs = add_to_lhs (full_lhs, lhs);
550
+ assign_rec (lhs_struct, new_full_lhs, new_rhs, guard);
551
+ }
552
+ else
553
+ {
554
+ // turn
555
+ // a.c=e
556
+ // into
557
+ // a'==a WITH [c:=e]
559
558
560
- with_exprt new_rhs (lhs_struct, exprt (ID_member_name), rhs);
561
- new_rhs.where ().set (ID_component_name, component_name);
559
+ with_exprt new_rhs (lhs_struct, exprt (ID_member_name), rhs);
560
+ new_rhs.where ().set (ID_component_name, component_name);
562
561
563
- exprt new_full_lhs= add_to_lhs (full_lhs, lhs);
564
- assign_rec (lhs_struct, new_full_lhs, new_rhs, guard);
565
- # endif
562
+ exprt new_full_lhs = add_to_lhs (full_lhs, lhs);
563
+ assign_rec (lhs_struct, new_full_lhs, new_rhs, guard);
564
+ }
566
565
}
567
566
568
567
void symex_assignt::assign_if (
0 commit comments