Skip to content

Commit 33a97fe

Browse files
committed
Swift: Update KeyPathComponent for new kind values
1 parent f1abf5e commit 33a97fe

File tree

7 files changed

+61
-52
lines changed

7 files changed

+61
-52
lines changed

swift/ql/.generated.list

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/internal/KeyPathComponentImpl.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,37 @@ module Impl {
1010
/**
1111
* Property access like `.bar` in `\Foo.bar`.
1212
*/
13-
predicate isProperty() { this.getKind() = 3 }
13+
predicate isProperty() { this.getKind() = 5 }
1414

1515
/**
1616
* Array or dictionary subscript like `[1]` or `["a", "b"]`.
1717
*/
18-
predicate isSubscript() { this.getKind() = 4 }
18+
predicate isSubscript() { this.getKind() = 6 }
1919

2020
/**
2121
* Optional forcing `!`.
2222
*/
23-
predicate isOptionalForcing() { this.getKind() = 5 }
23+
predicate isOptionalForcing() { this.getKind() = 7 }
2424

2525
/**
2626
* Optional chaining `?`.
2727
*/
28-
predicate isOptionalChaining() { this.getKind() = 6 }
28+
predicate isOptionalChaining() { this.getKind() = 8 }
2929

3030
/**
3131
* Implicit optional wrapping component inserted by the compiler when an optional chain ends in a non-optional value.
3232
*/
33-
predicate isOptionalWrapping() { this.getKind() = 7 }
33+
predicate isOptionalWrapping() { this.getKind() = 9 }
3434

3535
/**
3636
* Reference to the entire object; the `self` in `\Foo.self`.
3737
*/
38-
predicate isSelf() { this.getKind() = 8 }
38+
predicate isSelf() { this.getKind() = 10 }
3939

4040
/**
4141
* Tuple indexing like `.1`.
4242
*/
43-
predicate isTupleIndexing() { this.getKind() = 9 }
43+
predicate isTupleIndexing() { this.getKind() = 11 }
4444

4545
/** Gets the underlying key-path expression which this is a component of. */
4646
KeyPathExpr getKeyPathExpr() { result.getAComponent() = this }

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

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/test/extractor-tests/generated/KeyPathComponent/KeyPathComponent.expected

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
instances
2-
| file://:0:0:0:0 | KeyPathComponent | getKind: | 7 | getComponentType: | Int? |
3-
| key_path_expr.swift:11:17:11:17 | KeyPathComponent | getKind: | 3 | getComponentType: | Int |
4-
| key_path_expr.swift:12:24:12:26 | KeyPathComponent | getKind: | 4 | getComponentType: | Int |
5-
| key_path_expr.swift:13:34:13:38 | KeyPathComponent | getKind: | 4 | getComponentType: | Int? |
6-
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 5 | getComponentType: | Int |
7-
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 8 | getComponentType: | Int? |
8-
| key_path_expr.swift:15:21:15:21 | KeyPathComponent | getKind: | 3 | getComponentType: | Bar? |
9-
| key_path_expr.swift:15:24:15:24 | KeyPathComponent | getKind: | 6 | getComponentType: | Bar |
10-
| key_path_expr.swift:15:26:15:26 | KeyPathComponent | getKind: | 3 | getComponentType: | Int? |
11-
| key_path_expr.swift:16:25:16:25 | KeyPathComponent | getKind: | 3 | getComponentType: | Bar? |
12-
| key_path_expr.swift:16:28:16:28 | KeyPathComponent | getKind: | 6 | getComponentType: | Bar |
13-
| key_path_expr.swift:16:30:16:30 | KeyPathComponent | getKind: | 3 | getComponentType: | Int |
14-
| key_path_expr.swift:17:16:17:16 | KeyPathComponent | getKind: | 8 | getComponentType: | Int |
15-
| key_path_expr.swift:18:32:18:32 | KeyPathComponent | getKind: | 9 | getComponentType: | Int |
2+
| file://:0:0:0:0 | KeyPathComponent | getKind: | 9 | getComponentType: | Int? |
3+
| key_path_expr.swift:11:17:11:17 | KeyPathComponent | getKind: | 5 | getComponentType: | Int |
4+
| key_path_expr.swift:12:24:12:26 | KeyPathComponent | getKind: | 6 | getComponentType: | Int |
5+
| key_path_expr.swift:13:34:13:38 | KeyPathComponent | getKind: | 6 | getComponentType: | Int? |
6+
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 7 | getComponentType: | Int |
7+
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 10 | getComponentType: | Int? |
8+
| key_path_expr.swift:15:21:15:21 | KeyPathComponent | getKind: | 5 | getComponentType: | Bar? |
9+
| key_path_expr.swift:15:24:15:24 | KeyPathComponent | getKind: | 8 | getComponentType: | Bar |
10+
| key_path_expr.swift:15:26:15:26 | KeyPathComponent | getKind: | 5 | getComponentType: | Int? |
11+
| key_path_expr.swift:16:25:16:25 | KeyPathComponent | getKind: | 5 | getComponentType: | Bar? |
12+
| key_path_expr.swift:16:28:16:28 | KeyPathComponent | getKind: | 8 | getComponentType: | Bar |
13+
| key_path_expr.swift:16:30:16:30 | KeyPathComponent | getKind: | 5 | getComponentType: | Int |
14+
| key_path_expr.swift:17:16:17:16 | KeyPathComponent | getKind: | 10 | getComponentType: | Int |
15+
| key_path_expr.swift:18:32:18:32 | KeyPathComponent | getKind: | 11 | getComponentType: | Int |
1616
getSubscriptArgument
1717
| key_path_expr.swift:12:24:12:26 | KeyPathComponent | 0 | key_path_expr.swift:12:25:12:25 | : 0 |
1818
| key_path_expr.swift:13:34:13:38 | KeyPathComponent | 0 | key_path_expr.swift:13:35:13:35 | : a |
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
| file://:0:0:0:0 | KeyPathComponent | getKind: | 7 | | | | | optional wrapping | | |
2-
| key_path_expr.swift:11:17:11:17 | KeyPathComponent | getKind: | 3 | property | | | | | | |
3-
| key_path_expr.swift:12:24:12:26 | KeyPathComponent | getKind: | 4 | | subscript | | | | | |
4-
| key_path_expr.swift:13:34:13:38 | KeyPathComponent | getKind: | 4 | | subscript | | | | | |
5-
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 5 | | | optional forcing | | | | |
6-
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 8 | | | | | | self | |
7-
| key_path_expr.swift:15:21:15:21 | KeyPathComponent | getKind: | 3 | property | | | | | | |
8-
| key_path_expr.swift:15:24:15:24 | KeyPathComponent | getKind: | 6 | | | | optional chaining | | | |
9-
| key_path_expr.swift:15:26:15:26 | KeyPathComponent | getKind: | 3 | property | | | | | | |
10-
| key_path_expr.swift:16:25:16:25 | KeyPathComponent | getKind: | 3 | property | | | | | | |
11-
| key_path_expr.swift:16:28:16:28 | KeyPathComponent | getKind: | 6 | | | | optional chaining | | | |
12-
| key_path_expr.swift:16:30:16:30 | KeyPathComponent | getKind: | 3 | property | | | | | | |
13-
| key_path_expr.swift:17:16:17:16 | KeyPathComponent | getKind: | 8 | | | | | | self | |
14-
| key_path_expr.swift:18:32:18:32 | KeyPathComponent | getKind: | 9 | | | | | | | tuple indexing |
1+
| file://:0:0:0:0 | KeyPathComponent | getKind: | 9 | | | | | optional wrapping | | |
2+
| key_path_expr.swift:11:17:11:17 | KeyPathComponent | getKind: | 5 | property | | | | | | |
3+
| key_path_expr.swift:12:24:12:26 | KeyPathComponent | getKind: | 6 | | subscript | | | | | |
4+
| key_path_expr.swift:13:34:13:38 | KeyPathComponent | getKind: | 6 | | subscript | | | | | |
5+
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 7 | | | optional forcing | | | | |
6+
| key_path_expr.swift:14:31:14:31 | KeyPathComponent | getKind: | 10 | | | | | | self | |
7+
| key_path_expr.swift:15:21:15:21 | KeyPathComponent | getKind: | 5 | property | | | | | | |
8+
| key_path_expr.swift:15:24:15:24 | KeyPathComponent | getKind: | 8 | | | | optional chaining | | | |
9+
| key_path_expr.swift:15:26:15:26 | KeyPathComponent | getKind: | 5 | property | | | | | | |
10+
| key_path_expr.swift:16:25:16:25 | KeyPathComponent | getKind: | 5 | property | | | | | | |
11+
| key_path_expr.swift:16:28:16:28 | KeyPathComponent | getKind: | 8 | | | | optional chaining | | | |
12+
| key_path_expr.swift:16:30:16:30 | KeyPathComponent | getKind: | 5 | property | | | | | | |
13+
| key_path_expr.swift:17:16:17:16 | KeyPathComponent | getKind: | 10 | | | | | | self | |
14+
| key_path_expr.swift:18:32:18:32 | KeyPathComponent | getKind: | 11 | | | | | | | tuple indexing |

swift/schema.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,15 @@ class KeyPathComponent(AstNode):
486486
kind: int | doc("kind of key path component") | desc("""
487487
INTERNAL: Do not use.
488488
489-
This is 3 for properties, 4 for array and dictionary subscripts, 5 for optional forcing
490-
(`!`), 6 for optional chaining (`?`), 7 for implicit optional wrapping, 8 for `self`,
491-
and 9 for tuple element indexing.
489+
TODO: Swift 6.2 update with UnresolvedApply and Apply
490+
TODO: Swift 6.2 make sure to adjust in dbscheme upgrade/downgrade
492491
493-
The following values should not appear: 0 for invalid components, 1 for unresolved
494-
properties, 2 for unresolved subscripts, 10 for #keyPath dictionary keys, and 11 for
492+
This is 5 for properties, 6 for array and dictionary subscripts, 7 for optional forcing
493+
(`!`), 8 for optional chaining (`?`), 9 for implicit optional wrapping, 10 for `self`,
494+
and 11 for tuple element indexing.
495+
496+
The following values should not appear: 0 for invalid components, 2 for unresolved
497+
properties, 3 for unresolved subscripts, 12 for #keyPath dictionary keys, and 13 for
495498
implicit IDE code completion data.
496499
""")
497500
subscript_arguments : list[Argument] | child | doc(

0 commit comments

Comments
 (0)