@@ -8,6 +8,8 @@ Date: May 2016
8
8
9
9
\*******************************************************************/
10
10
11
+ #include < iostream>
12
+
11
13
#include < algorithm>
12
14
#include < iterator>
13
15
#include < unordered_set>
@@ -114,6 +116,7 @@ void coverage_goalst::get_coverage(const std::string &coverage,
114
116
message_handlert &message_handler)
115
117
{
116
118
jsont json;
119
+ source_locationt source_location;
117
120
118
121
// check coverage file
119
122
if (parse_json (coverage, message_handler, json))
@@ -133,6 +136,7 @@ void coverage_goalst::get_coverage(const std::string &coverage,
133
136
exit (0 );
134
137
}
135
138
139
+ irep_idt line_number;
136
140
for (jsont::arrayt::const_iterator
137
141
it=json.array .begin ();
138
142
it!=json.array .end ();
@@ -147,8 +151,9 @@ void coverage_goalst::get_coverage(const std::string &coverage,
147
151
itg++)
148
152
{
149
153
// get the line of each existing goal
150
- const std::string line=(*itg)[" sourceLocation" ][" line" ].value ;
151
- set_goals (line);
154
+ line_number=(*itg)[" sourceLocation" ][" line" ].value ;
155
+ source_location.set_line (line_number);
156
+ set_goals (source_location);
152
157
}
153
158
}
154
159
}
@@ -166,7 +171,7 @@ Function: coverage_goalst::set_goals
166
171
167
172
\*******************************************************************/
168
173
169
- void coverage_goalst::set_goals (std::string goal)
174
+ void coverage_goalst::set_goals (source_locationt goal)
170
175
{
171
176
existing_goals.push_back (goal);
172
177
}
@@ -185,10 +190,13 @@ Function: coverage_goalst::is_existing_goal
185
190
186
191
bool coverage_goalst::is_existing_goal (source_locationt source_location)
187
192
{
188
- std::vector<std::string>::iterator it;
189
- it = find (existing_goals.begin (), existing_goals.end (),
190
- source_location.get_line ().c_str ());
191
-
193
+ std::vector<source_locationt>::iterator it = existing_goals.begin ();
194
+ while (it!=existing_goals.end ())
195
+ {
196
+ if (!source_location.get_line ().compare (it->get_line ()))
197
+ break ;
198
+ ++it;
199
+ }
192
200
if (it == existing_goals.end ())
193
201
return true ;
194
202
else
0 commit comments