@@ -142,9 +142,9 @@ bool coverage_goalst::get_coverage_goals(
142
142
for (const auto &each_goal : goals_in_json[" goals" ].array )
143
143
{
144
144
// get and set the bytecode_index
145
- irep_idt bytecode_index =
145
+ irep_idt bytecodeIndex =
146
146
each_goal[" sourceLocation" ][" bytecode_index" ].value ;
147
- source_location.set_java_bytecode_index (bytecode_index );
147
+ source_location.set_java_bytecode_index (bytecodeIndex );
148
148
149
149
// get and set the file
150
150
irep_idt file=each_goal[" sourceLocation" ][" file" ].value ;
@@ -166,25 +166,47 @@ bool coverage_goalst::get_coverage_goals(
166
166
return false ;
167
167
}
168
168
169
+ // / store existing goal
170
+ // / \param goal: source location of the existing goal
169
171
void coverage_goalst::add_goal (source_locationt goal)
170
172
{
171
- existing_goals.push_back (goal);
173
+ existing_goals[goal]=false ;
174
+ }
175
+
176
+ // / check whether we have an existing goal that is uncovered
177
+ // / \param msg: message to be printed about the uncovered goal
178
+ void coverage_goalst::check_uncovered_goals (messaget msg)
179
+ {
180
+ for (auto const &existing_loc : existing_goals)
181
+ {
182
+ if (!existing_loc.second )
183
+ {
184
+ msg.warning () << " Warning: existing goal in file "
185
+ << existing_loc.first .get_file ()
186
+ << " line " << existing_loc.first .get_line ()
187
+ << " function " << existing_loc.first .get_function ()
188
+ << " is uncovered" << messaget::eom;
189
+ }
190
+ }
172
191
}
173
192
174
193
// / compare the value of the current goal to the existing ones
175
194
// / \param source_loc: source location of the current goal
176
195
// / \return true : if the current goal exists false : otherwise
177
- bool coverage_goalst::is_existing_goal (source_locationt source_loc) const
196
+ bool coverage_goalst::is_existing_goal (source_locationt source_loc)
178
197
{
179
- for (const auto &existing_loc : existing_goals)
198
+ for (auto const &existing_loc : existing_goals)
180
199
{
181
- if ((source_loc.get_file ()==existing_loc.get_file ()) &&
182
- (source_loc.get_function ()==existing_loc.get_function ()) &&
183
- (source_loc.get_line ()==existing_loc.get_line ()) &&
200
+ if ((source_loc.get_file ()==existing_loc.first . get_file ()) &&
201
+ (source_loc.get_function ()==existing_loc.first . get_function ()) &&
202
+ (source_loc.get_line ()==existing_loc.first . get_line ()) &&
184
203
(source_loc.get_java_bytecode_index ().empty () ||
185
204
(source_loc.get_java_bytecode_index ()==
186
- existing_loc.get_java_bytecode_index ())))
187
- return true ;
205
+ existing_loc.first .get_java_bytecode_index ())))
206
+ {
207
+ existing_goals[existing_loc.first ]=true ;
208
+ return true ;
209
+ }
188
210
}
189
211
return false ;
190
212
}
@@ -998,7 +1020,7 @@ void instrument_cover_goals(
998
1020
const symbol_tablet &symbol_table,
999
1021
goto_programt &goto_program,
1000
1022
coverage_criteriont criterion,
1001
- const coverage_goalst &goals,
1023
+ coverage_goalst &goals,
1002
1024
bool function_only,
1003
1025
bool ignore_trivial)
1004
1026
{
@@ -1342,7 +1364,7 @@ void instrument_cover_goals(
1342
1364
const symbol_tablet &symbol_table,
1343
1365
goto_functionst &goto_functions,
1344
1366
coverage_criteriont criterion,
1345
- const coverage_goalst &goals,
1367
+ coverage_goalst &goals,
1346
1368
bool function_only,
1347
1369
bool ignore_trivial)
1348
1370
{
@@ -1450,10 +1472,10 @@ bool instrument_cover_goals(
1450
1472
}
1451
1473
1452
1474
// check existing test goals
1453
- coverage_goalst existing_goals;
1475
+ static coverage_goalst existing_goals;
1454
1476
if (cmdline.isset (" existing-coverage" ))
1455
1477
{
1456
- msg.status () << " Check existing coverage goals" << messaget::eom;
1478
+ msg.status () << " Add existing coverage goals" << messaget::eom;
1457
1479
// get file with covered test goals
1458
1480
const std::string coverage=cmdline.get_value (" existing-coverage" );
1459
1481
// get a coverage_goalst object
@@ -1477,6 +1499,10 @@ bool instrument_cover_goals(
1477
1499
cmdline.isset (" no-trivial-tests" ));
1478
1500
}
1479
1501
1502
+ // check whether all existing goals have been covered
1503
+ msg.status () << " Checking uncovered goals" << messaget::eom;
1504
+ existing_goals.check_uncovered_goals (msg);
1505
+
1480
1506
if (cmdline.isset (" cover-traces-must-terminate" ))
1481
1507
{
1482
1508
// instrument an additional goal in CPROVER_START. This will rephrase
0 commit comments