File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
ql/lib/codeql/swift/elements/decl Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ AstNode:
81
81
Callable :
82
82
_children :
83
83
params : ParamDecl*
84
+ self_param : ParamDecl?
84
85
body : BraceStmt?
85
86
86
87
ConditionElement :
Original file line number Diff line number Diff line change @@ -327,6 +327,8 @@ void DeclVisitor::fillAbstractFunctionDecl(const swift::AbstractFunctionDecl& de
327
327
entry.name = !decl.hasName () ? " (unnamed function decl)" : constructName (decl.getName ());
328
328
entry.body = dispatcher_.fetchOptionalLabel (decl.getBody ());
329
329
entry.params = dispatcher_.fetchRepeatedLabels (*decl.getParameters ());
330
+ auto self = const_cast <swift::ParamDecl* const >(decl.getImplicitSelfDecl ());
331
+ entry.self_param = dispatcher_.fetchOptionalLabel (self);
330
332
fillValueDecl (decl, entry);
331
333
fillGenericContext (decl, entry);
332
334
}
Original file line number Diff line number Diff line change @@ -5,6 +5,20 @@ class ParamDecl extends ParamDeclBase {
5
5
/** Gets the function which declares this parameter. */
6
6
Callable getDeclaringFunction ( ) { result .getAParam ( ) = this }
7
7
8
- /** Gets the index of this parameter in its declaring function's parameter list. */
8
+ /**
9
+ * Gets the index of this parameter in its declaring function's parameter list,
10
+ * or -1 if this is `self`.
11
+ */
9
12
int getIndex ( ) { exists ( Callable func | func .getParam ( result ) = this ) }
10
13
}
14
+
15
+ /** A `self` parameter. */
16
+ class SelfParamDecl extends ParamDecl {
17
+ Callable call ;
18
+
19
+ SelfParamDecl ( ) { call .getSelfParam ( ) = this }
20
+
21
+ override Callable getDeclaringFunction ( ) { result = call }
22
+
23
+ override int getIndex ( ) { result = - 1 }
24
+ }
You can’t perform that action at this time.
0 commit comments