@@ -16,6 +16,7 @@ Author: Michael Tautschnig
16
16
17
17
#include " reaching_definitions.h"
18
18
19
+ #include < algorithm>
19
20
#include < memory>
20
21
21
22
#include < util/pointer_offset_size.h>
@@ -575,51 +576,78 @@ bool rd_range_domaint::merge(
575
576
locationt from,
576
577
locationt to)
577
578
{
578
- bool changed= false ;
579
+ bool changed = false ;
579
580
580
- if (other.has_values . is_false ())
581
+ if (other.is_bottom ())
581
582
{
582
- assert (other.values .empty ());
583
583
return false ;
584
584
}
585
585
586
- if (has_values. is_false ())
586
+ if (is_bottom ())
587
587
{
588
- assert (values.empty ());
589
- values=other.values ;
590
- assert (!other.has_values .is_true ());
591
- has_values=other.has_values ;
588
+ values = other.values ;
589
+
590
+ INVARIANT (!other.is_top (), " top unused" );
591
+ has_values = other.has_values ;
592
+
592
593
return true ;
593
594
}
594
- rd_range_domaint &o=const_cast <rd_range_domaint &>(other);
595
+
596
+ rd_range_domaint &o =
597
+ const_cast <rd_range_domaint &>(other);
595
598
values.swap (o.values );
596
- valuest::delta_viewt delta_view;
597
- o.values .get_delta_view (values, delta_view);
599
+
600
+ {
601
+ // Needed to set changed
602
+ typename valuest::delta_viewt delta_view_test;
603
+ values.get_delta_view (o.values , delta_view_test, false );
604
+
605
+ for (const auto &element : delta_view_test)
606
+ {
607
+ if (!element.in_both )
608
+ {
609
+ changed = true ;
610
+ break ;
611
+ }
612
+ }
613
+ }
614
+
615
+ typename valuest::delta_viewt delta_view;
616
+ o.values .get_delta_view (values, delta_view, false );
617
+
598
618
for (const auto &element : delta_view)
599
619
{
600
- bool in_both= element.in_both ;
601
- const irep_idt &k= element.k ;
602
- const values_innert &inner_other= element.m ; // in other
603
- const values_innert &inner= element.other_m ; // in this
620
+ bool in_both = element.in_both ;
621
+ const irep_idt &k = element.k ;
622
+ const values_innert &inner_other = element.m ; // in other
623
+ const values_innert &inner = element.other_m ; // in this
604
624
605
625
if (!in_both)
606
626
{
607
627
values.insert (k, inner_other);
608
- changed=true ;
609
628
}
610
629
else
611
630
{
612
- if (inner!=inner_other)
631
+ bool inner_is_superset = std::includes (
632
+ inner.begin (), inner.end (), inner_other.begin (), inner_other.end ());
633
+
634
+ if (!inner_is_superset)
613
635
{
614
- auto &v= values.find (k);
615
- assert (v.second );
636
+ auto &v = values.find (k);
637
+ INVARIANT (v.second , " key exists as in_both is true " );
616
638
617
- values_innert &inner=v.first ;
639
+ values_innert &inner = v.first ;
640
+ const values_innert copy (inner_other);
618
641
619
- size_t n=inner.size ();
620
642
inner.insert (inner_other.begin (), inner_other.end ());
621
- if (inner.size ()!=n)
622
- changed=true ;
643
+
644
+ if (inner != copy)
645
+ changed = true ;
646
+ }
647
+ else
648
+ {
649
+ if (inner != inner_other)
650
+ changed = true ;
623
651
}
624
652
}
625
653
}
0 commit comments