Skip to content

Commit 9f7b844

Browse files
lucasccordeirotautschnig
authored andcommitted
default variant of instrument_cover_goals that uses an empty set of existing goals
Signed-off-by: Lucas Cordeiro <[email protected]>
1 parent 82a83e5 commit 9f7b844

File tree

3 files changed

+15
-82
lines changed

3 files changed

+15
-82
lines changed

src/goto-instrument/cover.cpp

Lines changed: 12 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -933,15 +933,10 @@ void instrument_cover_goals(
933933
source_locationt source_location=
934934
basic_blocks.source_location_map[block_nr];
935935

936-
<<<<<<< HEAD
937-
if(!source_location.get_file().empty() &&
938-
!source_location.is_built_in())
939-
=======
940936
//check whether the current goal already exists
941937
if(goals.is_existing_goal(source_location.get_line().c_str()) &&
942-
!source_location.get_file().empty() &&
943-
source_location.get_file()[0]!='<')
944-
>>>>>>> generate goals only if they do not exist in the json file
938+
!source_location.get_file().empty() &&
939+
!source_location.is_built_in())
945940
{
946941
std::string comment="block "+b;
947942
goto_program.insert_before_swap(i_it);
@@ -1200,80 +1195,20 @@ void instrument_cover_goals(
12001195
}
12011196
}
12021197

1203-
bool instrument_cover_goals(
1204-
const cmdlinet &cmdline,
1198+
void instrument_cover_goals(
12051199
const symbol_tablet &symbol_table,
12061200
goto_functionst &goto_functions,
1207-
message_handlert &msgh)
1201+
coverage_criteriont criterion)
12081202
{
1209-
messaget msg(msgh);
1210-
std::list<std::string> criteria_strings=cmdline.get_values("cover");
1211-
std::set<coverage_criteriont> criteria;
1212-
bool keep_assertions=false;
1213-
1214-
for(const auto &criterion_string : criteria_strings)
1215-
{
1216-
coverage_criteriont c;
1217-
1218-
if(criterion_string=="assertion" || criterion_string=="assertions")
1219-
{
1220-
keep_assertions=true;
1221-
c=coverage_criteriont::ASSERTION;
1222-
}
1223-
else if(criterion_string=="path" || criterion_string=="paths")
1224-
c=coverage_criteriont::PATH;
1225-
else if(criterion_string=="branch" || criterion_string=="branches")
1226-
c=coverage_criteriont::BRANCH;
1227-
else if(criterion_string=="location" || criterion_string=="locations")
1228-
c=coverage_criteriont::LOCATION;
1229-
else if(criterion_string=="decision" || criterion_string=="decisions")
1230-
c=coverage_criteriont::DECISION;
1231-
else if(criterion_string=="condition" || criterion_string=="conditions")
1232-
c=coverage_criteriont::CONDITION;
1233-
else if(criterion_string=="mcdc")
1234-
c=coverage_criteriont::MCDC;
1235-
else if(criterion_string=="cover")
1236-
c=coverage_criteriont::COVER;
1237-
else
1238-
{
1239-
msg.error() << "unknown coverage criterion "
1240-
<< '\'' << criterion_string << '\''
1241-
<< messaget::eom;
1242-
return true;
1243-
}
1244-
1245-
criteria.insert(c);
1246-
}
1247-
1248-
if(keep_assertions && criteria_strings.size()>1)
1203+
Forall_goto_functions(f_it, goto_functions)
12491204
{
1250-
msg.error() << "assertion coverage cannot currently be used together with "
1251-
<< "other coverage criteria" << messaget::eom;
1252-
return true;
1253-
}
1254-
1255-
msg.status() << "Rewriting existing assertions as assumptions"
1256-
<< messaget::eom;
1205+
if(f_it->first==ID__start ||
1206+
f_it->first=="__CPROVER_initialize")
1207+
continue;
12571208

1258-
if(!keep_assertions)
1259-
{
1260-
// turn assertions (from generic checks) into assumptions
1261-
Forall_goto_functions(f_it, goto_functions)
1262-
{
1263-
goto_programt &body=f_it->second.body;
1264-
Forall_goto_program_instructions(i_it, body)
1265-
{
1266-
if(i_it->is_assert())
1267-
i_it->type=goto_program_instruction_typet::ASSUME;
1268-
}
1269-
}
1209+
//empty set of existing goals
1210+
coverage_goalst goals;
1211+
instrument_cover_goals(symbol_table, f_it->second.body,
1212+
criterion, goals);
12701213
}
1271-
1272-
msg.status() << "Instrumenting coverage goals" << messaget::eom;
1273-
1274-
for(const auto &criterion : criteria)
1275-
instrument_cover_goals(symbol_table, goto_functions, criterion);
1276-
1277-
goto_functions.update();
1278-
return false;
12791214
}

src/goto-instrument/cover.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ void instrument_cover_goals(
4646
coverage_criteriont,
4747
coverage_goalst &goals);
4848

49-
bool instrument_cover_goals(
50-
const cmdlinet &cmdline,
49+
void instrument_cover_goals(
5150
const symbol_tablet &symbol_table,
5251
goto_functionst &goto_functions,
53-
message_handlert &msgh);
52+
coverage_criteriont);
5453

5554
#endif // CPROVER_GOTO_INSTRUMENT_COVER_H

src/symex/symex_parse_options.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ bool symex_parse_optionst::process_goto_program(const optionst &options)
362362
}
363363

364364
status() << "Instrumenting coverge goals" << eom;
365-
coverage_goalst goals;
366-
instrument_cover_goals(symbol_table, goto_model.goto_functions, c, goals);
365+
instrument_cover_goals(symbol_table, goto_model.goto_functions, c);
367366
goto_model.goto_functions.update();
368367
}
369368

0 commit comments

Comments
 (0)