Skip to content

Commit 1ede851

Browse files
committed
Swift: initial getStaticTarget test
1 parent 99719d0 commit 1ede851

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
noStaticTarget
2+
| file://:0:0:0:0 | call to ... | file://:0:0:0:0 | (no string representation) | DeclRefExpr |
3+
| methodlookup.swift:27:5:27:27 | call to ... | methodlookup.swift:27:5:27:9 | .{ ... } | DotSyntaxBaseIgnoredExpr |
4+
| methodlookup.swift:27:5:27:29 | call to ... | methodlookup.swift:27:5:27:27 | call to ... | CallExpr |
5+
| methodlookup.swift:47:11:47:30 | call to ... | methodlookup.swift:47:11:47:15 | call to instanceMethod() | DotSyntaxCallExpr |
6+
| methodlookup.swift:48:11:48:33 | call to ... | methodlookup.swift:48:11:48:15 | .{ ... } | DotSyntaxBaseIgnoredExpr |
7+
| methodlookup.swift:48:11:48:35 | call to ... | methodlookup.swift:48:11:48:33 | call to ... | CallExpr |
8+
| methodlookup.swift:50:11:50:27 | call to ... | methodlookup.swift:50:11:50:15 | call to classMethod() | DotSyntaxCallExpr |
9+
| methodlookup.swift:51:11:51:28 | call to ... | methodlookup.swift:51:11:51:15 | call to staticMethod() | DotSyntaxCallExpr |
10+
#select
11+
| file://:0:0:0:0 | call to ... | false | - |
12+
| file://:0:0:0:0 | call to init(_:) | true | init(_:) |
13+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
14+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
15+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
16+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
17+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
18+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
19+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
20+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
21+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
22+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
23+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
24+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
25+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
26+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
27+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
28+
| file://:0:0:0:0 | call to zeroInitializer() | true | zeroInitializer() |
29+
| methodlookup.swift:23:15:23:19 | call to init() | true | init() |
30+
| methodlookup.swift:24:9:24:18 | call to init() | true | init() |
31+
| methodlookup.swift:26:5:26:24 | call to instanceMethod() | true | instanceMethod() |
32+
| methodlookup.swift:27:5:27:27 | call to ... | false | - |
33+
| methodlookup.swift:27:5:27:29 | call to ... | false | - |
34+
| methodlookup.swift:27:9:27:9 | call to instanceMethod() | true | instanceMethod() |
35+
| methodlookup.swift:29:5:29:21 | call to classMethod() | true | classMethod() |
36+
| methodlookup.swift:30:5:30:22 | call to staticMethod() | true | staticMethod() |
37+
| methodlookup.swift:33:1:41:1 | call to init(priority:operation:) | true | init(priority:operation:) |
38+
| methodlookup.swift:34:15:34:19 | call to init() | true | init() |
39+
| methodlookup.swift:35:9:35:18 | call to init() | true | init() |
40+
| methodlookup.swift:37:11:37:30 | call to instanceMethod() | true | instanceMethod() |
41+
| methodlookup.swift:40:5:40:22 | call to staticMethod() | true | staticMethod() |
42+
| methodlookup.swift:43:1:52:1 | call to init(priority:operation:) | true | init(priority:operation:) |
43+
| methodlookup.swift:44:21:44:25 | call to init() | true | init() |
44+
| methodlookup.swift:45:15:45:24 | call to init() | true | init() |
45+
| methodlookup.swift:47:11:47:30 | call to ... | false | - |
46+
| methodlookup.swift:48:11:48:33 | call to ... | false | - |
47+
| methodlookup.swift:48:11:48:35 | call to ... | false | - |
48+
| methodlookup.swift:48:15:48:15 | call to instanceMethod() | true | instanceMethod() |
49+
| methodlookup.swift:50:11:50:27 | call to ... | false | - |
50+
| methodlookup.swift:51:11:51:28 | call to ... | false | - |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import swift
2+
3+
query predicate noStaticTarget(CallExpr c, Expr func, string funcClass) {
4+
not exists(c.getStaticTarget()) and
5+
func = c.getFunction() and
6+
funcClass = func.getPrimaryQlClasses()
7+
}
8+
9+
from CallExpr c, boolean hasStaticTarget, string staticTarget
10+
where
11+
if exists(c.getStaticTarget().toString())
12+
then (
13+
hasStaticTarget = true and
14+
staticTarget = c.getStaticTarget().toString()
15+
) else (
16+
hasStaticTarget = false and
17+
staticTarget = "-"
18+
)
19+
select c, hasStaticTarget, staticTarget

swift/ql/test/extractor-tests/expressions/methodlookup/methodlookup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Task {
4444
let baz = await Baz()
4545
_ = await Baz.init()
4646

47-
await baz.instanceMethod()
48-
await Baz.instanceMethod(baz)()
47+
await baz.instanceMethod() // DotSyntaxCallExpr
48+
await Baz.instanceMethod(baz)() // DotSyntaxBaseIgnoredExpr
4949

5050
await Baz.classMethod()
5151
await Baz.staticMethod()

0 commit comments

Comments
 (0)