File tree Expand file tree Collapse file tree 9 files changed +78
-19
lines changed
lib/codeql/swift/elements/expr Expand file tree Collapse file tree 9 files changed +78
-19
lines changed Original file line number Diff line number Diff line change 1
1
private import codeql.swift.generated.expr.ApplyExpr
2
- private import codeql.swift.elements.decl.AbstractFunctionDecl
2
+ private import codeql.swift.elements.Callable
3
3
private import codeql.swift.elements.expr.DeclRefExpr
4
- private import codeql.swift.elements.expr.MethodRefExpr
4
+ private import codeql.swift.elements.expr.MethodLookupExpr
5
5
private import codeql.swift.elements.expr.ConstructorRefCallExpr
6
+ private import codeql.swift.elements.decl.MethodDecl
6
7
7
8
class ApplyExpr extends Generated:: ApplyExpr {
8
- AbstractFunctionDecl getStaticTarget ( ) {
9
+ Callable getStaticTarget ( ) {
9
10
exists ( Expr f |
10
11
f = this .getFunction ( ) and
11
12
(
12
13
result = f .( DeclRefExpr ) .getDecl ( )
13
14
or
14
- result = f .( ConstructorRefCallExpr ) .getFunction ( ) .( DeclRefExpr ) .getDecl ( )
15
+ result = f .( ConstructorRefCallExpr ) .getFunction ( ) .( DeclRefExpr ) .getDecl ( ) // TODO: fix this
15
16
)
16
17
)
17
18
}
@@ -36,11 +37,11 @@ class ApplyExpr extends Generated::ApplyExpr {
36
37
}
37
38
38
39
class MethodApplyExpr extends ApplyExpr {
39
- private MethodRefExpr method ;
40
+ private MethodLookupExpr method ;
40
41
41
42
MethodApplyExpr ( ) { method = this .getFunction ( ) }
42
43
43
- override AbstractFunctionDecl getStaticTarget ( ) { result = method .getMethod ( ) }
44
+ override MethodDecl getStaticTarget ( ) { result = method .getMethod ( ) }
44
45
45
46
override Expr getQualifier ( ) { result = method .getBase ( ) }
46
47
}
Original file line number Diff line number Diff line change @@ -31,4 +31,6 @@ class BinaryExpr extends Generated::BinaryExpr {
31
31
Expr getAnOperand ( ) { result = [ this .getLeftOperand ( ) , this .getRightOperand ( ) ] }
32
32
33
33
override string toString ( ) { result = "... " + this .getFunction ( ) .toString ( ) + " ..." }
34
+
35
+ override AbstractFunctionDecl getStaticTarget ( ) { result = super .getStaticTarget ( ) }
34
36
}
Original file line number Diff line number Diff line change 1
- // generated by codegen/codegen.py, remove this comment if you wish to edit this file
2
1
private import codeql.swift.generated.Raw
3
2
4
- predicate constructConstructorRefCallExpr ( Raw:: ConstructorRefCallExpr id ) { any ( ) }
3
+ predicate constructConstructorRefCallExpr ( Raw:: ConstructorRefCallExpr id ) { none ( ) }
Original file line number Diff line number Diff line change 1
- // generated by codegen/codegen.py, remove this comment if you wish to edit this file
2
1
private import codeql.swift.generated.Raw
3
- private import codeql.swift.generated.PureSynthConstructors
4
2
5
- predicate constructDotSyntaxCallExpr ( Raw:: DotSyntaxCallExpr id ) { not constructMethodRefExpr ( id ) }
3
+ predicate constructDotSyntaxCallExpr ( Raw:: DotSyntaxCallExpr id ) { none ( ) }
Original file line number Diff line number Diff line change 1
- private import codeql.swift.generated.expr.MethodRefExpr
1
+ private import codeql.swift.generated.expr.MethodLookupExpr
2
2
private import codeql.swift.elements.expr.Expr
3
3
private import codeql.swift.elements.decl.Decl
4
- private import codeql.swift.elements.decl.AbstractFunctionDecl
4
+ private import codeql.swift.elements.decl.MethodDecl
5
5
private import codeql.swift.generated.Raw
6
6
private import codeql.swift.generated.Synth
7
7
8
- class MethodRefExpr extends Generated:: MethodRefExpr {
8
+ class MethodLookupExpr extends Generated:: MethodLookupExpr {
9
9
override string toString ( ) { result = "." + this .getMember ( ) .toString ( ) }
10
10
11
11
override Expr getImmediateBase ( ) {
@@ -14,11 +14,11 @@ class MethodRefExpr extends Generated::MethodRefExpr {
14
14
15
15
override Decl getImmediateMember ( ) {
16
16
result =
17
- Synth:: convertDeclFromRaw ( this .getUnderlying ( ) .getFunction ( ) .( Raw:: DeclRefExpr ) .getDecl ( ) )
17
+ Synth:: convertDeclFromRaw ( this .getUnderlying ( ) .getFunction ( ) .( Raw:: DeclRefExpr ) .getDecl ( ) ) // TODO: FIX THIS
18
18
}
19
19
20
- AbstractFunctionDecl getMethod ( ) { result = this .getMember ( ) }
20
+ MethodDecl getMethod ( ) { result = this .getMember ( ) }
21
21
22
22
cached
23
- private Raw:: DotSyntaxCallExpr getUnderlying ( ) { this = Synth:: TMethodRefExpr ( result ) }
23
+ private Raw:: SelfApplyExpr getUnderlying ( ) { this = Synth:: TMethodLookupExpr ( result ) }
24
24
}
Original file line number Diff line number Diff line change
1
+ private import codeql.swift.generated.Raw
2
+
3
+ predicate constructMethodLookupExpr ( Raw:: SelfApplyExpr id ) { any ( ) }
Original file line number Diff line number Diff line change @@ -19,4 +19,6 @@ class PrefixUnaryExpr extends Generated::PrefixUnaryExpr {
19
19
* Gets the operator of this prefix unary expression (the function that is called).
20
20
*/
21
21
AbstractFunctionDecl getOperator ( ) { result = this .getStaticTarget ( ) }
22
+
23
+ override AbstractFunctionDecl getStaticTarget ( ) { result = super .getStaticTarget ( ) }
22
24
}
Original file line number Diff line number Diff line change
1
+ class X {
2
+ static func foo( _: Int , _: Int ) { }
3
+ class func bar( ) { }
4
+ func baz( _: Int ) { }
5
+
6
+ init ( ) {
7
+ let f = baz
8
+ }
9
+ }
10
+
11
+ actor Y {
12
+ static func foo( _: Int , _: Int ) { }
13
+ func baz( _: Int ) { }
14
+
15
+ init ( ) {
16
+ let f = baz
17
+ }
18
+ }
19
+
20
+ @MainActor
21
+ class Z {
22
+ static func foo( _: Int , _: Int ) { }
23
+ class func bar( ) { }
24
+ func baz( _: Int ) { }
25
+
26
+ init ( ) {
27
+ let f = baz
28
+ }
29
+ }
30
+
31
+ do {
32
+ X . foo ( 1 , 2 )
33
+ X . bar ( )
34
+ X ( ) . baz ( 42 )
35
+
36
+ let f = X . bar
37
+ let g = X ( ) . baz
38
+ }
39
+
40
+ Task {
41
+ Y . foo ( 1 , 2 )
42
+ await Y ( ) . baz ( 42 )
43
+
44
+ let f = Y . foo
45
+ }
46
+
47
+ Task {
48
+ await Z . foo ( 1 , 2 )
49
+ await Z . bar ( )
50
+ await Z ( ) . baz ( 42 )
51
+
52
+ let f = Z . bar
53
+ let g = ( await Z ( ) ) . baz
54
+ }
Original file line number Diff line number Diff line change @@ -674,8 +674,8 @@ class ConstructorRefCallExpr(SelfApplyExpr):
674
674
class DotSyntaxCallExpr (SelfApplyExpr ):
675
675
pass
676
676
677
- @synth .from_class (DotSyntaxCallExpr )
678
- class MethodRefExpr (LookupExpr ):
677
+ @synth .from_class (SelfApplyExpr )
678
+ class MethodLookupExpr (LookupExpr ):
679
679
pass
680
680
681
681
class DynamicMemberRefExpr (DynamicLookupExpr ):
You can’t perform that action at this time.
0 commit comments