Skip to content

Commit d68155e

Browse files
lucasccordeirotautschnig
authored andcommitted
use json file suggested at github issue #187
1 parent 99a5489 commit d68155e

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/goto-instrument/cover.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,33 @@ coverage_goalst coverage_goalst::get_coverage_goals(const std::string &coverage,
127127
exit(0);
128128
}
129129

130-
irep_idt line_number;
130+
irep_idt file, function, line;
131131
for(jsont::arrayt::const_iterator
132132
it=json.array.begin();
133133
it!=json.array.end();
134134
it++)
135135
{
136-
//get the goals array
137-
if ((*it)["goals"].is_array())
136+
137+
//get the file of each existing goal
138+
file=(*it)["file"].value;
139+
source_location.set_file(file);
140+
141+
//get the function of each existing goal
142+
function=(*it)["function"].value;
143+
source_location.set_function(function);
144+
145+
//get the lines array
146+
if ((*it)["lines"].is_array())
138147
{
139148
for(jsont::arrayt::const_iterator
140-
itg=(*it)["goals"].array.begin();
141-
itg!=(*it)["goals"].array.end();
149+
itg=(*it)["lines"].array.begin();
150+
itg!=(*it)["lines"].array.end();
142151
itg++)
143152
{
144153
//get the line of each existing goal
145-
line_number=(*itg)["sourceLocation"]["line"].value;
146-
source_location.set_line(line_number);
147-
goals.set_goals(source_location);
154+
line=(*itg)["number"].value;
155+
source_location.set_line(line);
156+
goals.set_goals(source_location);
148157
}
149158
}
150159
}
@@ -156,7 +165,9 @@ bool coverage_goalst::is_existing_goal(source_locationt source_location)
156165
std::vector<source_locationt>::iterator it = existing_goals.begin();
157166
while (it!=existing_goals.end())
158167
{
159-
if (!source_location.get_line().compare(it->get_line()))
168+
if (!source_location.get_file().compare(it->get_file()) &&
169+
!source_location.get_function().compare(it->get_function()) &&
170+
!source_location.get_line().compare(it->get_line()))
160171
break;
161172
++it;
162173
}

0 commit comments

Comments
 (0)