Skip to content

Commit 0d39c4a

Browse files
extend the existing-coverage option to support bytecode_index
1 parent ebe4914 commit 0d39c4a

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/goto-instrument/cover.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,33 @@ bool coverage_goalst::get_coverage_goals(
132132
return true;
133133
}
134134

135-
for(const auto &goal : json.array)
135+
// traverse the given JSON file
136+
for(const auto &goals_in_json : json.array)
136137
{
137-
// get the file of each existing goal
138-
irep_idt file=goal["file"].value;
139-
source_location.set_file(file);
140-
141-
// get the function of each existing goal
142-
irep_idt function=goal["function"].value;
143-
source_location.set_function(function);
144-
145-
// get the lines array
146-
if(goal["lines"].is_array())
138+
// get the set of goals
139+
if(goals_in_json["goals"].is_array())
147140
{
148-
for(const auto &line_json : goal["lines"].array)
141+
// store the source location for each existing goal
142+
for(const auto &each_goal : goals_in_json["goals"].array)
149143
{
150-
// get the line of each existing goal
151-
irep_idt line=line_json["number"].value;
144+
// get and set the bytecode_index
145+
irep_idt bytecode_index=
146+
each_goal["sourceLocation"]["bytecode_index"].value;
147+
source_location.set_java_bytecode_index(bytecode_index);
148+
149+
// get and set the file
150+
irep_idt file=each_goal["sourceLocation"]["file"].value;
151+
source_location.set_file(file);
152+
153+
// get and set the function
154+
irep_idt function=each_goal["sourceLocation"]["function"].value;
155+
source_location.set_function(function);
156+
157+
// get and set the line
158+
irep_idt line=each_goal["sourceLocation"]["line"].value;
152159
source_location.set_line(line);
160+
161+
// store the existing goal
153162
goals.add_goal(source_location);
154163
}
155164
}

0 commit comments

Comments
 (0)