@@ -135,22 +135,23 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
135
135
source_locationt source_location;
136
136
goals.set_no_trivial_tests (false );
137
137
138
- // check coverage file
138
+ // check coverage file
139
139
if (parse_json (coverage, message_handler, json))
140
140
{
141
141
messaget message (message_handler);
142
142
message.error () << coverage << " file is not a valid json file"
143
143
<< messaget::eom;
144
- exit (0 );
144
+ exit (6 );
145
145
}
146
146
147
- // make sure that we have an array of elements
147
+ // make sure that we have an array of elements
148
148
if (!json.is_array ())
149
149
{
150
150
messaget message (message_handler);
151
- message.error () << " expecting an array in the " << coverage << " file, but got "
151
+ message.error () << " expecting an array in the " << coverage
152
+ << " file, but got "
152
153
<< json << messaget::eom;
153
- exit (0 );
154
+ exit (6 );
154
155
}
155
156
156
157
irep_idt file, function, line;
@@ -159,29 +160,28 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
159
160
it!=json.array .end ();
160
161
it++)
161
162
{
162
-
163
- // get the file of each existing goal
163
+ // get the file of each existing goal
164
164
file=(*it)[" file" ].value ;
165
165
source_location.set_file (file);
166
166
167
- // get the function of each existing goal
167
+ // get the function of each existing goal
168
168
function=(*it)[" function" ].value ;
169
169
source_location.set_function (function);
170
170
171
- // get the lines array
172
- if ((*it)[" lines" ].is_array ())
173
- {
174
- for (jsont::arrayt::const_iterator
175
- itg=(*it)[" lines" ].array .begin ();
176
- itg!=(*it)[" lines" ].array .end ();
177
- itg++)
178
- {
179
- // get the line of each existing goal
171
+ // get the lines array
172
+ if ((*it)[" lines" ].is_array ())
173
+ {
174
+ for (jsont::arrayt::const_iterator
175
+ itg=(*it)[" lines" ].array .begin ();
176
+ itg!=(*it)[" lines" ].array .end ();
177
+ itg++)
178
+ {
179
+ // get the line of each existing goal
180
180
line=(*itg)[" number" ].value ;
181
181
source_location.set_line (line);
182
182
goals.set_goals (source_location);
183
- }
184
- }
183
+ }
184
+ }
185
185
}
186
186
return goals;
187
187
}
@@ -218,12 +218,12 @@ Function: coverage_goalst::is_existing_goal
218
218
bool coverage_goalst::is_existing_goal (source_locationt source_location)
219
219
{
220
220
std::vector<source_locationt>::iterator it = existing_goals.begin ();
221
- while (it!=existing_goals.end ())
221
+ while (it!=existing_goals.end ())
222
222
{
223
- if (!source_location.get_file ().compare (it->get_file ()) &&
224
- !source_location.get_function ().compare (it->get_function ()) &&
225
- !source_location.get_line ().compare (it->get_line ()))
226
- break ;
223
+ if (!source_location.get_file ().compare (it->get_file ()) &&
224
+ !source_location.get_function ().compare (it->get_function ()) &&
225
+ !source_location.get_line ().compare (it->get_line ()))
226
+ break ;
227
227
++it;
228
228
}
229
229
if (it == existing_goals.end ())
@@ -1347,9 +1347,9 @@ void instrument_cover_goals(
1347
1347
source_locationt source_location=
1348
1348
basic_blocks.source_location_map [block_nr];
1349
1349
1350
- // check whether the current goal already exists
1350
+ // check whether the current goal already exists
1351
1351
if (goals.is_existing_goal (source_location) &&
1352
- !source_location.get_file ().empty () &&
1352
+ !source_location.get_file ().empty () &&
1353
1353
source_location.get_file ()[0 ]!=' <' )
1354
1354
{
1355
1355
std::string comment=" block " +b;
@@ -1639,10 +1639,10 @@ void instrument_cover_goals(
1639
1639
f_it->first ==" __CPROVER_initialize" )
1640
1640
continue ;
1641
1641
1642
- // empty set of existing goals
1642
+ // empty set of existing goals
1643
1643
coverage_goalst goals;
1644
1644
instrument_cover_goals (symbol_table, f_it->second .body ,
1645
- criterion, goals);
1645
+ criterion, goals);
1646
1646
}
1647
1647
}
1648
1648
@@ -1662,8 +1662,8 @@ bool consider_goals(
1662
1662
const goto_programt &goto_program,
1663
1663
coverage_goalst &goals)
1664
1664
{
1665
- // check whether we should eliminate trivial goals
1666
- if (!goals.get_no_trivial_tests ())
1665
+ // check whether we should eliminate trivial goals
1666
+ if (!goals.get_no_trivial_tests ())
1667
1667
return true ;
1668
1668
1669
1669
bool result;
@@ -1672,16 +1672,19 @@ bool consider_goals(
1672
1672
forall_goto_program_instructions (i_it, goto_program)
1673
1673
{
1674
1674
if (i_it->is_goto ())
1675
- ++count_goto;
1676
- else if (i_it->is_assign ())
1675
+ ++count_goto;
1676
+ else if (i_it->is_assign ())
1677
1677
++count_assignments;
1678
- else if (i_it->is_decl ())
1678
+ else if (i_it->is_decl ())
1679
1679
++count_decl;
1680
1680
}
1681
1681
1682
- // this might be a get or set method (pattern)
1683
- result = !((count_decl==0 ) && (count_goto<=1 ) &&
1684
- (count_assignments>0 && count_assignments<5 ));
1682
+ // check whether this is a constructor/destructor or a get/set (pattern)
1683
+ if (!count_goto && !count_assignments && !count_decl)
1684
+ result=false ;
1685
+ else
1686
+ result = !((count_decl==0 ) && (count_goto<=1 ) &&
1687
+ (count_assignments>0 && count_assignments<5 ));
1685
1688
1686
1689
return result;
1687
1690
}
0 commit comments