Skip to content

Commit 5bcc815

Browse files
use json file suggested at github issue diffblue#187
Signed-off-by: Lucas Cordeiro <[email protected]>
1 parent 863f904 commit 5bcc815

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/goto-instrument/cover.cpp

Lines changed: 22 additions & 8 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

@@ -105,24 +107,34 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
105107
exit(0);
106108
}
107109

108-
irep_idt line_number;
110+
irep_idt file, function, line;
109111
for(jsont::arrayt::const_iterator
110112
it=json.array.begin();
111113
it!=json.array.end();
112114
it++)
113115
{
114-
//get the goals array
115-
if ((*it)["goals"].is_array())
116+
117+
//get the file of each existing goal
118+
file=(*it)["file"].value;
119+
source_location.set_file(file);
120+
121+
//get the function of each existing goal
122+
function=(*it)["function"].value;
123+
source_location.set_function(function);
124+
125+
//get the lines array
126+
if ((*it)["lines"].is_array())
116127
{
117128
for(jsont::arrayt::const_iterator
118-
itg=(*it)["goals"].array.begin();
119-
itg!=(*it)["goals"].array.end();
129+
itg=(*it)["lines"].array.begin();
130+
itg!=(*it)["lines"].array.end();
120131
itg++)
121132
{
122133
//get the line of each existing goal
123-
line_number=(*itg)["sourceLocation"]["line"].value;
124-
source_location.set_line(line_number);
134+
line=(*itg)["number"].value;
135+
source_location.set_line(line);
125136
goals.set_goals(source_location);
137+
126138
}
127139
}
128140
}
@@ -163,7 +175,9 @@ bool coverage_goalst::is_existing_goal(source_locationt source_location)
163175
std::vector<source_locationt>::iterator it = existing_goals.begin();
164176
while (it!=existing_goals.end())
165177
{
166-
if (!source_location.get_line().compare(it->get_line()))
178+
if (!source_location.get_file().compare(it->get_file()) &&
179+
!source_location.get_function().compare(it->get_function()) &&
180+
!source_location.get_line().compare(it->get_line()))
167181
break;
168182
++it;
169183
}

0 commit comments

Comments
 (0)