Skip to content

Commit 71b3fd2

Browse files
Merge pull request #772 from lucasccordeiro/fix-existing-coverage
check for java bytecode index in the existing coverage
2 parents 406a6c4 + a63f2bb commit 71b3fd2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/goto-instrument/cover.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class basic_blockst
6464
format_number_ranget format_lines;
6565
for(const auto &cover_set : block_line_cover_map)
6666
{
67-
assert(!cover_set.second.empty());
67+
INVARIANT(!cover_set.second.empty(),
68+
"covered lines set must not be empty");
6869
std::vector<unsigned>
6970
line_list{cover_set.second.begin(), cover_set.second.end()};
7071

@@ -161,14 +162,20 @@ void coverage_goalst::add_goal(source_locationt goal)
161162
existing_goals.push_back(goal);
162163
}
163164

164-
bool coverage_goalst::is_existing_goal(source_locationt source_location) const
165+
/// compare the value of the current goal to the existing ones
166+
/// \param source_loc: source location of the current goal
167+
/// \return true : if the current goal exists false : otherwise
168+
bool coverage_goalst::is_existing_goal(source_locationt source_loc) const
165169
{
166170
for(const auto &existing_loc : existing_goals)
167171
{
168-
if(source_location.get_file()==existing_loc.get_file() &&
169-
source_location.get_function()==existing_loc.get_function() &&
170-
source_location.get_line()==existing_loc.get_line())
171-
return true;
172+
if((source_loc.get_file()==existing_loc.get_file()) &&
173+
(source_loc.get_function()==existing_loc.get_function()) &&
174+
(source_loc.get_line()==existing_loc.get_line()) &&
175+
(source_loc.get_java_bytecode_index().empty() ||
176+
(source_loc.get_java_bytecode_index()==
177+
existing_loc.get_java_bytecode_index())))
178+
return true;
172179
}
173180
return false;
174181
}

src/goto-instrument/cover.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class coverage_goalst
2525
message_handlert &message_handler,
2626
coverage_goalst &goals);
2727
void add_goal(source_locationt goal);
28-
bool is_existing_goal(source_locationt source_location) const;
28+
bool is_existing_goal(source_locationt source_loc) const;
2929

3030
private:
3131
std::vector<source_locationt> existing_goals;

0 commit comments

Comments
 (0)