File tree Expand file tree Collapse file tree
lib/codeql/swift/elements/expr Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11private import codeql.swift.generated.expr.ApplyExpr
2- private import codeql.swift.elements.decl.AbstractFunctionDecl
2+ private import codeql.swift.elements.Callable
33private import codeql.swift.elements.expr.DeclRefExpr
4- private import codeql.swift.elements.expr.MethodRefExpr
4+ private import codeql.swift.elements.expr.MethodLookupExpr
55private import codeql.swift.elements.expr.ConstructorRefCallExpr
6+ private import codeql.swift.elements.decl.MethodDecl
67
78class ApplyExpr extends Generated:: ApplyExpr {
8- AbstractFunctionDecl getStaticTarget ( ) {
9+ Callable getStaticTarget ( ) {
910 exists ( Expr f |
1011 f = this .getFunction ( ) and
1112 (
1213 result = f .( DeclRefExpr ) .getDecl ( )
1314 or
14- result = f .( ConstructorRefCallExpr ) .getFunction ( ) .( DeclRefExpr ) .getDecl ( )
15+ result = f .( ConstructorRefCallExpr ) .getFunction ( ) .( DeclRefExpr ) .getDecl ( ) // TODO: fix this
1516 )
1617 )
1718 }
@@ -36,11 +37,11 @@ class ApplyExpr extends Generated::ApplyExpr {
3637}
3738
3839class MethodApplyExpr extends ApplyExpr {
39- private MethodRefExpr method ;
40+ private MethodLookupExpr method ;
4041
4142 MethodApplyExpr ( ) { method = this .getFunction ( ) }
4243
43- override AbstractFunctionDecl getStaticTarget ( ) { result = method .getMethod ( ) }
44+ override MethodDecl getStaticTarget ( ) { result = method .getMethod ( ) }
4445
4546 override Expr getQualifier ( ) { result = method .getBase ( ) }
4647}
Original file line number Diff line number Diff line change @@ -31,4 +31,6 @@ class BinaryExpr extends Generated::BinaryExpr {
3131 Expr getAnOperand ( ) { result = [ this .getLeftOperand ( ) , this .getRightOperand ( ) ] }
3232
3333 override string toString ( ) { result = "... " + this .getFunction ( ) .toString ( ) + " ..." }
34+
35+ override AbstractFunctionDecl getStaticTarget ( ) { result = super .getStaticTarget ( ) }
3436}
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
21private import codeql.swift.generated.Raw
32
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
21private import codeql.swift.generated.Raw
3- private import codeql.swift.generated.PureSynthConstructors
42
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
22private import codeql.swift.elements.expr.Expr
33private import codeql.swift.elements.decl.Decl
4- private import codeql.swift.elements.decl.AbstractFunctionDecl
4+ private import codeql.swift.elements.decl.MethodDecl
55private import codeql.swift.generated.Raw
66private import codeql.swift.generated.Synth
77
8- class MethodRefExpr extends Generated:: MethodRefExpr {
8+ class MethodLookupExpr extends Generated:: MethodLookupExpr {
99 override string toString ( ) { result = "." + this .getMember ( ) .toString ( ) }
1010
1111 override Expr getImmediateBase ( ) {
@@ -14,11 +14,11 @@ class MethodRefExpr extends Generated::MethodRefExpr {
1414
1515 override Decl getImmediateMember ( ) {
1616 result =
17- Synth:: convertDeclFromRaw ( this .getUnderlying ( ) .getFunction ( ) .( Raw:: DeclRefExpr ) .getDecl ( ) )
17+ Synth:: convertDeclFromRaw ( this .getUnderlying ( ) .getFunction ( ) .( Raw:: DeclRefExpr ) .getDecl ( ) ) // TODO: FIX THIS
1818 }
1919
20- AbstractFunctionDecl getMethod ( ) { result = this .getMember ( ) }
20+ MethodDecl getMethod ( ) { result = this .getMember ( ) }
2121
2222 cached
23- private Raw:: DotSyntaxCallExpr getUnderlying ( ) { this = Synth:: TMethodRefExpr ( result ) }
23+ private Raw:: SelfApplyExpr getUnderlying ( ) { this = Synth:: TMethodLookupExpr ( result ) }
2424}
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 {
1919 * Gets the operator of this prefix unary expression (the function that is called).
2020 */
2121 AbstractFunctionDecl getOperator ( ) { result = this .getStaticTarget ( ) }
22+
23+ override AbstractFunctionDecl getStaticTarget ( ) { result = super .getStaticTarget ( ) }
2224}
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):
674674class DotSyntaxCallExpr (SelfApplyExpr ):
675675 pass
676676
677- @synth .from_class (DotSyntaxCallExpr )
678- class MethodRefExpr (LookupExpr ):
677+ @synth .from_class (SelfApplyExpr )
678+ class MethodLookupExpr (LookupExpr ):
679679 pass
680680
681681class DynamicMemberRefExpr (DynamicLookupExpr ):
You can’t perform that action at this time.
0 commit comments