Skip to content

Commit 5b0603a

Browse files
committed
C++: Artificial block insertion for loops and switches has changed in frontend
There are now more artificial blocks containing more than one instruction (artificial blocks containing a single instruction have the extractor only emit that instruction and not the block). The second instruction in each case is the label for breaking out of a loop or switch.
1 parent d43ae9b commit 5b0603a

File tree

10 files changed

+810
-782
lines changed

10 files changed

+810
-782
lines changed

cpp/ql/test/library-tests/controlflow/dominance/dominator.expected

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
| test | 44 | ... = ... | 42 | j |
119119
| test | 44 | ExprStmt | 44 | 10 |
120120
| test | 44 | w | 44 | ... = ... |
121-
| test | 47 | ... += ... | 50 | for(...;...;...) ... |
121+
| test | 47 | ... += ... | 50 | { ... } |
122122
| test | 47 | ExprStmt | 47 | z |
123123
| test | 47 | w | 47 | ... += ... |
124124
| test | 47 | z | 47 | w |
@@ -133,6 +133,7 @@
133133
| test | 50 | j | 50 | ... ++ |
134134
| test | 50 | j | 50 | ... = ... |
135135
| test | 50 | label ...: | 50 | j |
136+
| test | 50 | { ... } | 50 | for(...;...;...) ... |
136137
| test | 50 | { ... } | 51 | ExprStmt |
137138
| test | 51 | 30 | 51 | y |
138139
| test | 51 | ... = ... | 52 | if (...) ... |
@@ -182,8 +183,9 @@
182183
| test | 70 | w | 70 | ... = ... |
183184
| test | 71 | return ... | 71 | w |
184185
| test2 | 74 | { ... } | 76 | declaration |
185-
| test2 | 76 | declaration | 77 | for(...;...;...) ... |
186+
| test2 | 76 | declaration | 77 | { ... } |
186187
| test2 | 77 | for(...;...;...) ... | 77 | { ... } |
188+
| test2 | 77 | { ... } | 77 | for(...;...;...) ... |
187189
| test2 | 77 | { ... } | 78 | ExprStmt |
188190
| test2 | 78 | 10 | 78 | b |
189191
| test2 | 78 | ... = ... | 79 | if (...) ... |

cpp/ql/test/library-tests/sideEffects/stmts/stmts.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
| stmts.c:3:5:3:10 | declaration | true | true |
33
| stmts.c:4:5:4:18 | declaration | true | true |
44
| stmts.c:5:5:5:16 | declaration | false | true |
5+
| stmts.c:7:5:7:5 | { ... } | true | true |
56
| stmts.c:7:5:14:5 | switch (...) ... | true | true |
67
| stmts.c:7:15:14:5 | { ... } | true | true |
78
| stmts.c:8:9:8:15 | case ...: | true | true |

cpp/ql/test/library-tests/switch/blocks.expected

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
| switch.c:2:5:2:5 | f | switch.c:2:14:12:1 | { ... } | switch.c:3:5:10:5 | switch (...) ... |
2-
| switch.c:2:5:2:5 | f | switch.c:2:14:12:1 | { ... } | switch.c:10:5:10:5 | label ...: |
1+
| switch.c:2:5:2:5 | f | switch.c:2:14:12:1 | { ... } | switch.c:3:5:3:5 | { ... } |
32
| switch.c:2:5:2:5 | f | switch.c:2:14:12:1 | { ... } | switch.c:11:5:11:13 | return ... |
43
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:15:2:15:7 | declaration |
5-
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:17:5:26:5 | switch (...) ... |
6-
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:26:5:26:5 | label ...: |
4+
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:17:5:17:5 | { ... } |
75
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:28:5:29:5 | switch (...) ... |
8-
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:31:5:44:2 | switch (...) ... |
9-
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:44:2:44:2 | label ...: |
6+
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:31:5:31:5 | { ... } |
107
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:46:2:51:2 | switch (...) ... |
118
| switch.c:14:6:14:6 | g | switch.c:14:15:52:1 | { ... } | switch.c:52:1:52:1 | return ... |
129
| switch.cpp:4:5:4:5 | f | switch.cpp:4:14:9:1 | { ... } | switch.cpp:5:5:8:5 | switch (...) ... |
Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,89 @@
1-
| 10 | 1 | { ... } | 12 switch (...) ... |
2-
| 10 | 43 | f | <no successors> |
3-
| 12 | 2 | switch (...) ... | 12 cond |
4-
| 12 | 3 | cond | 12 { ... } |
5-
| 12 | 4 | { ... } | 13 case ...: |
6-
| 12 | 4 | { ... } | 16 case ...: |
7-
| 12 | 4 | { ... } | 18 case ...: |
8-
| 12 | 4 | { ... } | 21 case ...: |
9-
| 12 | 4 | { ... } | 22 case ...: |
10-
| 12 | 4 | { ... } | 24 case ...: |
11-
| 12 | 4 | { ... } | 25 default: |
12-
| 12 | 4 | { ... } | 26 case ...: |
13-
| 12 | 4 | { ... } | 28 case ...: |
1+
| 10 | 1 | { ... } | 12 { ... } |
2+
| 10 | 44 | f | <no successors> |
3+
| 12 | 2 | { ... } | 12 switch (...) ... |
4+
| 12 | 3 | switch (...) ... | 12 cond |
5+
| 12 | 4 | cond | 12 { ... } |
6+
| 12 | 5 | { ... } | 13 case ...: |
7+
| 12 | 5 | { ... } | 16 case ...: |
8+
| 12 | 5 | { ... } | 18 case ...: |
9+
| 12 | 5 | { ... } | 21 case ...: |
10+
| 12 | 5 | { ... } | 22 case ...: |
11+
| 12 | 5 | { ... } | 24 case ...: |
12+
| 12 | 5 | { ... } | 25 default: |
13+
| 12 | 5 | { ... } | 26 case ...: |
14+
| 12 | 5 | { ... } | 28 case ...: |
1415
| 13 | 1 | 1 | <no successors> |
15-
| 13 | 5 | case ...: | 14 ExprStmt |
16-
| 14 | 6 | ExprStmt | 14 111 |
17-
| 14 | 7 | 111 | 14 x |
18-
| 14 | 8 | x | 14 ... = ... |
19-
| 14 | 9 | ... = ... | 15 break; |
20-
| 15 | 10 | break; | 31 label ...: |
16+
| 13 | 6 | case ...: | 14 ExprStmt |
17+
| 14 | 7 | ExprStmt | 14 111 |
18+
| 14 | 8 | 111 | 14 x |
19+
| 14 | 9 | x | 14 ... = ... |
20+
| 14 | 10 | ... = ... | 15 break; |
21+
| 15 | 11 | break; | 31 label ...: |
2122
| 16 | 1 | 1 | <no successors> |
2223
| 16 | 1 | 2 | <no successors> |
2324
| 16 | 1 | ... + ... | <no successors> |
24-
| 16 | 5 | case ...: | 17 ExprStmt |
25-
| 17 | 6 | ExprStmt | 17 333 |
26-
| 17 | 7 | 333 | 17 x |
27-
| 17 | 8 | x | 17 ... = ... |
28-
| 17 | 9 | ... = ... | 18 case ...: |
25+
| 16 | 6 | case ...: | 17 ExprStmt |
26+
| 17 | 7 | ExprStmt | 17 333 |
27+
| 17 | 8 | 333 | 17 x |
28+
| 17 | 9 | x | 17 ... = ... |
29+
| 17 | 10 | ... = ... | 18 case ...: |
2930
| 18 | 1 | 4 | <no successors> |
30-
| 18 | 10 | case ...: | 19 ExprStmt |
31-
| 19 | 11 | ExprStmt | 19 444 |
32-
| 19 | 12 | 444 | 19 x |
33-
| 19 | 13 | x | 19 ... = ... |
34-
| 19 | 14 | ... = ... | 20 break; |
35-
| 20 | 15 | break; | 31 label ...: |
31+
| 18 | 11 | case ...: | 19 ExprStmt |
32+
| 19 | 12 | ExprStmt | 19 444 |
33+
| 19 | 13 | 444 | 19 x |
34+
| 19 | 14 | x | 19 ... = ... |
35+
| 19 | 15 | ... = ... | 20 break; |
36+
| 20 | 16 | break; | 31 label ...: |
3637
| 21 | 1 | 5 | <no successors> |
37-
| 21 | 5 | case ...: | 22 case ...: |
38+
| 21 | 6 | case ...: | 22 case ...: |
3839
| 22 | 1 | 6 | <no successors> |
39-
| 22 | 6 | case ...: | 23 ExprStmt |
40-
| 23 | 7 | ExprStmt | 23 777 |
41-
| 23 | 8 | 777 | 23 x |
42-
| 23 | 9 | x | 23 ... = ... |
43-
| 23 | 10 | ... = ... | 24 case ...: |
40+
| 22 | 7 | case ...: | 23 ExprStmt |
41+
| 23 | 8 | ExprStmt | 23 777 |
42+
| 23 | 9 | 777 | 23 x |
43+
| 23 | 10 | x | 23 ... = ... |
44+
| 23 | 11 | ... = ... | 24 case ...: |
4445
| 24 | 1 | 7 | <no successors> |
45-
| 24 | 11 | case ...: | 25 default: |
46-
| 25 | 12 | default: | 26 case ...: |
46+
| 24 | 12 | case ...: | 25 default: |
47+
| 25 | 13 | default: | 26 case ...: |
4748
| 26 | 1 | 8 | <no successors> |
48-
| 26 | 13 | case ...: | 27 ExprStmt |
49-
| 27 | 14 | ExprStmt | 27 888 |
50-
| 27 | 15 | 888 | 27 x |
51-
| 27 | 16 | x | 27 ... = ... |
52-
| 27 | 17 | ... = ... | 28 case ...: |
49+
| 26 | 14 | case ...: | 27 ExprStmt |
50+
| 27 | 15 | ExprStmt | 27 888 |
51+
| 27 | 16 | 888 | 27 x |
52+
| 27 | 17 | x | 27 ... = ... |
53+
| 27 | 18 | ... = ... | 28 case ...: |
5354
| 28 | 1 | 9 | <no successors> |
54-
| 28 | 18 | case ...: | 29 ExprStmt |
55-
| 29 | 19 | ExprStmt | 29 999 |
56-
| 29 | 20 | 999 | 29 x |
57-
| 29 | 21 | x | 29 ... = ... |
58-
| 29 | 22 | ... = ... | 30 break; |
59-
| 30 | 23 | break; | 31 label ...: |
60-
| 31 | 41 | label ...: | 33 return ... |
61-
| 33 | 42 | return ... | 10 f |
62-
| 36 | 1 | { ... } | 38 switch (...) ... |
63-
| 36 | 22 | g | <no successors> |
64-
| 38 | 2 | switch (...) ... | 38 cond |
65-
| 38 | 3 | cond | 38 { ... } |
66-
| 38 | 4 | { ... } | 39 case ...: |
67-
| 38 | 4 | { ... } | 42 case ...: |
68-
| 38 | 4 | { ... } | 45 label ...: |
55+
| 28 | 19 | case ...: | 29 ExprStmt |
56+
| 29 | 20 | ExprStmt | 29 999 |
57+
| 29 | 21 | 999 | 29 x |
58+
| 29 | 22 | x | 29 ... = ... |
59+
| 29 | 23 | ... = ... | 30 break; |
60+
| 30 | 24 | break; | 31 label ...: |
61+
| 31 | 42 | label ...: | 33 return ... |
62+
| 33 | 43 | return ... | 10 f |
63+
| 36 | 1 | { ... } | 38 { ... } |
64+
| 36 | 23 | g | <no successors> |
65+
| 38 | 2 | { ... } | 38 switch (...) ... |
66+
| 38 | 3 | switch (...) ... | 38 cond |
67+
| 38 | 4 | cond | 38 { ... } |
68+
| 38 | 5 | { ... } | 39 case ...: |
69+
| 38 | 5 | { ... } | 42 case ...: |
70+
| 38 | 5 | { ... } | 45 label ...: |
6971
| 39 | 1 | 1 | <no successors> |
70-
| 39 | 5 | case ...: | 40 ExprStmt |
71-
| 40 | 6 | ExprStmt | 40 111 |
72-
| 40 | 7 | 111 | 40 x |
73-
| 40 | 8 | x | 40 ... = ... |
74-
| 40 | 9 | ... = ... | 41 break; |
75-
| 41 | 10 | break; | 45 label ...: |
72+
| 39 | 6 | case ...: | 40 ExprStmt |
73+
| 40 | 7 | ExprStmt | 40 111 |
74+
| 40 | 8 | 111 | 40 x |
75+
| 40 | 9 | x | 40 ... = ... |
76+
| 40 | 10 | ... = ... | 41 break; |
77+
| 41 | 11 | break; | 45 label ...: |
7678
| 42 | 1 | 2 | <no successors> |
77-
| 42 | 5 | case ...: | 43 ExprStmt |
78-
| 43 | 6 | ExprStmt | 43 222 |
79-
| 43 | 7 | 222 | 43 x |
80-
| 43 | 8 | x | 43 ... = ... |
81-
| 43 | 9 | ... = ... | 45 label ...: |
82-
| 45 | 16 | label ...: | 46 ExprStmt |
83-
| 46 | 17 | ExprStmt | 46 999 |
84-
| 46 | 18 | 999 | 46 x |
85-
| 46 | 19 | x | 46 ... = ... |
86-
| 46 | 20 | ... = ... | 48 return ... |
87-
| 48 | 21 | return ... | 36 g |
79+
| 42 | 6 | case ...: | 43 ExprStmt |
80+
| 43 | 7 | ExprStmt | 43 222 |
81+
| 43 | 8 | 222 | 43 x |
82+
| 43 | 9 | x | 43 ... = ... |
83+
| 43 | 10 | ... = ... | 45 label ...: |
84+
| 45 | 17 | label ...: | 46 ExprStmt |
85+
| 46 | 18 | ExprStmt | 46 999 |
86+
| 46 | 19 | 999 | 46 x |
87+
| 46 | 20 | x | 46 ... = ... |
88+
| 46 | 21 | ... = ... | 48 return ... |
89+
| 48 | 22 | return ... | 36 g |

0 commit comments

Comments
 (0)