@@ -25,7 +25,6 @@ Date: May 2016
25
25
#include < util/cprover_prefix.h>
26
26
#include < util/config.h>
27
27
28
- #include < json/json_parser.h>
29
28
#include < util/message.h>
30
29
31
30
namespace
@@ -293,139 +292,6 @@ class basic_blockst
293
292
};
294
293
}
295
294
296
- bool coverage_goalst::get_coverage_goals (
297
- const std::string &coverage_file,
298
- message_handlert &message_handler,
299
- coverage_goalst &goals,
300
- const irep_idt &mode)
301
- {
302
- messaget message (message_handler);
303
- jsont json;
304
- source_locationt source_location;
305
-
306
- message.status () << " Load existing coverage goals\n " ;
307
-
308
- // check coverage file
309
- if (parse_json (coverage_file, message_handler, json))
310
- {
311
- message.error () << coverage_file << " file is not a valid json file"
312
- << messaget::eom;
313
- return true ;
314
- }
315
-
316
- // make sure that we have an array of elements
317
- if (!json.is_array ())
318
- {
319
- message.error () << " expecting an array in the " << coverage_file
320
- << " file, but got "
321
- << json << messaget::eom;
322
- return true ;
323
- }
324
-
325
- // traverse the given JSON file
326
- for (const auto &each_goal : json.array )
327
- {
328
- // ensure minimal requirements for a goal entry
329
- PRECONDITION (
330
- (!each_goal[" goal" ].is_null ()) ||
331
- (!each_goal[" sourceLocation" ][" bytecodeIndex" ].is_null ()) ||
332
- (!each_goal[" sourceLocation" ][" file" ].is_null () &&
333
- !each_goal[" sourceLocation" ][" function" ].is_null () &&
334
- !each_goal[" sourceLocation" ][" line" ].is_null ()));
335
-
336
- // check whether bytecodeIndex is provided for Java programs
337
- if (mode==ID_java &&
338
- each_goal[" sourceLocation" ][" bytecodeIndex" ].is_null ())
339
- {
340
- messaget message (message_handler);
341
- message.error () << coverage_file
342
- << " file does not contain bytecodeIndex"
343
- << messaget::eom;
344
- return true ;
345
- }
346
-
347
- if (!each_goal[" sourceLocation" ][" bytecodeIndex" ].is_null ())
348
- {
349
- // get and set the bytecodeIndex
350
- irep_idt bytecode_index=
351
- each_goal[" sourceLocation" ][" bytecodeIndex" ].value ;
352
- source_location.set_java_bytecode_index (bytecode_index);
353
- }
354
-
355
- if (!each_goal[" sourceLocation" ][" file" ].is_null ())
356
- {
357
- // get and set the file
358
- irep_idt file=each_goal[" sourceLocation" ][" file" ].value ;
359
- source_location.set_file (file);
360
- }
361
-
362
- if (!each_goal[" sourceLocation" ][" function" ].is_null ())
363
- {
364
- // get and set the function
365
- irep_idt function=each_goal[" sourceLocation" ][" function" ].value ;
366
- source_location.set_function (function);
367
- }
368
-
369
- if (!each_goal[" sourceLocation" ][" line" ].is_null ())
370
- {
371
- // get and set the line
372
- irep_idt line=each_goal[" sourceLocation" ][" line" ].value ;
373
- source_location.set_line (line);
374
- }
375
-
376
- // store the existing goal
377
- goals.add_goal (source_location);
378
- message.status () << " " << source_location << " \n " ;
379
- }
380
- message.status () << messaget::eom;
381
-
382
- return false ;
383
- }
384
-
385
- // / store existing goal
386
- // / \param goal: source location of the existing goal
387
- void coverage_goalst::add_goal (source_locationt goal)
388
- {
389
- existing_goals[goal]=false ;
390
- }
391
-
392
- // / check whether we have an existing goal that does not match
393
- // / an instrumented goal
394
- // / \param msg: Message stream
395
- void coverage_goalst::check_existing_goals (messaget &msg)
396
- {
397
- for (const auto &existing_loc : existing_goals)
398
- {
399
- if (!existing_loc.second )
400
- {
401
- msg.warning ()
402
- << " Warning: unmatched existing goal "
403
- << existing_loc.first << messaget::eom;
404
- }
405
- }
406
- }
407
-
408
- // / compare the value of the current goal to the existing ones
409
- // / \param source_loc: source location of the current goal
410
- // / \return true : if the current goal exists false : otherwise
411
- bool coverage_goalst::is_existing_goal (source_locationt source_loc)
412
- {
413
- for (const auto &existing_loc : existing_goals)
414
- {
415
- if ((source_loc.get_file ()==existing_loc.first .get_file ()) &&
416
- (source_loc.get_function ()==existing_loc.first .get_function ()) &&
417
- (source_loc.get_line ()==existing_loc.first .get_line ()) &&
418
- (source_loc.get_java_bytecode_index ().empty () ||
419
- (source_loc.get_java_bytecode_index ()==
420
- existing_loc.first .get_java_bytecode_index ())))
421
- {
422
- existing_goals[existing_loc.first ]=true ;
423
- return true ;
424
- }
425
- }
426
- return false ;
427
- }
428
-
429
295
const char *as_string (coverage_criteriont c)
430
296
{
431
297
switch (c)
@@ -1196,13 +1062,11 @@ void instrument_cover_goals(
1196
1062
message_handlert &message_handler,
1197
1063
bool function_only)
1198
1064
{
1199
- coverage_goalst goals; // empty already covered goals
1200
1065
instrument_cover_goals (
1201
1066
symbol_table,
1202
1067
goto_program,
1203
1068
criterion,
1204
1069
message_handler,
1205
- goals,
1206
1070
function_only,
1207
1071
false );
1208
1072
}
@@ -1238,7 +1102,6 @@ void instrument_cover_goals(
1238
1102
goto_programt &goto_program,
1239
1103
coverage_criteriont criterion,
1240
1104
message_handlert &message_handler,
1241
- coverage_goalst &goals,
1242
1105
bool function_only,
1243
1106
bool ignore_trivial)
1244
1107
{
@@ -1325,10 +1188,9 @@ void instrument_cover_goals(
1325
1188
basic_blocks.source_location_of (block_nr);
1326
1189
1327
1190
// check whether the current goal already exists
1328
- if (!goals.is_existing_goal (source_location) &&
1329
- !source_location.get_file ().empty () &&
1330
- !source_location.is_built_in () &&
1331
- cover_curr_function)
1191
+ if (
1192
+ !source_location.get_file ().empty () &&
1193
+ !source_location.is_built_in () && cover_curr_function)
1332
1194
{
1333
1195
std::string comment=" block " +b;
1334
1196
const irep_idt function=i_it->function ;
@@ -1597,7 +1459,6 @@ void instrument_cover_goals(
1597
1459
goto_functionst &goto_functions,
1598
1460
coverage_criteriont criterion,
1599
1461
message_handlert &message_handler,
1600
- coverage_goalst &goals,
1601
1462
bool function_only,
1602
1463
bool ignore_trivial,
1603
1464
const std::string &cover_include_pattern)
@@ -1623,7 +1484,6 @@ void instrument_cover_goals(
1623
1484
f_it->second .body ,
1624
1485
criterion,
1625
1486
message_handler,
1626
- goals,
1627
1487
function_only,
1628
1488
ignore_trivial);
1629
1489
}
@@ -1636,14 +1496,11 @@ void instrument_cover_goals(
1636
1496
message_handlert &message_handler,
1637
1497
bool function_only)
1638
1498
{
1639
- // empty set of existing goals
1640
- coverage_goalst goals;
1641
1499
instrument_cover_goals (
1642
1500
symbol_table,
1643
1501
goto_functions,
1644
1502
criterion,
1645
1503
message_handler,
1646
- goals,
1647
1504
function_only,
1648
1505
false ,
1649
1506
" " );
@@ -1718,26 +1575,6 @@ bool instrument_cover_goals(
1718
1575
}
1719
1576
}
1720
1577
1721
- // check existing test goals
1722
- coverage_goalst existing_goals;
1723
- if (cmdline.isset (" existing-coverage" ))
1724
- {
1725
- // get the mode to ensure invariants
1726
- // (e.g., bytecodeIndex for Java programs)
1727
- namespacet ns (symbol_table);
1728
- const irep_idt &mode=ns.lookup (goto_functions.entry_point ()).mode ;
1729
-
1730
- // get file with covered test goals
1731
- const std::string coverage=cmdline.get_value (" existing-coverage" );
1732
- // get a coverage_goalst object
1733
- if (coverage_goalst::get_coverage_goals (
1734
- coverage, message_handler, existing_goals, mode))
1735
- {
1736
- msg.error () << " Loading existing coverage goals failed" << messaget::eom;
1737
- return true ;
1738
- }
1739
- }
1740
-
1741
1578
msg.status () << " Instrumenting coverage goals" << messaget::eom;
1742
1579
1743
1580
for (const auto &criterion : criteria)
@@ -1747,15 +1584,11 @@ bool instrument_cover_goals(
1747
1584
goto_functions,
1748
1585
criterion,
1749
1586
message_handler,
1750
- existing_goals,
1751
1587
cmdline.isset (" cover-function-only" ),
1752
1588
cmdline.isset (" no-trivial-tests" ),
1753
1589
cmdline.get_value (" cover-include-pattern" ));
1754
1590
}
1755
1591
1756
- // check whether all existing goals match with instrumented goals
1757
- existing_goals.check_existing_goals (msg);
1758
-
1759
1592
if (cmdline.isset (" cover-traces-must-terminate" ))
1760
1593
{
1761
1594
// instrument an additional goal in CPROVER_START. This will rephrase
0 commit comments