@@ -55,31 +55,15 @@ void symex_slice_by_tracet::slice_by_trace(
55
55
idx=next;
56
56
}
57
57
58
- exprt trace_condition;
59
-
60
- if (trace_conditions.size ()==1 )
61
- {
62
- trace_condition=trace_conditions[0 ];
63
- }
64
- else
65
- {
66
- trace_condition=exprt (ID_and, typet (ID_bool));
67
- trace_condition.operands ().reserve (trace_conditions.size ());
68
- for (std::vector<exprt>::iterator i=trace_conditions.begin ();
69
- i!=trace_conditions.end (); i++)
70
- {
71
- trace_condition.move_to_operands (*i);
72
- }
73
- }
58
+ exprt trace_condition = conjunction (trace_conditions);
74
59
75
60
simplify (trace_condition, ns);
76
61
77
62
std::set<exprt> implications=implied_guards (trace_condition);
78
63
79
- for (std::set<exprt>::iterator i=sliced_guards.begin (); i !=
80
- sliced_guards.end (); i++)
64
+ for (const auto &guard : sliced_guards)
81
65
{
82
- exprt g_copy (*i );
66
+ exprt g_copy (guard );
83
67
84
68
DATA_INVARIANT (
85
69
g_copy.id () == ID_symbol || g_copy.id () == ID_not ||
@@ -300,27 +284,29 @@ void symex_slice_by_tracet::compute_ts_back(
300
284
{
301
285
std::list<exprt> eq_conds;
302
286
std::list<exprt>::iterator pvi=i->io_args .begin ();
303
- for (std::vector<irep_idt>::iterator k=sigma_vals[j]. begin ();
304
- k!= sigma_vals[j]. end (); k++ )
287
+
288
+ for ( const auto &sigma_val : sigma_vals[j])
305
289
{
306
290
exprt equal_cond=exprt (ID_equal, bool_typet ());
307
291
equal_cond.operands ().reserve (2 );
308
292
equal_cond.copy_to_operands (*pvi);
309
293
// Should eventually change to handle non-bv types!
310
- exprt constant_value=
311
- from_integer ( unsafe_string2int (id2string (*k )), (*pvi).type ());
294
+ exprt constant_value = from_integer (
295
+ unsafe_string2int (id2string (sigma_val )), (*pvi).type ());
312
296
equal_cond.move_to_operands (constant_value);
313
297
eq_conds.push_back (equal_cond);
314
298
pvi++;
315
299
}
300
+
316
301
exprt val_merge=exprt (ID_and, typet (ID_bool));
317
302
val_merge.operands ().reserve (eq_conds.size ()+1 );
318
303
val_merge.copy_to_operands (merge[j+1 ]);
319
- for (std::list<exprt>::iterator k=eq_conds. begin ();
320
- k!= eq_conds. end (); k++ )
304
+
305
+ for ( const auto &eq_cond : eq_conds)
321
306
{
322
- val_merge.copy_to_operands (*k );
307
+ val_merge.copy_to_operands (eq_cond );
323
308
}
309
+
324
310
u_lhs.move_to_operands (val_merge);
325
311
}
326
312
else
@@ -384,23 +370,20 @@ void symex_slice_by_tracet::slice_SSA_steps(
384
370
size_t location_SSA_steps=0 ;
385
371
size_t trace_loc_sliced=0 ;
386
372
387
- for (symex_target_equationt::SSA_stepst::iterator
388
- it=equation.SSA_steps .begin ();
389
- it!=equation.SSA_steps .end ();
390
- it++)
373
+ for (auto &SSA_step : equation.SSA_steps )
391
374
{
392
- if (it-> is_output ())
375
+ if (SSA_step. is_output ())
393
376
trace_SSA_steps++;
394
- if (it-> is_location ())
377
+ if (SSA_step. is_location ())
395
378
location_SSA_steps++;
396
379
bool sliced_SSA_step=false ;
397
- exprt guard=it-> guard ;
380
+ exprt guard = SSA_step. guard ;
398
381
399
382
simplify (guard, ns);
400
383
401
384
if (!guard.is_true ())
402
385
potential_SSA_steps++;
403
- // it-> output(ns,std::cout);
386
+ // SSA_step. output(ns,std::cout);
404
387
// std::cout << "-----------------\n";
405
388
406
389
if ((guard.id ()==ID_symbol) || (guard.id () == ID_not))
@@ -409,11 +392,11 @@ void symex_slice_by_tracet::slice_SSA_steps(
409
392
410
393
if (implications.count (guard)!=0 )
411
394
{
412
- it-> cond_expr = true_exprt ();
413
- it-> ssa_rhs = true_exprt ();
414
- it-> guard = false_exprt ();
395
+ SSA_step. cond_expr = true_exprt ();
396
+ SSA_step. ssa_rhs = true_exprt ();
397
+ SSA_step. guard = false_exprt ();
415
398
sliced_SSA_steps++;
416
- if (it-> is_output () || it-> is_location ())
399
+ if (SSA_step. is_output () || SSA_step. is_location ())
417
400
trace_loc_sliced++;
418
401
sliced_SSA_step=true ;
419
402
}
@@ -427,11 +410,11 @@ void symex_slice_by_tracet::slice_SSA_steps(
427
410
428
411
if (implications.count (neg_expr)!=0 )
429
412
{
430
- it-> cond_expr = true_exprt ();
431
- it-> ssa_rhs = true_exprt ();
432
- it-> guard = false_exprt ();
413
+ SSA_step. cond_expr = true_exprt ();
414
+ SSA_step. ssa_rhs = true_exprt ();
415
+ SSA_step. guard = false_exprt ();
433
416
sliced_SSA_steps++;
434
- if (it-> is_output () || it-> is_location ())
417
+ if (SSA_step. is_output () || SSA_step. is_location ())
435
418
trace_loc_sliced++;
436
419
sliced_SSA_step=true ;
437
420
break ; // Sliced, so no need to consider the rest
@@ -443,32 +426,32 @@ void symex_slice_by_tracet::slice_SSA_steps(
443
426
}
444
427
}
445
428
446
- if (!sliced_SSA_step && it-> is_assignment ())
429
+ if (!sliced_SSA_step && SSA_step. is_assignment ())
447
430
{
448
- if (it-> ssa_rhs .id ()== ID_if)
431
+ if (SSA_step. ssa_rhs .id () == ID_if)
449
432
{
450
433
conds_seen++;
451
- exprt cond_copy (to_if_expr (it-> ssa_rhs ).cond ());
434
+ exprt cond_copy (to_if_expr (SSA_step. ssa_rhs ).cond ());
452
435
simplify (cond_copy, ns);
453
436
454
437
if (implications.count (cond_copy)!=0 )
455
438
{
456
439
sliced_conds++;
457
- exprt t_copy1 (to_if_expr (it-> ssa_rhs ).true_case ());
458
- exprt t_copy2 (to_if_expr (it-> ssa_rhs ).true_case ());
459
- it-> ssa_rhs = t_copy1;
460
- it-> cond_expr .op1 ().swap (t_copy2);
440
+ exprt t_copy1 (to_if_expr (SSA_step. ssa_rhs ).true_case ());
441
+ exprt t_copy2 (to_if_expr (SSA_step. ssa_rhs ).true_case ());
442
+ SSA_step. ssa_rhs = t_copy1;
443
+ SSA_step. cond_expr .op1 ().swap (t_copy2);
461
444
}
462
445
else
463
446
{
464
447
cond_copy = simplify_expr (boolean_negate (cond_copy), ns);
465
448
if (implications.count (cond_copy)!=0 )
466
449
{
467
450
sliced_conds++;
468
- exprt f_copy1 (to_if_expr (it-> ssa_rhs ).false_case ());
469
- exprt f_copy2 (to_if_expr (it-> ssa_rhs ).false_case ());
470
- it-> ssa_rhs = f_copy1;
471
- it-> cond_expr .op1 ().swap (f_copy2);
451
+ exprt f_copy1 (to_if_expr (SSA_step. ssa_rhs ).false_case ());
452
+ exprt f_copy2 (to_if_expr (SSA_step. ssa_rhs ).false_case ());
453
+ SSA_step. ssa_rhs = f_copy1;
454
+ SSA_step. cond_expr .op1 ().swap (f_copy2);
472
455
}
473
456
}
474
457
}
@@ -565,15 +548,13 @@ std::set<exprt> symex_slice_by_tracet::implied_guards(exprt e)
565
548
}
566
549
else if (e.id ()==ID_and)
567
550
{ // Descend into and
568
- Forall_operands (it, e )
551
+ for ( const auto &conjunct : e. operands () )
569
552
{
570
- std::set<exprt> r=implied_guards (*it);
571
- for (std::set<exprt>::iterator i=r.begin ();
572
- i!=r.end (); i++)
573
- {
574
- s.insert (*i);
575
- }
553
+ const auto imps = implied_guards (conjunct);
554
+ for (const auto &guard : imps)
555
+ s.insert (guard);
576
556
}
557
+
577
558
return s;
578
559
}
579
560
else if (e.id ()==ID_or)
@@ -611,11 +592,9 @@ bool symex_slice_by_tracet::implies_false(const exprt e)
611
592
{
612
593
std::set<exprt> imps=implied_guards (e);
613
594
614
- for (std::set<exprt>::iterator
615
- i=imps.begin ();
616
- i!=imps.end (); i++)
595
+ for (const auto &implied_guard : imps)
617
596
{
618
- exprt i_copy = boolean_negate (*i );
597
+ exprt i_copy = boolean_negate (implied_guard );
619
598
simplify (i_copy, ns);
620
599
if (imps.count (i_copy)!=0 )
621
600
return true ;
0 commit comments