Define coverage blocks so as to be terminated by all assumptions #7944
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.
This PR is a variation on #7810 which is raised in response to this comment here - #7810 (comment)
I have kept these changes as a separate PR/branch for the moment as they are functionally different from the ones which have been previously been approved and I would like confirmation from @remi-delmas-3000 before we continue with the approach in this PR.
The key difference between this PR and the original PR is that the original PR will produce a single block for the case where there are multiple consecutive assumptions which map to the same source line. Kind of like a transformation from
assume(a); assume(b);
toassume(a && b);
. This PR will create a coverage block for each of the assumptions. This tends to be the case where we add assertions during instrumentation passes, which become assumptions for the purposes of coverage checks.The drawback with the presence of multiple coverage blocks on the same line of code is that the coverage reporting only reports at a granularity of source lines rather than goto instructions. This can make the output appear somewhat odd. Only source lines are included in the output regardless of whether we are using the default plain text UI or
--xml-ui
or--json-ui
. To illustrate this issue I have taken one of the examples from our test suite and run it against develop, my first PR and this PR.C source
For this example we run
cbmc test.c --cover location --pointer-check --malloc-may-fail --malloc-fail-null
Coverage reporting on develop.
The above results combine lines 12 and 14 in the same block, even though line 14 would be unreachable if the instrumentation assertions could not be satisfied. This demonstrates the problem from original issue.
Coverage reporting from https://github.com//pull/7810
The above coverage output includes an additional block for line 14. This is correctly shown as SATISFIED / reachable as the conditions added by the instrumentation can be satisfied in this case.
Coverage reporting from this PR
The coverage output now shows 5 blocks which each cover line 12 alone. In this example they aren't too difficult to consolidate. However it is conceivable that some of them could report as SATISFIED with others for the same line showing as FAILED. This could occur in the case where the first check is satisifyable but one of the following checks is not.