Skip to content

Make location coverage reported include all lines of a multi-line statement #5635

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 4 commits into from
Nov 27, 2020
Merged
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
17 changes: 11 additions & 6 deletions src/goto-instrument/cover_basic_blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,17 @@ void cover_basic_blockst::add_block_lines(
cover_basic_blockst::block_infot &block,

Choose a reason for hiding this comment

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

⛏️ should imho be called block_info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO, it would be better to rename block_infot to blockt. This is on the basis that you wouldn't bother creating instances of a struct that didn't contain information. Therefore the word info is redundant in the context of the name. It doesn't really convey any useful meaning to the reader.

const goto_programt::instructiont &instruction)
{
const irep_idt &line = instruction.source_location.get_line();
if(!line.empty())
{
block.lines.insert(unsafe_string2unsigned(id2string(line)));
block.source_lines.insert(instruction.source_location);
}
const auto &add_location = [&](const source_locationt &location) {
const irep_idt &line = location.get_line();
if(!line.empty())
{
block.lines.insert(unsafe_string2unsigned(id2string(line)));

Choose a reason for hiding this comment

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

block_infot::lines is a set I presume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

block.source_lines.insert(location);
}
};
add_location(instruction.source_location);
instruction.code.visit_pre(
[&](const exprt &expr) { add_location(expr.source_location()); });
}

void cover_basic_blockst::update_covered_lines(block_infot &block_info)
Expand Down