16
16
#include < util/exception_utils.h>
17
17
#include < util/invariant.h>
18
18
#include < util/pointer_offset_size.h>
19
+ #include < util/range.h>
19
20
#include < util/std_expr.h>
20
21
21
22
#include < analyses/dirty.h>
@@ -362,29 +363,38 @@ void goto_symext::phi_function(
362
363
const statet::goto_statet &goto_state,
363
364
statet &dest_state)
364
365
{
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);
367
379
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);
370
384
371
385
guardt diff_guard;
372
-
373
- if (!variables.empty ())
386
+ if (!all_current_names_range.empty ())
374
387
{
375
388
diff_guard=goto_state.guard ;
376
389
377
390
// this gets the diff between the guards
378
391
diff_guard-=dest_state.guard ;
379
392
}
380
393
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)
385
395
{
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 ();
388
398
389
399
if (obj_identifier==guard_identifier)
390
400
continue ; // just a guard, don't bother
@@ -409,11 +419,12 @@ void goto_symext::phi_function(
409
419
// may have been introduced by symex_start_thread (and will
410
420
// only later be removed from level2.current_names by pop_frame
411
421
// 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 ))
414
425
continue ;
415
426
416
- exprt goto_state_rhs=*it , dest_state_rhs=*it ;
427
+ exprt goto_state_rhs = ssa , dest_state_rhs = ssa ;
417
428
418
429
{
419
430
const auto p_it = goto_state.propagation .find (l1_identifier);
@@ -459,7 +470,7 @@ void goto_symext::phi_function(
459
470
do_simplify (rhs);
460
471
}
461
472
462
- ssa_exprt new_lhs=*it ;
473
+ ssa_exprt new_lhs = ssa ;
463
474
const bool record_events=dest_state.record_events ;
464
475
dest_state.record_events =false ;
465
476
dest_state.assignment (new_lhs, rhs, ns, true , true );
0 commit comments