@@ -120,11 +120,9 @@ void collect_mcdc_controlling_rec(
120
120
}
121
121
else
122
122
{
123
- /* *
124
- * It may happen that ''is_condition(src)'' is valid,
125
- * but we ignore this case here as it can be handled
126
- * by the routine decision/condition detection.
127
- **/
123
+ // It may happen that ''is_condition(src)'' is valid,
124
+ // but we ignore this case here as it can be handled
125
+ // by the routine decision/condition detection.
128
126
}
129
127
}
130
128
@@ -174,11 +172,10 @@ collect_mcdc_controlling_nested(const std::set<exprt> &decisions)
174
172
for (auto &src : controlling)
175
173
{
176
174
std::set<exprt> s1, s2;
177
- /* *
178
- * The final controlling conditions resulted from ''src''
179
- * will be stored in ''s1''; ''s2'' is usd to hold the
180
- * temporary expansion.
181
- **/
175
+
176
+ // The final controlling conditions resulted from ''src''
177
+ // will be stored in ''s1''; ''s2'' is usd to hold the
178
+ // temporary expansion.
182
179
s1.insert (src);
183
180
184
181
// dual-loop structure to eliminate complex
@@ -204,11 +201,9 @@ collect_mcdc_controlling_nested(const std::set<exprt> &decisions)
204
201
for (std::size_t i = 0 ; i < operands.size (); i++)
205
202
{
206
203
std::set<exprt> res;
207
- /* *
208
- * To expand an operand if it is not atomic,
209
- * and label the ''changed'' flag; the resulted
210
- * expansion of such an operand is stored in ''res''.
211
- **/
204
+ // To expand an operand if it is not atomic,
205
+ // and label the ''changed'' flag; the resulted
206
+ // expansion of such an operand is stored in ''res''.
212
207
if (operands[i].id () == ID_not)
213
208
{
214
209
exprt no = operands[i].op0 ();
@@ -281,9 +276,7 @@ std::set<signed> sign_of_expr(const exprt &e, const exprt &E)
281
276
}
282
277
}
283
278
284
- /* *
285
- * In the general case, we analyze each operand of ''E''.
286
- **/
279
+ // In the general case, we analyze each operand of ''E''.
287
280
std::vector<exprt> ops;
288
281
collect_operands (E, ops);
289
282
for (auto &x : ops)
@@ -348,12 +341,10 @@ void remove_repetition(std::set<exprt> &exprs)
348
341
for (auto &x : exprs)
349
342
{
350
343
bool red = false ;
351
- /* *
352
- * To check if ''x'' is identical with some
353
- * expr in ''new_exprs''. Two exprs ''x''
354
- * and ''y'' are identical iff they have the
355
- * same sign for every atomic condition ''c''.
356
- **/
344
+ // To check if ''x'' is identical with some
345
+ // expr in ''new_exprs''. Two exprs ''x''
346
+ // and ''y'' are identical iff they have the
347
+ // same sign for every atomic condition ''c''.
357
348
for (auto &y : new_exprs)
358
349
{
359
350
bool iden = true ;
@@ -380,11 +371,9 @@ void remove_repetition(std::set<exprt> &exprs)
380
371
}
381
372
}
382
373
}
383
- /* *
384
- * If ''x'' is found identical w.r.t some
385
- * expr in ''new_conditions, we label it
386
- * and break.
387
- **/
374
+ // If ''x'' is found identical w.r.t some
375
+ // expr in ''new_conditions, we label it
376
+ // and break.
388
377
if (iden)
389
378
{
390
379
red = true ;
@@ -509,12 +498,10 @@ bool is_mcdc_pair(
509
498
eval_expr (atomic_exprs_e2, decision))
510
499
return false ;
511
500
512
- /* *
513
- * A mcdc pair of controlling exprs regarding ''c''
514
- * can have different values for only one atomic
515
- * expr, i.e., ''c''. Otherwise, they are not
516
- * a mcdc pair.
517
- **/
501
+ // A mcdc pair of controlling exprs regarding ''c''
502
+ // can have different values for only one atomic
503
+ // expr, i.e., ''c''. Otherwise, they are not
504
+ // a mcdc pair.
518
505
int diff_count = 0 ;
519
506
auto e1_it = atomic_exprs_e1.begin ();
520
507
auto e2_it = atomic_exprs_e2.begin ();
@@ -577,22 +564,20 @@ void minimize_mcdc_controlling(
577
564
{
578
565
std::set<exprt> new_controlling;
579
566
bool ctrl_update = false ;
580
- /* *
581
- * Iteratively, we test that after removing an item ''x''
582
- * from the ''controlling'', can a complete mcdc coverage
583
- * over ''decision'' still be reserved?
584
- *
585
- * If yes, we update ''controlling'' with the
586
- * ''new_controlling'' without ''x''; otherwise, we should
587
- * keep ''x'' within ''controlling''.
588
- *
589
- * If in the end all elements ''x'' in ''controlling'' are
590
- * reserved, this means that current ''controlling'' set is
591
- * minimum and the ''while'' loop should be broken out of.
592
- *
593
- * Note: implementation here for the above procedure is
594
- * not (meant to be) optimal.
595
- **/
567
+ // Iteratively, we test that after removing an item ''x''
568
+ // from the ''controlling'', can a complete mcdc coverage
569
+ // over ''decision'' still be reserved?
570
+ //
571
+ // If yes, we update ''controlling'' with the
572
+ // ''new_controlling'' without ''x''; otherwise, we should
573
+ // keep ''x'' within ''controlling''.
574
+ //
575
+ // If in the end all elements ''x'' in ''controlling'' are
576
+ // reserved, this means that current ''controlling'' set is
577
+ // minimum and the ''while'' loop should be broken out of.
578
+ //
579
+ // Note: implementation here for the above procedure is
580
+ // not (meant to be) optimal.
596
581
for (auto &x : controlling)
597
582
{
598
583
// To create a new ''controlling'' set without ''x''
@@ -607,11 +592,9 @@ void minimize_mcdc_controlling(
607
592
for (auto &c : conditions)
608
593
{
609
594
bool cOK = has_mcdc_pair (c, new_controlling, conditions, decision);
610
- /* *
611
- * If there is no mcdc pair for an atomic condition ''c'',
612
- * then ''x'' should not be removed from the original
613
- * ''controlling'' set
614
- **/
595
+ // If there is no mcdc pair for an atomic condition ''c'',
596
+ // then ''x'' should not be removed from the original
597
+ // ''controlling'' set
615
598
if (!cOK)
616
599
{
617
600
removing_x = false ;
@@ -679,7 +662,6 @@ void cover_mcdc_instrumentert::instrument(
679
662
std::string comment_t = description + " `" + p_string + " ' true" ;
680
663
const irep_idt function = i_it->function ;
681
664
goto_program.insert_before_swap (i_it);
682
- // i_it->make_assertion(p);
683
665
i_it->make_assertion (not_exprt (p));
684
666
i_it->source_location = source_location;
685
667
i_it->source_location .set_comment (comment_t );
@@ -690,7 +672,6 @@ void cover_mcdc_instrumentert::instrument(
690
672
691
673
std::string comment_f = description + " `" + p_string + " ' false" ;
692
674
goto_program.insert_before_swap (i_it);
693
- // i_it->make_assertion(not_exprt(p));
694
675
i_it->make_assertion (p);
695
676
i_it->source_location = source_location;
696
677
i_it->source_location .set_comment (comment_f);
@@ -701,13 +682,14 @@ void cover_mcdc_instrumentert::instrument(
701
682
}
702
683
703
684
std::set<exprt> controlling;
704
- // controlling=collect_mcdc_controlling(decisions);
705
685
controlling = collect_mcdc_controlling_nested (decisions);
706
686
remove_repetition (controlling);
707
687
// for now, we restrict to the case of a single ''decision'';
708
688
// however, this is not true, e.g., ''? :'' operator.
709
- INVARIANT (!decisions.empty (), " There must be at least one decision" );
710
- minimize_mcdc_controlling (controlling, *decisions.begin ());
689
+ if (!decisions.empty ())
690
+ {
691
+ minimize_mcdc_controlling (controlling, *decisions.begin ());
692
+ }
711
693
712
694
for (const auto &p : controlling)
713
695
{
@@ -719,7 +701,6 @@ void cover_mcdc_instrumentert::instrument(
719
701
const irep_idt function = i_it->function ;
720
702
goto_program.insert_before_swap (i_it);
721
703
i_it->make_assertion (not_exprt (p));
722
- // i_it->make_assertion(p);
723
704
i_it->source_location = source_location;
724
705
i_it->source_location .set_comment (description);
725
706
i_it->source_location .set (ID_coverage_criterion, coverage_criterion);
0 commit comments