File tree Expand file tree Collapse file tree 6 files changed +15
-29
lines changed
ql/lib/codeql/swift/elements/expr Expand file tree Collapse file tree 6 files changed +15
-29
lines changed Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ private import codeql.swift.elements.expr.MethodLookupExpr
44predicate constructArgument ( Raw:: Argument id ) {
55 // exclude an argument that will be part of a SelfApplyExpr
66 // that will be transformed into a MethodLookupExpr
7- not exists ( Raw:: SelfApplyExpr e | id . getExpr ( ) = e .getBase ( ) )
7+ not exists ( Raw:: SelfApplyExpr e | id = e .getArgument ( 0 ) )
88}
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
12private import codeql.swift.generated.Raw
2- private import codeql.swift.elements.expr.MethodLookupExprConstructor
33
4- predicate constructDeclRefExpr ( Raw:: DeclRefExpr id ) {
5- // exclude an argument that will be part of a SelfApplyExpr
6- // that will be transformed into a MethodLookupExpr
7- not exists ( Raw:: SelfApplyExpr e | id .getDecl ( ) = extractDeclFromSelfApplyExpr ( e ) )
8- }
4+ predicate constructDeclRefExpr ( Raw:: DeclRefExpr id ) { any ( ) }
Original file line number Diff line number Diff line change 11private import codeql.swift.generated.expr.MethodLookupExpr
22private import codeql.swift.elements.expr.MethodLookupExprConstructor
33private import codeql.swift.elements.expr.Expr
4+ private import codeql.swift.elements.expr.DeclRefExpr
5+ private import codeql.swift.elements.expr.OtherConstructorDeclRefExpr
46private import codeql.swift.elements.decl.Decl
57private import codeql.swift.elements.decl.MethodDecl
68private import codeql.swift.generated.Raw
@@ -14,7 +16,13 @@ class MethodLookupExpr extends Generated::MethodLookupExpr {
1416 }
1517
1618 override Decl getImmediateMember ( ) {
17- result = Synth:: convertDeclFromRaw ( extractDeclFromSelfApplyExpr ( this .getUnderlying ( ) ) )
19+ result = this .getMethodRef ( ) .( DeclRefExpr ) .getDecl ( )
20+ or
21+ result = this .getMethodRef ( ) .( OtherConstructorDeclRefExpr ) .getConstructorDecl ( )
22+ }
23+
24+ override Expr getImmediateMethodRef ( ) {
25+ result = Synth:: convertExprFromRaw ( this .getUnderlying ( ) .getFunction ( ) )
1826 }
1927
2028 MethodDecl getMethod ( ) { result = this .getMember ( ) }
Original file line number Diff line number Diff line change 11private import codeql.swift.generated.Raw
22
33predicate constructMethodLookupExpr ( Raw:: SelfApplyExpr id ) { any ( ) }
4-
5- Raw:: Decl extractDeclFromSelfApplyExpr ( Raw:: SelfApplyExpr e ) {
6- exists ( Raw:: Expr unwrappedFunction | unwrappedFunction = unwrapConversion * ( e .getFunction ( ) ) |
7- result =
8- [
9- unwrappedFunction .( Raw:: DeclRefExpr ) .getDecl ( ) ,
10- unwrappedFunction .( Raw:: OtherConstructorDeclRefExpr ) .getConstructorDecl ( )
11- ]
12- )
13- }
14-
15- private Raw:: Expr unwrapConversion ( Raw:: Expr e ) {
16- e .( Raw:: ImplicitConversionExpr ) .getSubExpr ( ) = result
17- }
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
12private import codeql.swift.generated.Raw
2- private import codeql.swift.elements.expr.MethodLookupExprConstructor
33
4- predicate constructOtherConstructorDeclRefExpr ( Raw:: OtherConstructorDeclRefExpr id ) {
5- // exclude an argument that will be part of a SelfApplyExpr
6- // that will be transformed into a MethodLookupExpr
7- not exists ( Raw:: SelfApplyExpr e | id .getConstructorDecl ( ) = extractDeclFromSelfApplyExpr ( e ) )
8- }
4+ predicate constructOtherConstructorDeclRefExpr ( Raw:: OtherConstructorDeclRefExpr id ) { any ( ) }
Original file line number Diff line number Diff line change @@ -677,7 +677,7 @@ class DotSyntaxCallExpr(SelfApplyExpr):
677677
678678@synth .from_class (SelfApplyExpr )
679679class MethodLookupExpr (LookupExpr ):
680- pass
680+ method_ref : Expr | child | doc ( "the underlying method declaration reference expression" )
681681
682682class DynamicMemberRefExpr (DynamicLookupExpr ):
683683 pass
You can’t perform that action at this time.
0 commit comments