Skip to content

Commit 0927318

Browse files
use json file suggested at github issue diffblue#187
1 parent a4ae739 commit 0927318

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/goto-instrument/cover.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Date: May 2016
88
99
\*******************************************************************/
1010

11+
#include <iostream>
12+
1113
#include <algorithm>
1214
#include <iterator>
1315
#include <unordered_set>
@@ -135,24 +137,33 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
135137
exit(0);
136138
}
137139

138-
irep_idt line_number;
140+
irep_idt file, function, line;
139141
for(jsont::arrayt::const_iterator
140142
it=json.array.begin();
141143
it!=json.array.end();
142144
it++)
143145
{
144-
//get the goals array
145-
if ((*it)["goals"].is_array())
146+
147+
//get the file of each existing goal
148+
file=(*it)["file"].value;
149+
source_location.set_file(file);
150+
151+
//get the function of each existing goal
152+
function=(*it)["function"].value;
153+
source_location.set_function(function);
154+
155+
//get the lines array
156+
if ((*it)["lines"].is_array())
146157
{
147158
for(jsont::arrayt::const_iterator
148-
itg=(*it)["goals"].array.begin();
149-
itg!=(*it)["goals"].array.end();
159+
itg=(*it)["lines"].array.begin();
160+
itg!=(*it)["lines"].array.end();
150161
itg++)
151162
{
152163
//get the line of each existing goal
153-
line_number=(*itg)["sourceLocation"]["line"].value;
154-
source_location.set_line(line_number);
155-
goals.set_goals(source_location);
164+
line=(*itg)["number"].value;
165+
source_location.set_line(line);
166+
goals.set_goals(source_location);
156167
}
157168
}
158169
}
@@ -193,7 +204,9 @@ bool coverage_goalst::is_existing_goal(source_locationt source_location)
193204
std::vector<source_locationt>::iterator it = existing_goals.begin();
194205
while (it!=existing_goals.end())
195206
{
196-
if (!source_location.get_line().compare(it->get_line()))
207+
if (!source_location.get_file().compare(it->get_file()) &&
208+
!source_location.get_function().compare(it->get_function()) &&
209+
!source_location.get_line().compare(it->get_line()))
197210
break;
198211
++it;
199212
}

0 commit comments

Comments
 (0)