File tree Expand file tree Collapse file tree 6 files changed +30
-16
lines changed Expand file tree Collapse file tree 6 files changed +30
-16
lines changed Original file line number Diff line number Diff line change 3
3
--cover location
4
4
block 1 \(lines main.c:main:3,5\): SATISFIED
5
5
block 2 \(lines main.c:main:6\): SATISFIED
6
- block 3 \(lines main.c:main:6,9\): FAILED
7
- block 4 \(lines main.c:main:8\): SATISFIED
8
- block 5 \(lines main.c:main:9\): SATISFIED
6
+ block 3 \(lines main.c:main:8\): SATISFIED
7
+ block 4 \(lines main.c:main:9\): SATISFIED
9
8
^EXIT=0$
10
9
^SIGNAL=0$
11
10
--
Original file line number Diff line number Diff line change 3
3
--cover location --unwind 1
4
4
^EXIT=0$
5
5
^SIGNAL=0$
6
- ^\*\* 5 of 8 covered
6
+ ^\*\* 5 of 7 covered
7
7
--
8
8
^warning: ignoring
9
9
^\[.*<builtin-library-
Original file line number Diff line number Diff line change 2
2
main.c
3
3
--unwind 10 --show-goto-functions
4
4
activate-multi-line-match
5
- (?P<comment_block>\/\/ [0-9]+ file main\.c line [0-9]+ function main)[\s]*DEAD .*newAlloc0[\s]*(?P>comment_block)[\s]*DEAD .*pc[\s]*(?P>comment_block)[\s]*DEAD .*literal[\s]*(?P>comment_block)[\s]*9 : END_FUNCTION
5
+ (?P<comment_block>\/\/ [0-9]+ file main\.c line [0-9]+ function main)[\s]*DEAD .*newAlloc0[\s]*(?P>comment_block)[\s]*DEAD .*pc[\s]*(?P>comment_block)[\s]*DEAD .*literal[\s]*(?P>comment_block)[\s]*8 : END_FUNCTION
6
6
^EXIT=0$
7
7
^SIGNAL=0$
8
8
--
@@ -16,7 +16,7 @@ Checks for:
16
16
// 51 file main.c line 44 function main
17
17
DEAD main::$tmp::literal
18
18
// 52 file main.c line 45 function main
19
- 9 : END_FUNCTION
19
+ 8 : END_FUNCTION
20
20
21
21
This asserts that when you've created a compound literal that both temp and real
22
22
variable gets killed.
Original file line number Diff line number Diff line change 2
2
main.c
3
3
--unwind 10 --show-goto-functions
4
4
activate-multi-line-match
5
- (?P<comment_block>\/\/ [0-9]+ file main\.c line [0-9]+ function main)[\s]*6 : .*newAlloc4 : struct tag-test[\s]*(?P>comment_block)[\s]*.*newAlloc4 := \{ 4 \}[\s]*(?P>comment_block)[\s]*.*newAlloc6 : struct tag-test[\s]*(?P>comment_block)[\s]*.*newAlloc6 := \{ 6 \}[\s]*(?P>comment_block)[\s]*.*newAlloc7 : struct tag-test[\s]*(?P>comment_block)[\s]*.*newAlloc7 := \{ 7 \}[\s]*(?P>comment_block)[\s]*GOTO 3
5
+ (?P<comment_block>\/\/ [0-9]+ file main\.c line [0-9]+ function main)[\s]*5 : .*newAlloc4 : struct tag-test[\s]*(?P>comment_block)[\s]*.*newAlloc4 := \{ 4 \}[\s]*(?P>comment_block)[\s]*.*newAlloc6 : struct tag-test[\s]*(?P>comment_block)[\s]*.*newAlloc6 := \{ 6 \}[\s]*(?P>comment_block)[\s]*.*newAlloc7 : struct tag-test[\s]*(?P>comment_block)[\s]*.*newAlloc7 := \{ 7 \}[\s]*(?P>comment_block)[\s]*GOTO 3
6
6
^EXIT=0$
7
7
^SIGNAL=0$
8
8
--
9
9
--
10
10
Checks for:
11
11
12
12
// 37 file main.c line 36 function main
13
- 6 : DECL main::1::2::2::newAlloc4 : struct tag-test
13
+ 5 : DECL main::1::2::2::newAlloc4 : struct tag-test
14
14
// 38 file main.c line 36 function main
15
15
ASSIGN main::1::2::2::newAlloc4 := { 4 }
16
16
// 39 file main.c line 37 function main
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ while-break1.c
3
3
--text --solve --inline
4
4
^EXIT=0$
5
5
^SIGNAL=0$
6
- ^\(\d+\) ∀ ς : state \. S18 \(ς\) ⇒ S12in\(ς\)$
6
+ ^\(\d+\) ∀ ς : state \. S15T \(ς\) ⇒ S12in\(ς\)$
7
7
^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12in\(ς\)$
8
8
^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ ¬\(1 ≠ 0\)\) ⇒ S12T\(ς\)$
9
9
^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ 1 ≠ 0\) ⇒ S12\(ς\)$
10
- ^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ¬\( ς\(❝main::1::x❞\) = 0\) \) ⇒ S13T\(ς\)$
11
- ^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ς\(❝main::1::x❞\) = 0\) ⇒ S13\(ς\)$
12
- ^\(\d+\) ∀ ς : state \. S12T\(ς\) ⇒ S19in \(ς\)$
13
- ^\(\d+\) ∀ ς : state \. S14 \(ς\) ⇒ S19in \(ς\)$
14
- ^\(\d+\) ∀ ς : state \. S16\(ς\) ⇒ S19in \(ς\)$
10
+ ^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ς\(❝main::1::x❞\) = 0\) ⇒ S13T\(ς\)$
11
+ ^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ¬\( ς\(❝main::1::x❞\) = 0\) \) ⇒ S13\(ς\)$
12
+ ^\(\d+\) ∀ ς : state \. S12T\(ς\) ⇒ S17in \(ς\)$
13
+ ^\(\d+\) ∀ ς : state \. S13T \(ς\) ⇒ S17in \(ς\)$
14
+ ^\(\d+\) ∀ ς : state \. S16\(ς\) ⇒ S17in \(ς\)$
15
15
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
16
16
--
17
17
--
Original file line number Diff line number Diff line change @@ -1639,13 +1639,28 @@ void goto_convertt::generate_ifthenelse(
1639
1639
dest.destructive_append (tmp_v);
1640
1640
dest.destructive_append (tmp_w);
1641
1641
1642
+ // When the `then` branch of a balanced `if` condition ends with a `return` or
1643
+ // a `goto` statement, it is not necessary to add the `goto z` and `z:` goto
1644
+ // elements as they are never used.
1645
+ // This helps for example when using `--cover location` as such command are
1646
+ // marked unreachable, but are not part of the user-provided code to analyze.
1647
+ bool then_branch_returns = dest.instructions .rbegin ()->is_goto ();
1648
+
1642
1649
if (has_else)
1643
1650
{
1644
- dest.destructive_append (tmp_x);
1651
+ // Don't add the `goto` at the end of the `then` branch if not needed
1652
+ if (!then_branch_returns)
1653
+ {
1654
+ dest.destructive_append (tmp_x);
1655
+ }
1645
1656
dest.destructive_append (tmp_y);
1646
1657
}
1647
1658
1648
- dest.destructive_append (tmp_z);
1659
+ // Don't add the `z` label at the end of the `if` when not needed.
1660
+ if (!has_else || !then_branch_returns)
1661
+ {
1662
+ dest.destructive_append (tmp_z);
1663
+ }
1649
1664
}
1650
1665
1651
1666
// / if(guard) goto target;
You can’t perform that action at this time.
0 commit comments