@@ -72,23 +72,6 @@ class basic_blockst
7272
7373/* ******************************************************************\
7474
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-
9275Function: coverage_goalst::get_coverage
9376
9477 Inputs:
@@ -105,7 +88,6 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
10588 jsont json;
10689 coverage_goalst goals;
10790 source_locationt source_location;
108- goals.set_no_trivial_tests (false );
10991
11092 // check coverage file
11193 if (parse_json (coverage, message_handler, json))
@@ -151,7 +133,7 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
151133 // get the line of each existing goal
152134 line=(*itg)[" number" ].value ;
153135 source_location.set_line (line);
154- goals.set_goals (source_location);
136+ goals.add_goal (source_location);
155137 }
156138 }
157139 }
@@ -160,7 +142,7 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
160142
161143/* ******************************************************************\
162144
163- Function: coverage_goalst::set_goals
145+ Function: coverage_goalst::add_goal
164146
165147 Inputs:
166148
@@ -170,7 +152,7 @@ Function: coverage_goalst::set_goals
170152
171153\*******************************************************************/
172154
173- void coverage_goalst::set_goals (source_locationt goal)
155+ void coverage_goalst::add_goal (source_locationt goal)
174156{
175157 existing_goals.push_back (goal);
176158}
@@ -187,9 +169,9 @@ Function: coverage_goalst::is_existing_goal
187169
188170\*******************************************************************/
189171
190- bool coverage_goalst::is_existing_goal (source_locationt source_location)
172+ bool coverage_goalst::is_existing_goal (source_locationt source_location) const
191173{
192- std::vector<source_locationt>::iterator it = existing_goals.begin ();
174+ std::vector<source_locationt>::const_iterator it = existing_goals.begin ();
193175 while (it!=existing_goals.end ())
194176 {
195177 if (!source_location.get_file ().compare (it->get_file ()) &&
@@ -1199,13 +1181,50 @@ void instrument_cover_goals(
11991181 coverage_criteriont criterion,
12001182 bool function_only)
12011183{
1202- coverage_goalst goals; // empty
1184+ coverage_goalst goals; // empty already covered goals
12031185 instrument_cover_goals (symbol_table,goto_program,
12041186 criterion,goals,function_only,false );
12051187}
12061188
12071189/* ******************************************************************\
12081190
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+
12091228Function: instrument_cover_goals
12101229
12111230 Inputs:
@@ -1554,10 +1573,10 @@ Function: instrument_cover_goals
15541573void instrument_cover_goals (
15551574 const symbol_tablet &symbol_table,
15561575 goto_functionst &goto_functions,
1557- coverage_criteriont,
1576+ coverage_criteriont criterion ,
15581577 const coverage_goalst &goals,
1559- bool function_only= false ,
1560- bool ignore_trivial= false )
1578+ bool function_only,
1579+ bool ignore_trivial)
15611580{
15621581 Forall_goto_functions (f_it, goto_functions)
15631582 {
@@ -1588,45 +1607,8 @@ void instrument_cover_goals(
15881607 coverage_criteriont criterion,
15891608 bool function_only)
15901609{
1610+ coverage_goalst goals; // empty already covered goals
15911611 instrument_cover_goals (symbol_table, goto_functions,
15921612 criterion, goals, function_only, false );
15931613}
15941614
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