Skip to content

Commit e2478d1

Browse files
committed
Swift: 'getStaticCallTarget' should also return things like 'ConstructorDecl's.
1 parent a1bf448 commit e2478d1

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

swift/ql/lib/codeql/swift/elements/expr/ApplyExpr.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
private import codeql.swift.generated.expr.ApplyExpr
2-
private import codeql.swift.elements.decl.FuncDecl
2+
private import codeql.swift.elements.decl.AbstractFunctionDecl
33
private import codeql.swift.elements.expr.DeclRefExpr
44

55
class ApplyExpr extends ApplyExprBase {
6-
FuncDecl getStaticTarget() { result = this.getFunction().(DeclRefExpr).getDecl() }
6+
AbstractFunctionDecl getStaticTarget() { result = this.getFunction().(DeclRefExpr).getDecl() }
77

88
override string toString() {
99
result = "call to " + this.getStaticTarget().toString()

swift/ql/test/extractor-tests/expressions/all.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
| expressions.swift:21:6:21:16 | call to failure(_:) |
4545
| expressions.swift:21:14:21:14 | 11 |
4646
| expressions.swift:27:13:27:13 | Klass.Type |
47-
| expressions.swift:27:13:27:13 | call to ... |
47+
| expressions.swift:27:13:27:13 | call to init |
4848
| expressions.swift:27:13:27:13 | init |
4949
| expressions.swift:27:13:27:19 | call to ... |
5050
| expressions.swift:29:9:29:19 | [...] |
@@ -163,7 +163,7 @@
163163
| expressions.swift:79:11:79:11 | init |
164164
| expressions.swift:79:19:79:19 | 22 |
165165
| expressions.swift:83:15:83:15 | Derived.Type |
166-
| expressions.swift:83:15:83:15 | call to ... |
166+
| expressions.swift:83:15:83:15 | call to init |
167167
| expressions.swift:83:15:83:15 | init |
168168
| expressions.swift:83:15:83:23 | call to ... |
169169
| expressions.swift:84:1:84:1 | _ |
@@ -184,7 +184,7 @@
184184
| expressions.swift:92:14:92:55 | call to ... |
185185
| expressions.swift:92:24:92:24 | passRetained(_:) |
186186
| expressions.swift:92:37:92:37 | ToPtr.Type |
187-
| expressions.swift:92:37:92:37 | call to ... |
187+
| expressions.swift:92:37:92:37 | call to init |
188188
| expressions.swift:92:37:92:37 | init |
189189
| expressions.swift:92:37:92:43 | call to ... |
190190
| expressions.swift:92:46:92:46 | toOpaque() |

swift/ql/test/extractor-tests/types/Types.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
| types.swift:3:9:3:9 | call to +(_:_:) | (Int, Int) -> Int |
1414
| types.swift:3:11:3:11 | 10 | Int |
1515
| types.swift:7:16:7:16 | X.Type | X.Type |
16-
| types.swift:7:16:7:16 | call to ... | () -> X |
16+
| types.swift:7:16:7:16 | call to init | () -> X |
1717
| types.swift:7:16:7:16 | init | (X.Type) -> () -> X |
1818
| types.swift:7:16:7:18 | call to ... | X |
1919
| types.swift:13:17:13:17 | C.Type | C.Type |
20-
| types.swift:13:17:13:17 | call to ... | () -> C |
20+
| types.swift:13:17:13:17 | call to init | () -> C |
2121
| types.swift:13:17:13:17 | init | (C.Type) -> () -> C |
2222
| types.swift:13:17:13:19 | call to ... | C |
2323
| types.swift:14:22:14:24 | C.Nested.Type | C.Nested.Type |
24-
| types.swift:14:22:14:24 | call to ... | () -> C.Nested |
24+
| types.swift:14:22:14:24 | call to init | () -> C.Nested |
2525
| types.swift:14:22:14:31 | call to ... | C.Nested |
2626
| types.swift:14:24:14:24 | init | (C.Nested.Type) -> () -> C.Nested |
2727
| types.swift:17:10:17:10 | x | Int |

swift/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,9 @@ cfg.swift:
613613
#-----| match -> init
614614

615615
# 71| Int.Type
616-
#-----| -> call to ...
616+
#-----| -> call to init
617617

618-
# 71| call to ...
618+
# 71| call to init
619619
#-----| -> s
620620

621621
# 71| init
@@ -903,9 +903,9 @@ cfg.swift:
903903
#-----| -> n1
904904

905905
# 110| C.Type
906-
#-----| -> call to ...
906+
#-----| -> call to init
907907

908-
# 110| call to ...
908+
# 110| call to init
909909
#-----| -> 42
910910

911911
# 110| init

swift/ql/test/library-tests/parent/parent.expected

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@
148148
| declarations.swift:76:19:79:1 | { ... } | BraceStmt | declarations.swift:77:20:77:20 | x | ConcreteVarDecl |
149149
| declarations.swift:76:19:79:1 | { ... } | BraceStmt | declarations.swift:78:3:78:10 | return ... | ReturnStmt |
150150
| declarations.swift:77:4:77:4 | ZeroWrapper.Type | TypeExpr | declarations.swift:77:4:77:4 | FixedTypeRepr | FixedTypeRepr |
151-
| declarations.swift:77:4:77:4 | call to ... | CallExpr | declarations.swift:77:4:77:4 | call to ... | ConstructorRefCallExpr |
152-
| declarations.swift:77:4:77:4 | call to ... | ConstructorRefCallExpr | declarations.swift:77:4:77:4 | init | DeclRefExpr |
151+
| declarations.swift:77:4:77:4 | call to ... | CallExpr | declarations.swift:77:4:77:4 | call to init | ConstructorRefCallExpr |
152+
| declarations.swift:77:4:77:4 | call to init | ConstructorRefCallExpr | declarations.swift:77:4:77:4 | init | DeclRefExpr |
153153
| declarations.swift:77:16:77:23 | var ... = ... | PatternBindingDecl | declarations.swift:77:20:77:23 | ... as ... | TypedPattern |
154154
| declarations.swift:77:20:77:20 | ... as ... | TypedPattern | declarations.swift:77:20:77:20 | _x | NamedPattern |
155155
| declarations.swift:77:20:77:20 | get | AccessorDecl | declarations.swift:77:20:77:20 | { ... } | BraceStmt |
@@ -414,8 +414,8 @@
414414
| expressions.swift:27:1:27:19 | { ... } | BraceStmt | expressions.swift:27:1:27:19 | var ... = ... | PatternBindingDecl |
415415
| expressions.swift:27:1:27:19 | { ... } | TopLevelCodeDecl | expressions.swift:27:1:27:19 | { ... } | BraceStmt |
416416
| expressions.swift:27:13:27:13 | Klass.Type | TypeExpr | expressions.swift:27:13:27:13 | SimpleIdentTypeRepr | SimpleIdentTypeRepr |
417-
| expressions.swift:27:13:27:13 | call to ... | ConstructorRefCallExpr | expressions.swift:27:13:27:13 | init | DeclRefExpr |
418-
| expressions.swift:27:13:27:19 | call to ... | CallExpr | expressions.swift:27:13:27:13 | call to ... | ConstructorRefCallExpr |
417+
| expressions.swift:27:13:27:13 | call to init | ConstructorRefCallExpr | expressions.swift:27:13:27:13 | init | DeclRefExpr |
418+
| expressions.swift:27:13:27:19 | call to ... | CallExpr | expressions.swift:27:13:27:13 | call to init | ConstructorRefCallExpr |
419419
| expressions.swift:29:1:29:19 | var ... = ... | PatternBindingDecl | expressions.swift:29:5:29:5 | d | NamedPattern |
420420
| expressions.swift:29:1:29:19 | var ... = ... | PatternBindingDecl | expressions.swift:29:9:29:19 | [...] | DictionaryExpr |
421421
| expressions.swift:29:1:29:19 | { ... } | BraceStmt | expressions.swift:29:1:29:19 | var ... = ... | PatternBindingDecl |
@@ -576,8 +576,8 @@
576576
| expressions.swift:83:1:83:23 | { ... } | BraceStmt | expressions.swift:83:1:83:23 | var ... = ... | PatternBindingDecl |
577577
| expressions.swift:83:1:83:23 | { ... } | TopLevelCodeDecl | expressions.swift:83:1:83:23 | { ... } | BraceStmt |
578578
| expressions.swift:83:15:83:15 | Derived.Type | TypeExpr | expressions.swift:83:15:83:15 | SimpleIdentTypeRepr | SimpleIdentTypeRepr |
579-
| expressions.swift:83:15:83:15 | call to ... | ConstructorRefCallExpr | expressions.swift:83:15:83:15 | init | DeclRefExpr |
580-
| expressions.swift:83:15:83:23 | call to ... | CallExpr | expressions.swift:83:15:83:15 | call to ... | ConstructorRefCallExpr |
579+
| expressions.swift:83:15:83:15 | call to init | ConstructorRefCallExpr | expressions.swift:83:15:83:15 | init | DeclRefExpr |
580+
| expressions.swift:83:15:83:23 | call to ... | CallExpr | expressions.swift:83:15:83:15 | call to init | ConstructorRefCallExpr |
581581
| expressions.swift:84:1:84:13 | ... = ... | AssignExpr | expressions.swift:84:1:84:1 | _ | DiscardAssignmentExpr |
582582
| expressions.swift:84:1:84:13 | ... = ... | AssignExpr | expressions.swift:84:5:84:13 | .xx | MemberRefExpr |
583583
| expressions.swift:84:1:84:13 | { ... } | BraceStmt | expressions.swift:84:1:84:13 | ... = ... | AssignExpr |
@@ -610,8 +610,8 @@
610610
| expressions.swift:92:14:92:46 | call to toOpaque() | DotSyntaxCallExpr | expressions.swift:92:46:92:46 | toOpaque() | DeclRefExpr |
611611
| expressions.swift:92:14:92:55 | call to ... | CallExpr | expressions.swift:92:14:92:46 | call to toOpaque() | DotSyntaxCallExpr |
612612
| expressions.swift:92:37:92:37 | ToPtr.Type | TypeExpr | expressions.swift:92:37:92:37 | SimpleIdentTypeRepr | SimpleIdentTypeRepr |
613-
| expressions.swift:92:37:92:37 | call to ... | ConstructorRefCallExpr | expressions.swift:92:37:92:37 | init | DeclRefExpr |
614-
| expressions.swift:92:37:92:43 | call to ... | CallExpr | expressions.swift:92:37:92:37 | call to ... | ConstructorRefCallExpr |
613+
| expressions.swift:92:37:92:37 | call to init | ConstructorRefCallExpr | expressions.swift:92:37:92:37 | init | DeclRefExpr |
614+
| expressions.swift:92:37:92:43 | call to ... | CallExpr | expressions.swift:92:37:92:37 | call to init | ConstructorRefCallExpr |
615615
| expressions.swift:93:1:93:16 | Unmanaged<ToPtr>.Type | TypeExpr | expressions.swift:93:1:93:16 | ...<...> | GenericIdentTypeRepr |
616616
| expressions.swift:93:1:93:18 | call to fromOpaque(_:) | DotSyntaxCallExpr | expressions.swift:93:18:93:18 | fromOpaque(_:) | DeclRefExpr |
617617
| expressions.swift:93:1:93:35 | call to ... | CallExpr | expressions.swift:93:1:93:18 | call to fromOpaque(_:) | DotSyntaxCallExpr |

0 commit comments

Comments
 (0)