File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed
ql/lib/codeql/swift/elements Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 1
1
private import codeql.swift.generated.Callable
2
2
private import codeql.swift.elements.AstNode
3
+ private import codeql.swift.elements.decl.Decl
3
4
4
- class Callable extends Generated:: Callable , AstNode { }
5
+ class Callable extends Generated:: Callable , AstNode {
6
+ /**
7
+ * Holds if this Callable is a function named `funcName`.
8
+ */
9
+ predicate hasName ( string funcName ) { this .getName ( ) = funcName }
10
+
11
+ /**
12
+ * Holds if this Callable is a function named `funcName` defined in a module
13
+ * called `moduleName`.
14
+ */
15
+ predicate hasName ( string moduleName , string funcName ) {
16
+ this .hasName ( funcName ) and
17
+ this .( Decl ) .getModule ( ) .getFullName ( ) = moduleName
18
+ }
19
+ }
Original file line number Diff line number Diff line change 1
1
private import codeql.swift.generated.decl.AbstractFunctionDecl
2
2
private import codeql.swift.elements.decl.MethodDecl
3
+ private import codeql.swift.elements.Callable
3
4
4
5
/**
5
6
* A function.
6
7
*/
7
- class AbstractFunctionDecl extends Generated:: AbstractFunctionDecl {
8
+ class AbstractFunctionDecl extends Generated:: AbstractFunctionDecl , Callable {
8
9
override string toString ( ) { result = this .getName ( ) }
9
-
10
- /**
11
- * Holds if this function is called `funcName`.
12
- */
13
- predicate hasName ( string funcName ) { this .getName ( ) = funcName }
14
10
}
15
11
16
12
/**
Original file line number Diff line number Diff line change @@ -177,12 +177,13 @@ class ParamDecl(VarDecl):
177
177
""" )
178
178
179
179
class Callable (Element ):
180
+ name : optional [string ] | doc ("name of this Callable" )
180
181
self_param : optional [ParamDecl ] | child
181
182
params : list [ParamDecl ] | child
182
183
body : optional ["BraceStmt" ] | child | desc ("The body is absent within protocol declarations." )
183
184
184
185
class AbstractFunctionDecl (GenericContext , ValueDecl , Callable ):
185
- name : string | doc ( "name of this function" )
186
+ pass
186
187
187
188
class EnumElementDecl (ValueDecl ):
188
189
name : string
You can’t perform that action at this time.
0 commit comments