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:
8181Callable :
8282 _children :
8383 params : ParamDecl*
84+ self_param : ParamDecl?
8485 body : BraceStmt?
8586
8687ConditionElement :
Original file line number Diff line number Diff line change @@ -327,6 +327,8 @@ void DeclVisitor::fillAbstractFunctionDecl(const swift::AbstractFunctionDecl& de
327327 entry.name = !decl.hasName () ? " (unnamed function decl)" : constructName (decl.getName ());
328328 entry.body = dispatcher_.fetchOptionalLabel (decl.getBody ());
329329 entry.params = dispatcher_.fetchRepeatedLabels (*decl.getParameters ());
330+ auto self = const_cast <swift::ParamDecl* const >(decl.getImplicitSelfDecl ());
331+ entry.self_param = dispatcher_.fetchOptionalLabel (self);
330332 fillValueDecl (decl, entry);
331333 fillGenericContext (decl, entry);
332334}
Original file line number Diff line number Diff line change @@ -5,6 +5,20 @@ class ParamDecl extends ParamDeclBase {
55 /** Gets the function which declares this parameter. */
66 Callable getDeclaringFunction ( ) { result .getAParam ( ) = this }
77
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+ */
912 int getIndex ( ) { exists ( Callable func | func .getParam ( result ) = this ) }
1013}
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