@@ -16,6 +16,7 @@ Author: Daniel Kroening, kroening@kroening.com
1616#include < util/exception_utils.h>
1717#include < util/invariant.h>
1818#include < util/pointer_offset_size.h>
19+ #include < util/range.h>
1920#include < util/std_expr.h>
2021
2122#include < analyses/dirty.h>
@@ -362,29 +363,38 @@ void goto_symext::phi_function(
362363 const statet::goto_statet &goto_state,
363364 statet &dest_state)
364365{
365- // go over all variables to see what changed
366- std::unordered_set<ssa_exprt, irep_hash> variables;
366+ auto ssa_of_current_name =
367+ [&](const std::pair<irep_idt, std::pair<ssa_exprt, unsigned >> &pair) {
368+ return pair.second .first ;
369+ };
370+
371+ auto dest_state_names_range =
372+ make_range (dest_state.level2 .current_names )
373+ .filter (
374+ [&](const std::pair<irep_idt, std::pair<ssa_exprt, unsigned >> &pair) {
375+ // We ignore the identifiers that are already in goto_state names
376+ return goto_state.level2_current_names .count (pair.first ) == 0 ;
377+ })
378+ .map <const ssa_exprt>(ssa_of_current_name);
367379
368- goto_state.level2_get_variables (variables);
369- dest_state.level2 .get_variables (variables);
380+ // go over all variables to see what changed
381+ auto all_current_names_range = make_range (goto_state.level2_current_names )
382+ .map <const ssa_exprt>(ssa_of_current_name)
383+ .concat (dest_state_names_range);
370384
371385 guardt diff_guard;
372-
373- if (!variables.empty ())
386+ if (!all_current_names_range.empty ())
374387 {
375388 diff_guard=goto_state.guard ;
376389
377390 // this gets the diff between the guards
378391 diff_guard-=dest_state.guard ;
379392 }
380393
381- for (std::unordered_set<ssa_exprt, irep_hash>::const_iterator
382- it=variables.begin ();
383- it!=variables.end ();
384- it++)
394+ for (const auto &ssa : all_current_names_range)
385395 {
386- const irep_idt l1_identifier=it-> get_identifier ();
387- const irep_idt &obj_identifier=it-> get_object_name ();
396+ const irep_idt l1_identifier = ssa. get_identifier ();
397+ const irep_idt &obj_identifier = ssa. get_object_name ();
388398
389399 if (obj_identifier==guard_identifier)
390400 continue ; // just a guard, don't bother
@@ -409,11 +419,12 @@ void goto_symext::phi_function(
409419 // may have been introduced by symex_start_thread (and will
410420 // only later be removed from level2.current_names by pop_frame
411421 // once the thread is executed)
412- if (!it->get_level_0 ().empty () &&
413- it->get_level_0 ()!=std::to_string (dest_state.source .thread_nr ))
422+ if (
423+ !ssa.get_level_0 ().empty () &&
424+ ssa.get_level_0 () != std::to_string (dest_state.source .thread_nr ))
414425 continue ;
415426
416- exprt goto_state_rhs=*it , dest_state_rhs=*it ;
427+ exprt goto_state_rhs = ssa , dest_state_rhs = ssa ;
417428
418429 {
419430 const auto p_it = goto_state.propagation .find (l1_identifier);
@@ -459,7 +470,7 @@ void goto_symext::phi_function(
459470 do_simplify (rhs);
460471 }
461472
462- ssa_exprt new_lhs=*it ;
473+ ssa_exprt new_lhs = ssa ;
463474 const bool record_events=dest_state.record_events ;
464475 dest_state.record_events =false ;
465476 dest_state.assignment (new_lhs, rhs, ns, true , true );
0 commit comments