-
Notifications
You must be signed in to change notification settings - Fork 274
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
thomasspriggs
merged 4 commits into
diffblue:develop
from
thomasspriggs:tas/expression_coverage
Nov 27, 2020
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cf28697
Rename `_goto_program` to `goto_program`
thomasspriggs 3aa12a3
Factor adding lines to a block out of basic blocks constructor
thomasspriggs 87d73e1
Add all lines to a block which a statement spans
thomasspriggs b156c8f
Add tests of multi-line statement coverage
thomasspriggs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,12 +153,17 @@ void cover_basic_blockst::add_block_lines( | |
cover_basic_blockst::block_infot &block, | ||
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))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
.There was a problem hiding this comment.
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
toblockt
. This is on the basis that you wouldn't bother creating instances of a struct that didn't contain information. Therefore the wordinfo
is redundant in the context of the name. It doesn't really convey any useful meaning to the reader.