@@ -10,8 +10,11 @@ Date: May 2016
10
10
11
11
#include < algorithm>
12
12
#include < iterator>
13
+ #include < unordered_set>
13
14
15
+ #include < util/format_number_range.h>
14
16
#include < util/prefix.h>
17
+ #include < util/string2int.h>
15
18
16
19
#include " cover.h"
17
20
@@ -28,14 +31,38 @@ class basic_blockst
28
31
if (next_is_target || it->is_target ())
29
32
block_count++;
30
33
34
+ const irep_idt &line=it->source_location .get_line ();
35
+ if (!line.empty ())
36
+ block_line_cover_map[block_count]
37
+ .insert (unsafe_string2unsigned (id2string (line)));
38
+
31
39
block_map[it]=block_count;
32
40
33
41
if (!it->source_location .is_nil () &&
34
42
source_location_map.find (block_count)==source_location_map.end ())
35
43
source_location_map[block_count]=it->source_location ;
36
44
37
45
next_is_target=
46
+ #if 0
47
+ // Disabled for being too messy
38
48
it->is_goto() || it->is_function_call() || it->is_assume();
49
+ #else
50
+ it->is_goto () || it->is_function_call ();
51
+ #endif
52
+ }
53
+
54
+ // create list of covered lines as CSV string and set as property of source
55
+ // location of basic block, compress to ranges if applicable
56
+ format_number_ranget format_lines;
57
+ for (const auto &cover_set : block_line_cover_map)
58
+ {
59
+ assert (!cover_set.second .empty ());
60
+ std::vector<unsigned >
61
+ line_list{cover_set.second .begin (), cover_set.second .end ()};
62
+
63
+ std::string covered_lines=format_lines (line_list);
64
+ source_location_map[cover_set.first ]
65
+ .set_basic_block_covered_lines (covered_lines);
39
66
}
40
67
}
41
68
@@ -47,6 +74,11 @@ class basic_blockst
47
74
typedef std::map<unsigned , source_locationt> source_location_mapt;
48
75
source_location_mapt source_location_map;
49
76
77
+ // map block numbers to set of line numbers
78
+ typedef std::map<unsigned , std::unordered_set<unsigned > >
79
+ block_line_cover_mapt;
80
+ block_line_cover_mapt block_line_cover_map;
81
+
50
82
inline unsigned operator [](goto_programt::const_targett t)
51
83
{
52
84
return block_map[t];
@@ -414,7 +446,7 @@ std::set<exprt> collect_mcdc_controlling_nested(
414
446
const std::set<exprt> &decisions)
415
447
{
416
448
// To obtain the 1st-level controlling conditions
417
- std::set<exprt> controlling = collect_mcdc_controlling (decisions);
449
+ std::set<exprt> controlling= collect_mcdc_controlling (decisions);
418
450
419
451
std::set<exprt> result;
420
452
// For each controlling condition, to check if it contains
@@ -627,7 +659,7 @@ void remove_repetition(std::set<exprt> &exprs)
627
659
**/
628
660
for (auto &y : new_exprs)
629
661
{
630
- bool iden = true ;
662
+ bool iden= true ;
631
663
for (auto &c : conditions)
632
664
{
633
665
std::set<signed > signs1=sign_of_expr (c, x);
@@ -669,7 +701,7 @@ void remove_repetition(std::set<exprt> &exprs)
669
701
}
670
702
671
703
// update the original ''exprs''
672
- exprs = new_exprs;
704
+ exprs= new_exprs;
673
705
}
674
706
675
707
/* ******************************************************************\
@@ -838,7 +870,8 @@ bool is_mcdc_pair(
838
870
839
871
if (diff_count==1 )
840
872
return true ;
841
- else return false ;
873
+ else
874
+ return false ;
842
875
}
843
876
844
877
/* ******************************************************************\
@@ -963,7 +996,8 @@ void minimize_mcdc_controlling(
963
996
{
964
997
controlling=new_controlling;
965
998
}
966
- else break ;
999
+ else
1000
+ break ;
967
1001
}
968
1002
}
969
1003
@@ -1297,9 +1331,12 @@ void instrument_cover_goals(
1297
1331
const std::set<exprt> decisions=collect_decisions (i_it);
1298
1332
1299
1333
std::set<exprt> both;
1300
- std::set_union (conditions.begin (), conditions.end (),
1301
- decisions.begin (), decisions.end (),
1302
- inserter (both, both.end ()));
1334
+ std::set_union (
1335
+ conditions.begin (),
1336
+ conditions.end (),
1337
+ decisions.begin (),
1338
+ decisions.end (),
1339
+ inserter (both, both.end ()));
1303
1340
1304
1341
const source_locationt source_location=i_it->source_location ;
1305
1342
@@ -1397,6 +1434,9 @@ void instrument_cover_goals(
1397
1434
f_it->first ==" __CPROVER_initialize" )
1398
1435
continue ;
1399
1436
1400
- instrument_cover_goals (symbol_table, f_it->second .body , criterion);
1437
+ instrument_cover_goals (
1438
+ symbol_table,
1439
+ f_it->second .body ,
1440
+ criterion);
1401
1441
}
1402
1442
}
0 commit comments