Commit 90b86f2
Enrico Steffinlongo
Avoid adding useless goto blocks in if with return
When the parsed AST is transformed in GOTO language the if conditions
are translated in: `if (!c) goto else; then_branch; goto endif;
else: else_branch; endif: nop` and `if (!c) goto endif; then_branch;
endif: nop`.
This commit avoids to add the `goto endif` command and the `endif` label
if the `then_branch` ends with a `return` or a `goto` statement.
The benefit is that the `--cover location` command returns a
more precise result as unreachable code blocks that are added by CBMC's
frontend are not marked as unreachable.1 parent 9238a38 commit 90b86f2
1 file changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1639 | 1639 | | |
1640 | 1640 | | |
1641 | 1641 | | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
1642 | 1649 | | |
1643 | 1650 | | |
1644 | | - | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
1645 | 1656 | | |
1646 | 1657 | | |
1647 | 1658 | | |
1648 | | - | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
1649 | 1664 | | |
1650 | 1665 | | |
1651 | 1666 | | |
| |||
0 commit comments