Swift: extract DynamicLookupExpr

This commit is contained in:
Paolo Tranquilli
2022-11-09 16:31:59 +01:00
parent e2bdef2fba
commit 1a062823ee
14 changed files with 25 additions and 11 deletions

View File

@@ -0,0 +1,2 @@
| dynamic_lookup.swift:15:1:15:3 | .foo(_:) | DynamicMemberRefExpr | getBase: | dynamic_lookup.swift:15:1:15:1 | OpaqueValueExpr |
| dynamic_lookup.swift:16:5:16:9 | subscript ...[...] | DynamicSubscriptExpr | getBase: | dynamic_lookup.swift:16:5:16:5 | OpaqueValueExpr |

View File

@@ -2,9 +2,9 @@
import codeql.swift.elements
import TestUtils
from DynamicMemberRefExpr x, Expr getBase
from DynamicLookupExpr x, Expr getBase
where
toBeTested(x) and
not x.isUnknown() and
getBase = x.getBase()
select x, "getBase:", getBase
select x, x.getPrimaryQlClasses(), "getBase:", getBase

View File

@@ -0,0 +1,2 @@
| dynamic_lookup.swift:15:1:15:3 | .foo(_:) | dynamic_lookup.swift:6:9:6:28 | foo(_:) |
| dynamic_lookup.swift:16:5:16:9 | subscript ...[...] | dynamic_lookup.swift:7:9:9:3 | subscript ... |

View File

@@ -2,6 +2,6 @@
import codeql.swift.elements
import TestUtils
from DynamicMemberRefExpr x
from DynamicLookupExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getMember()

View File

@@ -0,0 +1,2 @@
| dynamic_lookup.swift:15:1:15:3 | .foo(_:) | ((Int) -> ())? |
| dynamic_lookup.swift:16:5:16:9 | subscript ...[...] | Int? |

View File

@@ -2,6 +2,6 @@
import codeql.swift.elements
import TestUtils
from DynamicMemberRefExpr x
from DynamicLookupExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()

View File

@@ -4,9 +4,13 @@
// Successful compilation would require importing Foundation for `@objc`
class A {
@objc func foo(_ : Int) {}
@objc subscript(i : Int) -> Int {
get { return 0 }
}
};
class B {}
var x : AnyObject = B()
x.foo!(17)
_ = x[17]!

View File

@@ -1 +0,0 @@
| dynamic_member_ref.swift:12:1:12:3 | .foo(_:) | getBase: | dynamic_member_ref.swift:12:1:12:1 | OpaqueValueExpr |

View File

@@ -1 +0,0 @@
| dynamic_member_ref.swift:12:1:12:3 | .foo(_:) | dynamic_member_ref.swift:6:9:6:28 | foo(_:) |

View File

@@ -1 +0,0 @@
| dynamic_member_ref.swift:12:1:12:3 | .foo(_:) | ((Int) -> ())? |

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