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

Conversation

thomasspriggs
Copy link
Contributor

This PR makes location coverage reported include all lines of multi-line statements. Previously this would only report the line on which a multi-line statement begins. This could falsely give the impression that the end of a statement was not covered.

This should resolve part of the inconstancy seen in #5543

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • N/A My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

As there is no other goto program in scope the underscore is not needed
for avoiding naming clashes. Therefore this rename can be done in order
to help with readability.
So that additional code can be added to this part in the following
commit without increasing the size of the constructor.
Because the entire statement is part of the block.
@codecov
Copy link

codecov bot commented Nov 26, 2020

Codecov Report

Merging #5635 (b156c8f) into develop (416b744) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #5635   +/-   ##
========================================
  Coverage    69.36%   69.36%           
========================================
  Files         1241     1241           
  Lines       100564   100571    +7     
========================================
+ Hits         69753    69760    +7     
  Misses       30811    30811           
Flag Coverage Δ
cproversmt2 43.15% <100.00%> (+<0.01%) ⬆️
regression 66.26% <100.00%> (+<0.01%) ⬆️
unit 32.27% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/goto-instrument/cover_basic_blocks.h 100.00% <ø> (ø)
src/goto-instrument/cover_basic_blocks.cpp 90.62% <100.00%> (+0.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 416b744...b156c8f. Read the comment docs.

To show that the new updated printing is working correctly.
@thomasspriggs thomasspriggs force-pushed the tas/expression_coverage branch from 4af02ce to b156c8f Compare November 27, 2020 10:48
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me - good catch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Overall LGTM

@@ -29,12 +29,12 @@ optionalt<std::size_t> cover_basic_blockst::continuation_of_block(
return {};
}

cover_basic_blockst::cover_basic_blockst(const goto_programt &_goto_program)
cover_basic_blockst::cover_basic_blockst(const goto_programt &goto_program)

Choose a reason for hiding this comment

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

👍

block_info.lines.insert(unsafe_string2unsigned(id2string(line)));
block_info.source_lines.insert(it->source_location);
}
add_block_lines(block_info, *it);
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Nov 27, 2020

Choose a reason for hiding this comment

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

This is really unfortunate. Constructors generally shouldn’t be as complicated as this one is to begin with!

(Not that this is this PRs fault)

@@ -155,6 +149,18 @@ void cover_basic_blockst::output(std::ostream &out) const
<< '\n';
}

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 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.

@@ -0,0 +1,2 @@

Choose a reason for hiding this comment

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

⛏️ Could use a comment explaining what this is here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is already explained in a comment of the .desc file.

@thomasspriggs thomasspriggs merged commit 3fec6e1 into diffblue:develop Nov 27, 2020
@thomasspriggs thomasspriggs deleted the tas/expression_coverage branch November 27, 2020 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants