Skip to content

Commit ebaa2c2

Browse files
Vojtech Forejtforejtv
Vojtech Forejt
authored andcommitted
get_cover_config is now called separately from instrument_cover_goals
1 parent 11c93bb commit ebaa2c2

File tree

6 files changed

+40
-17
lines changed

6 files changed

+40
-17
lines changed

jbmc/src/jdiff/jdiff_parse_options.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,12 @@ bool jdiff_parse_optionst::process_goto_program(
321321
// instrument cover goals
322322
if(cmdline.isset("cover"))
323323
{
324-
if(instrument_cover_goals(options, goto_model, get_message_handler()))
324+
const auto cover_config = get_cover_config(
325+
options, goto_model.symbol_table, get_message_handler());
326+
if(!cover_config)
327+
return true;
328+
if(instrument_cover_goals(
329+
options, *cover_config, goto_model, get_message_handler()))
325330
return true;
326331
}
327332

jbmc/unit/java_bytecode/java_virtual_functions/virtual_functions.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,15 @@ SCENARIO(
127127
{
128128
optionst options;
129129
options.set_option("cover", "location");
130-
REQUIRE_FALSE(
131-
instrument_cover_goals(
132-
options, new_table, new_goto_functions, null_message_handler));
130+
const auto cover_config =
131+
get_cover_config(options, new_table, null_message_handler);
132+
REQUIRE(cover_config);
133+
REQUIRE_FALSE(instrument_cover_goals(
134+
options,
135+
*cover_config,
136+
new_table,
137+
new_goto_functions,
138+
null_message_handler));
133139

134140
auto function = new_goto_functions.function_map.find(function_name);
135141
REQUIRE(function != new_goto_functions.function_map.end());

src/cbmc/cbmc_parse_options.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,12 @@ bool cbmc_parse_optionst::process_goto_program(
860860
// instrument cover goals
861861
if(options.is_set("cover"))
862862
{
863-
if(instrument_cover_goals(options, goto_model, log.get_message_handler()))
863+
const auto cover_config = get_cover_config(
864+
options, goto_model.symbol_table, log.get_message_handler());
865+
if(!cover_config)
866+
return true;
867+
if(instrument_cover_goals(
868+
options, *cover_config, goto_model, log.get_message_handler()))
864869
return true;
865870
}
866871

src/goto-diff/goto_diff_parse_options.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ bool goto_diff_parse_optionst::process_goto_program(
363363
// for coverage annotation:
364364
remove_skip(goto_model);
365365

366-
if(instrument_cover_goals(options, goto_model, get_message_handler()))
366+
const auto cover_config = get_cover_config(
367+
options, goto_model.symbol_table, get_message_handler());
368+
if(!cover_config)
369+
return true;
370+
if(instrument_cover_goals(
371+
options, *cover_config, goto_model, get_message_handler()))
367372
return true;
368373
}
369374

src/goto-instrument/cover.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@ void instrument_cover_goals(
329329

330330
/// Instruments goto functions based on given command line options
331331
/// \param options: the options
332+
/// \param cover_config: configuration, produced using get_cover_config
332333
/// \param symbol_table: the symbol table
333334
/// \param goto_functions: the goto functions
334335
/// \param message_handler: a message handler
335336
bool instrument_cover_goals(
336337
const optionst &options,
338+
const cover_configt &cover_config,
337339
const symbol_tablet &symbol_table,
338340
goto_functionst &goto_functions,
339341
message_handlert &message_handler)
@@ -342,13 +344,8 @@ bool instrument_cover_goals(
342344
msg.status() << "Rewriting existing assertions as assumptions"
343345
<< messaget::eom;
344346

345-
std::unique_ptr<cover_configt> cover_config =
346-
get_cover_config(options, symbol_table, message_handler);
347-
if(!cover_config)
348-
return true;
349-
350347
if(
351-
cover_config->traces_must_terminate &&
348+
cover_config.traces_must_terminate &&
352349
!goto_functions.function_map.count(goto_functions.entry_point()))
353350
{
354351
msg.error() << "cover-traces-must-terminate: invalid entry point ["
@@ -359,29 +356,31 @@ bool instrument_cover_goals(
359356
Forall_goto_functions(f_it, goto_functions)
360357
{
361358
const symbolt function_symbol = symbol_table.lookup_ref(f_it->first);
362-
cover_config->mode = function_symbol.mode;
363359
instrument_cover_goals(
364-
*cover_config, function_symbol, f_it->second, message_handler);
360+
cover_config, function_symbol, f_it->second, message_handler);
365361
}
366362
goto_functions.compute_location_numbers();
367363

368-
cover_config->function_filters.report_anomalies();
369-
cover_config->goal_filters.report_anomalies();
364+
cover_config.function_filters.report_anomalies();
365+
cover_config.goal_filters.report_anomalies();
370366

371367
return false;
372368
}
373369

374370
/// Instruments a goto model based on given command line options
375371
/// \param options: the options
372+
/// \param cover_config: configuration, produced using get_cover_config
376373
/// \param goto_model: the goto model
377374
/// \param message_handler: a message handler
378375
bool instrument_cover_goals(
379376
const optionst &options,
377+
const cover_configt &cover_config,
380378
goto_modelt &goto_model,
381379
message_handlert &message_handler)
382380
{
383381
return instrument_cover_goals(
384382
options,
383+
cover_config,
385384
goto_model.symbol_table,
386385
goto_model.goto_functions,
387386
message_handler);

src/goto-instrument/cover.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Date: May 2016
1414
#ifndef CPROVER_GOTO_INSTRUMENT_COVER_H
1515
#define CPROVER_GOTO_INSTRUMENT_COVER_H
1616

17-
#include <goto-programs/goto_model.h>
1817
#include "cover_filter.h"
1918
#include "cover_instrument.h"
2019

@@ -46,12 +45,14 @@ struct cover_configt
4645

4746
void instrument_cover_goals(
4847
const symbol_tablet &,
48+
const cover_configt &,
4949
goto_functionst &,
5050
coverage_criteriont,
5151
message_handlert &message_handler);
5252

5353
void instrument_cover_goals(
5454
const symbol_tablet &,
55+
const cover_configt &,
5556
goto_programt &,
5657
coverage_criteriont,
5758
message_handlert &message_handler);
@@ -68,12 +69,14 @@ void parse_cover_options(const cmdlinet &, optionst &);
6869

6970
bool instrument_cover_goals(
7071
const optionst &,
72+
const cover_configt &,
7173
const symbol_tablet &,
7274
goto_functionst &,
7375
message_handlert &);
7476

7577
bool instrument_cover_goals(
7678
const optionst &,
79+
const cover_configt &,
7780
goto_modelt &,
7881
message_handlert &);
7982

0 commit comments

Comments
 (0)