Swift: add more SelfApplyExpr testing

This commit is contained in:
Paolo Tranquilli
2022-08-16 17:46:22 +02:00
parent dd23d48ad2
commit f17fed7c9a
12 changed files with 79 additions and 10 deletions

View File

@@ -0,0 +1,3 @@
| constructor_ref_calls.swift:7:9:7:9 | call to init | getFunction: | constructor_ref_calls.swift:7:9:7:9 | init | getBaseExpr: | constructor_ref_calls.swift:7:9:7:9 | X.Type |
| constructor_ref_calls.swift:8:10:8:10 | call to init | getFunction: | constructor_ref_calls.swift:8:10:8:10 | init | getBaseExpr: | constructor_ref_calls.swift:8:10:8:10 | Y.Type |
| constructor_ref_calls.swift:9:10:9:10 | call to init | getFunction: | constructor_ref_calls.swift:9:10:9:10 | init | getBaseExpr: | constructor_ref_calls.swift:9:10:9:10 | Y.Type |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ConstructorRefCallExpr x, Expr getFunction, Expr getBaseExpr
where
toBeTested(x) and
not x.isUnknown() and
getFunction = x.getFunction() and
getBaseExpr = x.getBaseExpr()
select x, "getFunction:", getFunction, "getBaseExpr:", getBaseExpr

View File

@@ -0,0 +1,3 @@
| constructor_ref_calls.swift:7:9:7:9 | call to init | 0 | constructor_ref_calls.swift:7:9:7:9 | : X.Type |
| constructor_ref_calls.swift:8:10:8:10 | call to init | 0 | constructor_ref_calls.swift:8:10:8:10 | : Y.Type |
| constructor_ref_calls.swift:9:10:9:10 | call to init | 0 | constructor_ref_calls.swift:9:10:9:10 | : Y.Type |

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ConstructorRefCallExpr x, int index
where toBeTested(x) and not x.isUnknown()
select x, index, x.getArgument(index)

View File

@@ -0,0 +1,3 @@
| constructor_ref_calls.swift:7:9:7:9 | call to init | () -> X |
| constructor_ref_calls.swift:8:10:8:10 | call to init | (Int) -> Y |
| constructor_ref_calls.swift:9:10:9:10 | call to init | () -> Y |

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ConstructorRefCallExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,9 @@
struct X {}
struct Y {
init() {}
init(_: Int) {}
}
let x = X()
let y1 = Y(42)
let y2 = Y()

View File

@@ -1,2 +1,9 @@
| dot_syntax_call.swift:6:1:6:3 | call to foo(_:_:) | getFunction: | dot_syntax_call.swift:6:3:6:3 | foo(_:_:) | getBaseExpr: | dot_syntax_call.swift:6:1:6:1 | X.Type |
| dot_syntax_call.swift:7:1:7:3 | call to bar() | getFunction: | dot_syntax_call.swift:7:3:7:3 | bar() | getBaseExpr: | dot_syntax_call.swift:7:1:7:1 | X.Type |
| dot_syntax_call.swift:7:13:7:13 | call to ... | getFunction: | dot_syntax_call.swift:7:13:7:13 | { ... } | getBaseExpr: | dot_syntax_call.swift:7:13:7:13 | self |
| dot_syntax_call.swift:7:13:7:13 | call to baz(_:) | getFunction: | dot_syntax_call.swift:7:13:7:13 | baz(_:) | getBaseExpr: | file://:0:0:0:0 | self |
| dot_syntax_call.swift:11:1:11:3 | call to foo(_:_:) | getFunction: | dot_syntax_call.swift:11:3:11:3 | foo(_:_:) | getBaseExpr: | dot_syntax_call.swift:11:1:11:1 | X.Type |
| dot_syntax_call.swift:12:1:12:3 | call to bar() | getFunction: | dot_syntax_call.swift:12:3:12:3 | bar() | getBaseExpr: | dot_syntax_call.swift:12:1:12:1 | X.Type |
| dot_syntax_call.swift:13:1:13:5 | call to baz(_:) | getFunction: | dot_syntax_call.swift:13:5:13:5 | baz(_:) | getBaseExpr: | dot_syntax_call.swift:13:1:13:3 | call to ... |
| dot_syntax_call.swift:15:9:15:11 | call to ... | getFunction: | dot_syntax_call.swift:15:11:15:11 | { ... } | getBaseExpr: | dot_syntax_call.swift:15:9:15:9 | X.Type |
| dot_syntax_call.swift:15:11:15:11 | call to bar() | getFunction: | dot_syntax_call.swift:15:11:15:11 | bar() | getBaseExpr: | file://:0:0:0:0 | self |
| dot_syntax_call.swift:16:9:16:13 | call to ... | getFunction: | dot_syntax_call.swift:16:13:16:13 | { ... } | getBaseExpr: | dot_syntax_call.swift:16:9:16:11 | call to ... |
| dot_syntax_call.swift:16:13:16:13 | call to baz(_:) | getFunction: | dot_syntax_call.swift:16:13:16:13 | baz(_:) | getBaseExpr: | file://:0:0:0:0 | self |

View File

@@ -1,2 +1,9 @@
| dot_syntax_call.swift:6:1:6:3 | call to foo(_:_:) | 0 | dot_syntax_call.swift:6:1:6:1 | : X.Type |
| dot_syntax_call.swift:7:1:7:3 | call to bar() | 0 | dot_syntax_call.swift:7:1:7:1 | : X.Type |
| dot_syntax_call.swift:7:13:7:13 | call to ... | 0 | dot_syntax_call.swift:7:13:7:13 | : self |
| dot_syntax_call.swift:7:13:7:13 | call to baz(_:) | 0 | file://:0:0:0:0 | : self |
| dot_syntax_call.swift:11:1:11:3 | call to foo(_:_:) | 0 | dot_syntax_call.swift:11:1:11:1 | : X.Type |
| dot_syntax_call.swift:12:1:12:3 | call to bar() | 0 | dot_syntax_call.swift:12:1:12:1 | : X.Type |
| dot_syntax_call.swift:13:1:13:5 | call to baz(_:) | 0 | dot_syntax_call.swift:13:1:13:3 | : call to ... |
| dot_syntax_call.swift:15:9:15:11 | call to ... | 0 | dot_syntax_call.swift:15:9:15:9 | : X.Type |
| dot_syntax_call.swift:15:11:15:11 | call to bar() | 0 | file://:0:0:0:0 | : self |
| dot_syntax_call.swift:16:9:16:13 | call to ... | 0 | dot_syntax_call.swift:16:9:16:11 | : call to ... |
| dot_syntax_call.swift:16:13:16:13 | call to baz(_:) | 0 | file://:0:0:0:0 | : self |

View File

@@ -1,2 +1,9 @@
| dot_syntax_call.swift:6:1:6:3 | call to foo(_:_:) | (Int, Int) -> () |
| dot_syntax_call.swift:7:1:7:3 | call to bar() | () -> () |
| dot_syntax_call.swift:7:13:7:13 | call to ... | (Int) -> () |
| dot_syntax_call.swift:7:13:7:13 | call to baz(_:) | (Int) -> () |
| dot_syntax_call.swift:11:1:11:3 | call to foo(_:_:) | (Int, Int) -> () |
| dot_syntax_call.swift:12:1:12:3 | call to bar() | () -> () |
| dot_syntax_call.swift:13:1:13:5 | call to baz(_:) | (Int) -> () |
| dot_syntax_call.swift:15:9:15:11 | call to ... | () -> () |
| dot_syntax_call.swift:15:11:15:11 | call to bar() | () -> () |
| dot_syntax_call.swift:16:9:16:13 | call to ... | (Int) -> () |
| dot_syntax_call.swift:16:13:16:13 | call to baz(_:) | (Int) -> () |

View File

@@ -1,7 +1,16 @@
class X {
static func foo(_: Int, _:Int) {}
class func bar() {}
func baz(_: Int) {}
init() {
let f = baz
}
}
X.foo(1, 2)
X.bar()
X().baz(42)
let f = X.bar
let g = X().baz