Skip to content

Commit e09fa64

Browse files
committed
Unified: Add Swift CFG test.
1 parent 4a6040c commit e09fa64

6 files changed

Lines changed: 1223 additions & 0 deletions

File tree

unified/ql/test/library-tests/controlflow/basicblock-slices.expected

Lines changed: 456 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import unified
2+
import ControlFlow::TestCfgInline::BlockSlices
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
bbContinues
2+
| cfg.swift:147:5:147:5 | Block | 'Block goto true(+3)' |
3+
| cfg.swift:525:78:525:78 | Block | 'Block goto Task(+2)' |
4+
| cfg.swift:526:9:526:20 | continuation | 'continuation goto Block(-1)' |
5+
bbStep
6+
| cfg.swift:140:12:140:17 | BinaryExpr | 'BinaryExpr : empty -> SwitchExpr(+3)' |
7+
| cfg.swift:140:12:140:17 | BinaryExpr | 'BinaryExpr : non-empty -> _(+0)' |
8+
| cfg.swift:141:9:141:12 | Block | 'Block : successor -> SwitchExpr(+2)' |
9+
| cfg.swift:141:9:141:12 | Block | 'Block : successor -> _(-1)' |
10+
| cfg.swift:144:5:144:5 | OrPattern | 'OrPattern : match -> Block(+0)' |
11+
| cfg.swift:144:5:144:5 | OrPattern | 'OrPattern : no-match -> SwitchCase(+3)' |
12+
| cfg.swift:147:10:147:10 | ConditionalPattern | 'ConditionalPattern : match -> Block(+0)' |
13+
| cfg.swift:147:10:147:10 | ConditionalPattern | 'ConditionalPattern : no-match -> SwitchCase(+4)' |
14+
| cfg.swift:148:10:148:15 | BinaryExpr | 'BinaryExpr : false -> x(-1)' |
15+
| cfg.swift:148:10:148:15 | BinaryExpr | 'BinaryExpr : true -> x(+1)' |
16+
| cfg.swift:149:13:149:17 | BinaryExpr | 'BinaryExpr : successor -> x(-2)' |
17+
| cfg.swift:187:6:187:10 | BinaryExpr | 'BinaryExpr : false -> IfExpr(+3)' |
18+
| cfg.swift:187:6:187:10 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
19+
| cfg.swift:190:11:190:16 | BinaryExpr | 'BinaryExpr : false,false,false -> Block(+5)' |
20+
| cfg.swift:190:11:190:16 | BinaryExpr | 'BinaryExpr : true -> x(+1)' |
21+
| cfg.swift:191:13:191:17 | BinaryExpr | 'BinaryExpr : false,false,false -> Block(+4)' |
22+
| cfg.swift:191:13:191:17 | BinaryExpr | 'BinaryExpr : true -> UnaryExpr(+1)' |
23+
| cfg.swift:192:15:192:20 | BinaryExpr | 'BinaryExpr : false -> Block(+0)' |
24+
| cfg.swift:192:15:192:20 | BinaryExpr | 'BinaryExpr : true,false -> Block(+3)' |
25+
| cfg.swift:201:6:201:6 | b | 'b : false -> 1(+3)' |
26+
| cfg.swift:201:6:201:6 | b | 'b : true -> Block(+0)' |
27+
| cfg.swift:208:6:208:10 | BinaryExpr | 'BinaryExpr : false -> x(+6)' |
28+
| cfg.swift:208:6:208:10 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
29+
| cfg.swift:210:8:210:13 | BinaryExpr | 'BinaryExpr : false -> x(+4)' |
30+
| cfg.swift:210:8:210:13 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
31+
| cfg.swift:211:7:211:15 | AssignExpr | 'AssignExpr : successor -> x(+3)' |
32+
| cfg.swift:218:11:218:12 | b1 | 'b1 : false -> b3(+2)' |
33+
| cfg.swift:218:11:218:12 | b1 | 'b1 : true -> b2(+1)' |
34+
| cfg.swift:219:13:219:14 | b2 | 'b2 : false,false -> "!b2 \|\| !b3"(+3)' |
35+
| cfg.swift:219:13:219:14 | b2 | 'b2 : true,true -> "b2 \|\| b3"(+2)' |
36+
| cfg.swift:220:13:220:14 | b3 | 'b3 : false,false -> "!b2 \|\| !b3"(+2)' |
37+
| cfg.swift:220:13:220:14 | b3 | 'b3 : true,true -> "b2 \|\| b3"(+1)' |
38+
| cfg.swift:221:9:221:18 | "b2 \|\| b3" | '"b2 \|\| b3" : successor -> ReturnExpr(-3)' |
39+
| cfg.swift:222:9:222:20 | "!b2 \|\| !b3" | '"!b2 \|\| !b3" : successor -> ReturnExpr(-4)' |
40+
| cfg.swift:226:6:226:6 | b | 'b : false -> Bool(+2)' |
41+
| cfg.swift:226:6:226:6 | b | 'b : true -> true(+1)' |
42+
| cfg.swift:227:8:227:11 | true | 'true : true -> Block(+1)' |
43+
| cfg.swift:228:7:228:17 | CallExpr | 'CallExpr : false -> Block(+3)' |
44+
| cfg.swift:228:7:228:17 | CallExpr | 'CallExpr : true,true -> Block(+0)' |
45+
| cfg.swift:243:6:243:6 | b | 'b : false -> Block(+3)' |
46+
| cfg.swift:243:6:243:6 | b | 'b : true -> Block(+0)' |
47+
| cfg.swift:244:5:244:17 | CallExpr | 'CallExpr : successor -> print(+3)' |
48+
| cfg.swift:246:8:246:9 | Block | 'Block : successor -> print(+1)' |
49+
| cfg.swift:251:7:251:8 | b1 | 'b1 : false -> b2(+0)' |
50+
| cfg.swift:251:7:251:8 | b1 | 'b1 : true,true -> Block(+0)' |
51+
| cfg.swift:251:13:251:14 | b2 | 'b2 : true,true -> Block(+0)' |
52+
| cfg.swift:313:3:313:3 | WhileStmt | 'WhileStmt : successor -> x(+0)' |
53+
| cfg.swift:313:9:313:14 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
54+
| cfg.swift:315:5:315:10 | CompoundAssignExpr | 'CompoundAssignExpr : successor -> x(-2)' |
55+
| cfg.swift:320:3:320:3 | WhileStmt | 'WhileStmt : successor -> x(+0)' |
56+
| cfg.swift:320:9:320:14 | BinaryExpr | 'BinaryExpr : false -> print(+11)' |
57+
| cfg.swift:320:9:320:14 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
58+
| cfg.swift:323:8:323:14 | BinaryExpr | 'BinaryExpr : false -> IfExpr(+3)' |
59+
| cfg.swift:323:8:323:14 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
60+
| cfg.swift:324:7:324:11 | BreakExpr | 'BreakExpr : break -> print(+7)' |
61+
| cfg.swift:326:13:326:18 | BinaryExpr | 'BinaryExpr : false -> print(+3)' |
62+
| cfg.swift:326:13:326:18 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
63+
| cfg.swift:327:7:327:14 | ContinueExpr | 'ContinueExpr : continue -> x(-7)' |
64+
| cfg.swift:329:5:329:17 | CallExpr | 'CallExpr : successor -> x(-9)' |
65+
| cfg.swift:335:10:335:10 | WhileStmt | 'WhileStmt : successor -> x(+0)' |
66+
| cfg.swift:335:16:335:21 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
67+
| cfg.swift:336:12:336:12 | WhileStmt | 'WhileStmt : successor -> x(+0)' |
68+
| cfg.swift:336:18:336:23 | BinaryExpr | 'BinaryExpr : false -> print(+11)' |
69+
| cfg.swift:336:18:336:23 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
70+
| cfg.swift:339:10:339:16 | BinaryExpr | 'BinaryExpr : false -> IfExpr(+3)' |
71+
| cfg.swift:339:10:339:16 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
72+
| cfg.swift:342:15:342:20 | BinaryExpr | 'BinaryExpr : false -> print(+3)' |
73+
| cfg.swift:342:15:342:20 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
74+
| cfg.swift:343:9:343:22 | ContinueExpr | 'ContinueExpr : continue -> x(-7)' |
75+
| cfg.swift:345:7:345:19 | CallExpr | 'CallExpr : successor -> x(-9)' |
76+
| cfg.swift:347:5:347:17 | CallExpr | 'CallExpr : successor -> x(-12)' |
77+
| cfg.swift:352:3:352:3 | DoWhileStmt | 'DoWhileStmt : successor -> Block(+0)' |
78+
| cfg.swift:355:11:355:16 | BinaryExpr | 'BinaryExpr : true -> Block(-3)' |
79+
| cfg.swift:360:3:360:3 | WhileStmt | 'WhileStmt : successor -> x(+0)' |
80+
| cfg.swift:360:9:360:14 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
81+
| cfg.swift:361:5:361:10 | CompoundAssignExpr | 'CompoundAssignExpr : successor -> x(-1)' |
82+
| cfg.swift:500:6:500:28 | | ' : false -> IfExpr(+4)' |
83+
| cfg.swift:500:6:500:28 | | ' : true -> Block(+0)' |
84+
| cfg.swift:501:5:501:10 | CompoundAssignExpr | 'CompoundAssignExpr : successor -> IfExpr(+3)' |
85+
| cfg.swift:504:6:504:31 | | ' : false -> IfExpr(+4)' |
86+
| cfg.swift:504:6:504:31 | | ' : true -> Block(+0)' |
87+
| cfg.swift:505:5:505:10 | CompoundAssignExpr | 'CompoundAssignExpr : successor -> IfExpr(+3)' |
88+
| cfg.swift:508:6:508:47 | | ' : false -> GuardIfStmt(+4)' |
89+
| cfg.swift:508:6:508:47 | | ' : true -> Block(+0)' |
90+
| cfg.swift:509:5:509:10 | CompoundAssignExpr | 'CompoundAssignExpr : successor -> GuardIfStmt(+3)' |
91+
| cfg.swift:516:6:516:28 | | ' : false,false -> x(+5)' |
92+
| cfg.swift:516:6:516:28 | | ' : true -> (+1)' |
93+
| cfg.swift:517:7:517:27 | | ' : false,false -> x(+4)' |
94+
| cfg.swift:517:7:517:27 | | ' : true -> Block(+0)' |
95+
| cfg.swift:518:5:518:10 | CompoundAssignExpr | 'CompoundAssignExpr : successor -> x(+3)' |
96+
| cfg.swift:528:26:528:32 | BinaryExpr | 'BinaryExpr : empty -> continuation(+3)' |
97+
| cfg.swift:528:26:528:32 | BinaryExpr | 'BinaryExpr : non-empty -> i(+0)' |
98+
| cfg.swift:529:21:529:41 | CallExpr | 'CallExpr : successor -> continuation(+2)' |
99+
| cfg.swift:529:21:529:41 | CallExpr | 'CallExpr : successor -> i(-1)' |
100+
| cfg.swift:535:24:535:29 | stream | 'stream : non-empty -> i(+0)' |
101+
| cfg.swift:536:9:536:16 | CallExpr | 'CallExpr : successor -> i(-1)' |
102+
| cfg.swift:542:5:542:5 | x | 'x : non-null -> ReturnExpr(-1)' |
103+
| cfg.swift:542:5:542:5 | x | 'x : null -> 0(+1)' |
104+
| cfg.swift:543:9:543:9 | 0 | '0 : successor -> ReturnExpr(-2)' |
105+
| cfg.swift:547:6:547:6 | x | 'x : non-null,false -> Block(+3)' |
106+
| cfg.swift:547:6:547:6 | x | 'x : non-null,true -> Block(+1)' |
107+
| cfg.swift:547:6:547:6 | x | 'x : null -> false(+1)' |
108+
| cfg.swift:548:7:548:11 | false | 'false : false -> Block(+2)' |
109+
| cfg.swift:587:10:587:14 | BinaryExpr | 'BinaryExpr : match -> Block(+0)' |
110+
| cfg.swift:587:10:587:14 | BinaryExpr | 'BinaryExpr : no-match -> SwitchCase(+1)' |
111+
| cfg.swift:587:17:587:17 | 1 | '1 : successor -> VariableDeclaration(+3)' |
112+
| cfg.swift:588:14:588:14 | 2 | '2 : successor -> VariableDeclaration(+2)' |
113+
| cfg.swift:591:13:591:18 | BinaryExpr | 'BinaryExpr : false -> Block(+1)' |
114+
| cfg.swift:591:13:591:18 | BinaryExpr | 'BinaryExpr : true -> Block(+0)' |
115+
noCfg
116+
| cfg.swift:23:9:23:9 | x |
117+
| cfg.swift:24:5:24:42 | ThrowExpr |
118+
| cfg.swift:35:11:35:17 | MyError |
119+
| cfg.swift:36:5:36:12 | ReturnExpr |
120+
| cfg.swift:37:11:37:17 | MyError |
121+
| cfg.swift:38:5:38:20 | ReturnExpr |
122+
| cfg.swift:39:11:39:20 | |
123+
| cfg.swift:40:5:40:9 | print |
124+
| cfg.swift:42:5:42:9 | print |
125+
| cfg.swift:47:42:47:47 | String |
126+
| cfg.swift:53:34:53:34 | _ |
127+
| cfg.swift:60:34:60:34 | _ |
128+
| cfg.swift:66:6:66:17 | callClosures |
129+
| cfg.swift:77:6:77:27 | forceAndBackToOptional |
130+
| cfg.swift:83:6:83:14 | testInOut |
131+
| cfg.swift:106:8:106:15 | getMyInt |
132+
| cfg.swift:146:7:146:17 | ReturnExpr |
133+
| cfg.swift:155:3:155:5 | var |
134+
| cfg.swift:156:6:156:8 | obj |
135+
| cfg.swift:157:5:157:15 | ReturnExpr |
136+
| cfg.swift:160:3:160:5 | let |
137+
| cfg.swift:161:6:161:34 | PatternGuardExpr |
138+
| cfg.swift:162:5:162:17 | ReturnExpr |
139+
| cfg.swift:164:5:164:16 | ReturnExpr |
140+
| cfg.swift:236:6:236:23 | constant_condition |
141+
| cfg.swift:238:5:238:9 | print |
142+
| cfg.swift:279:6:279:22 | testSubscriptExpr |
143+
| cfg.swift:358:6:358:28 | loop_with_identity_expr |
144+
| cfg.swift:371:8:371:18 | getOptional |
145+
| cfg.swift:380:45:380:47 | Int |
146+
| cfg.swift:381:13:381:13 | z |
147+
| cfg.swift:421:6:421:22 | localDeclarations |
148+
| cfg.swift:468:6:468:17 | testIfConfig |
149+
| cfg.swift:497:6:497:18 | testAvailable |
150+
| cfg.swift:524:6:524:17 | testAsyncFor |
151+
| cfg.swift:559:6:559:20 | autoclosureTest |
152+
nonSimple
153+
| cfg.swift:10:1:10:1 | ClassLikeDeclaration | 'ClassLikeDeclaration -V MyError -^ BaseType -V Error' |
154+
| cfg.swift:209:5:209:5 | x | 'x -> x -? - -^ UnaryExpr -^ AssignExpr' |
155+
| cfg.swift:390:1:390:1 | ClassLikeDeclaration | 'ClassLikeDeclaration -V Derived -^ BaseType -V C' |
156+
| cfg.swift:527:13:527:16 | Task | 'Task -^ MemberAccessExpr -^ Argument -V FunctionExpr -^ CallExpr' |
157+
| cfg.swift:569:1:569:1 | ClassLikeDeclaration | 'ClassLikeDeclaration -V MyProcotolImpl -^ BaseType -V MyProtocol' |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import unified
2+
import ControlFlow::TestCfgInline
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: cfg.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)