Skip to content

Commit 6b90b2b

Browse files
committed
Swift: add children to IsPattern
1 parent a4f97dd commit 6b90b2b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

swift/codegen/schema.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,9 @@ ExprPattern:
559559

560560
IsPattern:
561561
_extends: Pattern
562-
cast_type_repr: TypeRepr?
563-
sub_pattern: Pattern?
562+
_children:
563+
cast_type_repr: TypeRepr?
564+
sub_pattern: Pattern?
564565

565566
NamedPattern:
566567
_extends: Pattern

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ private class ElementWithChildAccessor extends Element {
132132
or
133133
exists(TapExpr x | interpolated_string_literal_expr_appending_exprs(this, x) and result = x)
134134
or
135+
exists(TypeRepr x | is_pattern_cast_type_reprs(this, x) and result = x)
136+
or
137+
exists(Pattern x | is_pattern_sub_patterns(this, x) and result = x)
138+
or
135139
exists(Expr x | key_path_application_exprs(this, x, _) and result = x)
136140
or
137141
exists(Expr x | key_path_application_exprs(this, _, x) and result = x)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,14 @@
940940
| patterns.swift:41:5:41:18 | case ... | CaseStmt | patterns.swift:41:10:41:13 | ... is ... | CaseLabelItem |
941941
| patterns.swift:41:5:41:18 | case ... | CaseStmt | patterns.swift:41:18:41:18 | { ... } | BraceStmt |
942942
| patterns.swift:41:10:41:13 | ... is ... | CaseLabelItem | patterns.swift:41:10:41:13 | ... is ... | IsPattern |
943+
| patterns.swift:41:10:41:13 | ... is ... | IsPattern | patterns.swift:41:13:41:13 | TBD (SimpleIdentTypeRepr) | SimpleIdentTypeRepr |
943944
| patterns.swift:41:18:41:18 | { ... } | BraceStmt | patterns.swift:41:18:41:18 | is pattern | StringLiteralExpr |
944945
| patterns.swift:42:5:42:27 | case ... | CaseStmt | patterns.swift:42:10:42:19 | let ... | CaseLabelItem |
945946
| patterns.swift:42:5:42:27 | case ... | CaseStmt | patterns.swift:42:27:42:27 | { ... } | BraceStmt |
946947
| patterns.swift:42:10:42:19 | let ... | BindingPattern | patterns.swift:42:14:42:19 | ... is ... | IsPattern |
947948
| patterns.swift:42:10:42:19 | let ... | CaseLabelItem | patterns.swift:42:10:42:19 | let ... | BindingPattern |
949+
| patterns.swift:42:14:42:19 | ... is ... | IsPattern | patterns.swift:42:14:42:14 | x | NamedPattern |
950+
| patterns.swift:42:14:42:19 | ... is ... | IsPattern | patterns.swift:42:19:42:19 | TBD (SimpleIdentTypeRepr) | SimpleIdentTypeRepr |
948951
| patterns.swift:42:27:42:27 | { ... } | BraceStmt | patterns.swift:42:27:42:27 | as pattern | StringLiteralExpr |
949952
| patterns.swift:43:5:43:13 | case ... | CaseStmt | patterns.swift:43:10:43:10 | _ | CaseLabelItem |
950953
| patterns.swift:43:5:43:13 | case ... | CaseStmt | patterns.swift:43:13:43:13 | { ... } | BraceStmt |
@@ -1044,6 +1047,7 @@
10441047
| statements.swift:27:5:29:3 | case ... | CaseStmt | statements.swift:27:11:27:11 | ... is ... | CaseLabelItem |
10451048
| statements.swift:27:5:29:3 | case ... | CaseStmt | statements.swift:27:26:29:3 | { ... } | BraceStmt |
10461049
| statements.swift:27:11:27:11 | ... is ... | CaseLabelItem | statements.swift:27:11:27:11 | ... is ... | IsPattern |
1050+
| statements.swift:27:11:27:11 | ... is ... | IsPattern | statements.swift:27:11:27:19 | .failed | EnumElementPattern |
10471051
| statements.swift:27:26:29:3 | { ... } | BraceStmt | statements.swift:28:5:28:27 | call to print | CallExpr |
10481052
| statements.swift:28:5:28:27 | call to print | CallExpr | statements.swift:28:5:28:5 | print | DeclRefExpr |
10491053
| statements.swift:28:11:28:11 | (Any) ... | ErasureExpr | statements.swift:28:11:28:11 | AnError.failed | StringLiteralExpr |

0 commit comments

Comments
 (0)