@@ -72,23 +72,6 @@ class basic_blockst
72
72
73
73
/* ******************************************************************\
74
74
75
- Function: coverage_goalst::coverage_goalst
76
-
77
- Inputs:
78
-
79
- Outputs:
80
-
81
- Purpose:
82
-
83
- \*******************************************************************/
84
-
85
- coverage_goalst::coverage_goalst ()
86
- {
87
- no_trivial_tests=false ;
88
- }
89
-
90
- /* ******************************************************************\
91
-
92
75
Function: coverage_goalst::get_coverage
93
76
94
77
Inputs:
@@ -105,7 +88,6 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
105
88
jsont json;
106
89
coverage_goalst goals;
107
90
source_locationt source_location;
108
- goals.set_no_trivial_tests (false );
109
91
110
92
// check coverage file
111
93
if (parse_json (coverage, message_handler, json))
@@ -151,7 +133,7 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
151
133
// get the line of each existing goal
152
134
line=(*itg)[" number" ].value ;
153
135
source_location.set_line (line);
154
- goals.set_goals (source_location);
136
+ goals.add_goal (source_location);
155
137
}
156
138
}
157
139
}
@@ -160,7 +142,7 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
160
142
161
143
/* ******************************************************************\
162
144
163
- Function: coverage_goalst::set_goals
145
+ Function: coverage_goalst::add_goal
164
146
165
147
Inputs:
166
148
@@ -170,7 +152,7 @@ Function: coverage_goalst::set_goals
170
152
171
153
\*******************************************************************/
172
154
173
- void coverage_goalst::set_goals (source_locationt goal)
155
+ void coverage_goalst::add_goal (source_locationt goal)
174
156
{
175
157
existing_goals.push_back (goal);
176
158
}
@@ -187,9 +169,9 @@ Function: coverage_goalst::is_existing_goal
187
169
188
170
\*******************************************************************/
189
171
190
- bool coverage_goalst::is_existing_goal (source_locationt source_location)
172
+ bool coverage_goalst::is_existing_goal (source_locationt source_location) const
191
173
{
192
- std::vector<source_locationt>::iterator it = existing_goals.begin ();
174
+ std::vector<source_locationt>::const_iterator it = existing_goals.begin ();
193
175
while (it!=existing_goals.end ())
194
176
{
195
177
if (!source_location.get_file ().compare (it->get_file ()) &&
@@ -1199,13 +1181,50 @@ void instrument_cover_goals(
1199
1181
coverage_criteriont criterion,
1200
1182
bool function_only)
1201
1183
{
1202
- coverage_goalst goals; // empty
1184
+ coverage_goalst goals; // empty already covered goals
1203
1185
instrument_cover_goals (symbol_table,goto_program,
1204
1186
criterion,goals,function_only,false );
1205
1187
}
1206
1188
1207
1189
/* ******************************************************************\
1208
1190
1191
+ Function: consider_goals
1192
+
1193
+ Inputs:
1194
+
1195
+ Outputs:
1196
+
1197
+ Purpose:
1198
+
1199
+ \*******************************************************************/
1200
+
1201
+ bool consider_goals (const goto_programt &goto_program)
1202
+ {
1203
+ bool result;
1204
+ unsigned long count_assignments=0 , count_goto=0 , count_decl=0 ;
1205
+
1206
+ forall_goto_program_instructions (i_it, goto_program)
1207
+ {
1208
+ if (i_it->is_goto ())
1209
+ ++count_goto;
1210
+ else if (i_it->is_assign ())
1211
+ ++count_assignments;
1212
+ else if (i_it->is_decl ())
1213
+ ++count_decl;
1214
+ }
1215
+
1216
+ // check whether this is a constructor/destructor or a get/set (pattern)
1217
+ if (!count_goto && !count_assignments && !count_decl)
1218
+ result=false ;
1219
+ else
1220
+ result = !((count_decl==0 ) && (count_goto<=1 ) &&
1221
+ (count_assignments>0 && count_assignments<5 ));
1222
+
1223
+ return result;
1224
+ }
1225
+
1226
+ /* ******************************************************************\
1227
+
1209
1228
Function: instrument_cover_goals
1210
1229
1211
1230
Inputs:
@@ -1554,10 +1573,10 @@ Function: instrument_cover_goals
1554
1573
void instrument_cover_goals (
1555
1574
const symbol_tablet &symbol_table,
1556
1575
goto_functionst &goto_functions,
1557
- coverage_criteriont,
1576
+ coverage_criteriont criterion ,
1558
1577
const coverage_goalst &goals,
1559
- bool function_only= false ,
1560
- bool ignore_trivial= false )
1578
+ bool function_only,
1579
+ bool ignore_trivial)
1561
1580
{
1562
1581
Forall_goto_functions (f_it, goto_functions)
1563
1582
{
@@ -1588,45 +1607,8 @@ void instrument_cover_goals(
1588
1607
coverage_criteriont criterion,
1589
1608
bool function_only)
1590
1609
{
1610
+ coverage_goalst goals; // empty already covered goals
1591
1611
instrument_cover_goals (symbol_table, goto_functions,
1592
1612
criterion, goals, function_only, false );
1593
1613
}
1594
1614
1595
- /* ******************************************************************\
1596
-
1597
- Function: consider_goals
1598
-
1599
- Inputs:
1600
-
1601
- Outputs:
1602
-
1603
- Purpose:
1604
-
1605
- \*******************************************************************/
1606
-
1607
- bool consider_goals (const goto_programt &goto_program)
1608
- {
1609
- bool result;
1610
- unsigned long count_assignments=0 , count_goto=0 , count_decl=0 ;
1611
-
1612
- forall_goto_program_instructions (i_it, goto_program)
1613
- {
1614
- if (i_it->is_goto ())
1615
- ++count_goto;
1616
- else if (i_it->is_assign ())
1617
- ++count_assignments;
1618
- else if (i_it->is_decl ())
1619
- ++count_decl;
1620
- }
1621
-
1622
- // check whether this is a constructor/destructor or a get/set (pattern)
1623
- if (!count_goto && !count_assignments && !count_decl)
1624
- result=false ;
1625
- else
1626
- result = !((count_decl==0 ) && (count_goto<=1 ) &&
1627
- (count_assignments>0 && count_assignments<5 ));
1628
-
1629
- return result;
1630
- }
1631
-
1632
-
0 commit comments