Skip to content

Commit 6c96f71

Browse files
committed
Swift: Autogenerate and accept test changes.
1 parent 4595a9c commit 6c96f71

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

swift/ql/lib/codeql/swift/generated/GetImmediateParent.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Element getAnImmediateChild(Element e) {
1818
(
1919
none()
2020
or
21+
abstract_closure_expr_params(e, _, x)
22+
or
2123
abstract_function_decl_bodies(e, x)
2224
or
2325
abstract_function_decl_params(e, _, x)
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
// generated by codegen/codegen.py
22
import codeql.swift.elements.expr.Expr
3+
import codeql.swift.elements.decl.ParamDecl
34

4-
class AbstractClosureExprBase extends @abstract_closure_expr, Expr { }
5+
class AbstractClosureExprBase extends @abstract_closure_expr, Expr {
6+
ParamDecl getParam(int index) {
7+
exists(ParamDecl x |
8+
abstract_closure_expr_params(this, index, x) and
9+
result = x.resolve()
10+
)
11+
}
12+
13+
ParamDecl getAParam() { result = getParam(_) }
14+
15+
int getNumberOfParams() { result = count(getAParam()) }
16+
}

swift/ql/lib/swift.dbscheme

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,13 @@ value_decls(
659659
| @closure_expr
660660
;
661661

662+
#keyset[id, index]
663+
abstract_closure_expr_params(
664+
int id: @abstract_closure_expr ref,
665+
int index: int ref,
666+
int param: @param_decl ref
667+
);
668+
662669
@any_try_expr =
663670
@force_try_expr
664671
| @optional_try_expr

swift/ql/test/library-tests/parent/parent.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@
463463
| expressions.swift:41:1:43:1 | { ... } | TopLevelCodeDecl | expressions.swift:41:1:43:1 | { ... } | BraceStmt |
464464
| expressions.swift:41:10:43:1 | { ... } | BraceStmt | expressions.swift:42:5:42:16 | return ... | ReturnStmt |
465465
| expressions.swift:41:10:43:1 | { ... } | ClosureExpr | expressions.swift:41:10:43:1 | { ... } | BraceStmt |
466+
| expressions.swift:41:10:43:1 | { ... } | ClosureExpr | expressions.swift:41:13:41:16 | x | ParamDecl |
467+
| expressions.swift:41:10:43:1 | { ... } | ClosureExpr | expressions.swift:41:21:41:24 | y | ParamDecl |
466468
| expressions.swift:42:5:42:16 | return ... | ReturnStmt | expressions.swift:42:12:42:16 | ... call to + ... | BinaryExpr |
467469
| expressions.swift:42:12:42:16 | ... call to + ... | BinaryExpr | expressions.swift:42:14:42:14 | call to + | DotSyntaxCallExpr |
468470
| expressions.swift:42:14:42:14 | Int.Type | TypeExpr | expressions.swift:42:14:42:14 | FixedTypeRepr | FixedTypeRepr |
@@ -472,6 +474,8 @@
472474
| expressions.swift:44:1:46:1 | { ... } | TopLevelCodeDecl | expressions.swift:44:1:46:1 | { ... } | BraceStmt |
473475
| expressions.swift:44:10:46:1 | { ... } | BraceStmt | expressions.swift:45:5:45:16 | return ... | ReturnStmt |
474476
| expressions.swift:44:10:46:1 | { ... } | ClosureExpr | expressions.swift:44:10:46:1 | { ... } | BraceStmt |
477+
| expressions.swift:44:10:46:1 | { ... } | ClosureExpr | expressions.swift:44:12:44:12 | x | ParamDecl |
478+
| expressions.swift:44:10:46:1 | { ... } | ClosureExpr | expressions.swift:44:15:44:15 | y | ParamDecl |
475479
| expressions.swift:45:5:45:16 | return ... | ReturnStmt | expressions.swift:45:12:45:16 | ... call to + ... | BinaryExpr |
476480
| expressions.swift:45:12:45:16 | ... call to + ... | BinaryExpr | expressions.swift:45:14:45:14 | call to + | DotSyntaxCallExpr |
477481
| expressions.swift:45:14:45:14 | Int.Type | TypeExpr | expressions.swift:45:14:45:14 | FixedTypeRepr | FixedTypeRepr |
@@ -480,6 +484,8 @@
480484
| expressions.swift:47:1:47:27 | { ... } | BraceStmt | expressions.swift:47:1:47:27 | call to closured | CallExpr |
481485
| expressions.swift:47:1:47:27 | { ... } | TopLevelCodeDecl | expressions.swift:47:1:47:27 | { ... } | BraceStmt |
482486
| expressions.swift:47:10:47:27 | { ... } | BraceStmt | expressions.swift:47:12:47:24 | return ... | ReturnStmt |
487+
| expressions.swift:47:10:47:27 | { ... } | ClosureExpr | expressions.swift:47:10:47:10 | $0 | ParamDecl |
488+
| expressions.swift:47:10:47:27 | { ... } | ClosureExpr | expressions.swift:47:10:47:10 | $1 | ParamDecl |
483489
| expressions.swift:47:10:47:27 | { ... } | ClosureExpr | expressions.swift:47:10:47:27 | { ... } | BraceStmt |
484490
| expressions.swift:47:12:47:24 | return ... | ReturnStmt | expressions.swift:47:19:47:24 | ... call to + ... | BinaryExpr |
485491
| expressions.swift:47:19:47:24 | ... call to + ... | BinaryExpr | expressions.swift:47:22:47:22 | call to + | DotSyntaxCallExpr |
@@ -489,6 +495,8 @@
489495
| expressions.swift:48:1:48:20 | { ... } | BraceStmt | expressions.swift:48:1:48:20 | call to closured | CallExpr |
490496
| expressions.swift:48:1:48:20 | { ... } | TopLevelCodeDecl | expressions.swift:48:1:48:20 | { ... } | BraceStmt |
491497
| expressions.swift:48:10:48:20 | { ... } | BraceStmt | expressions.swift:48:12:48:17 | return ... | ReturnStmt |
498+
| expressions.swift:48:10:48:20 | { ... } | ClosureExpr | expressions.swift:48:10:48:10 | $0 | ParamDecl |
499+
| expressions.swift:48:10:48:20 | { ... } | ClosureExpr | expressions.swift:48:10:48:10 | $1 | ParamDecl |
492500
| expressions.swift:48:10:48:20 | { ... } | ClosureExpr | expressions.swift:48:10:48:20 | { ... } | BraceStmt |
493501
| expressions.swift:48:12:48:17 | ... call to + ... | BinaryExpr | expressions.swift:48:15:48:15 | call to + | DotSyntaxCallExpr |
494502
| expressions.swift:48:12:48:17 | return ... | ReturnStmt | expressions.swift:48:12:48:17 | ... call to + ... | BinaryExpr |
@@ -523,6 +531,7 @@
523531
| expressions.swift:60:23:60:23 | (Int) ... | LoadExpr | expressions.swift:60:23:60:23 | myNumber | DeclRefExpr |
524532
| expressions.swift:60:33:60:63 | ((UnsafePointer<Int>) throws -> ()) ... | FunctionConversionExpr | expressions.swift:60:33:60:63 | { ... } | ClosureExpr |
525533
| expressions.swift:60:33:60:63 | { ... } | BraceStmt | expressions.swift:60:35:60:61 | return ... | ReturnStmt |
534+
| expressions.swift:60:33:60:63 | { ... } | ClosureExpr | expressions.swift:60:33:60:33 | $0 | ParamDecl |
526535
| expressions.swift:60:33:60:63 | { ... } | ClosureExpr | expressions.swift:60:33:60:63 | { ... } | BraceStmt |
527536
| expressions.swift:60:35:60:61 | call to unsafeFunction | CallExpr | expressions.swift:60:35:60:35 | unsafeFunction | DeclRefExpr |
528537
| expressions.swift:60:35:60:61 | return ... | ReturnStmt | expressions.swift:60:35:60:61 | call to unsafeFunction | CallExpr |

0 commit comments

Comments
 (0)