Skip to content

check for java bytecode index in the existing coverage #772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/goto-instrument/cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,20 @@ void coverage_goalst::add_goal(source_locationt goal)
existing_goals.push_back(goal);
}

bool coverage_goalst::is_existing_goal(source_locationt source_location) const
/// compare the value of the current goal to the existing ones
/// \param source_loc: source location of the current goal
/// \return true : if the current goal exists false : otherwise
bool coverage_goalst::is_existing_goal(source_locationt source_loc) const
{
for(const auto &existing_loc : existing_goals)
{
if(source_location.get_file()==existing_loc.get_file() &&
source_location.get_function()==existing_loc.get_function() &&
source_location.get_line()==existing_loc.get_line())
return true;
if((source_loc.get_file()==existing_loc.get_file()) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd write if(a && b && c && (d || e)) return true;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented as suggested.

(source_loc.get_function()==existing_loc.get_function()) &&
(source_loc.get_line()==existing_loc.get_line()) &&
(source_loc.get_java_bytecode_index().empty() ||
(source_loc.get_java_bytecode_index()==
existing_loc.get_java_bytecode_index())))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

return true;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/cover.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class coverage_goalst
message_handlert &message_handler,
coverage_goalst &goals);
void add_goal(source_locationt goal);
bool is_existing_goal(source_locationt source_location) const;
bool is_existing_goal(source_locationt source_loc) const;

private:
std::vector<source_locationt> existing_goals;
Expand Down