Skip to content

Commit 4e08ba6

Browse files
authored
Merge pull request github#14618 from geoffw0/qldoc
Swift: QLDoc and test for getCanonicalType
2 parents b9c8975 + 8937e0b commit 4e08ba6

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
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/generated/Raw.qll

Lines changed: 6 additions & 0 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/type/Type.qll

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
| nominaltype.swift:84:6:84:6 | i | Int | getABaseType:CVarArg, getABaseType:CodingKeyRepresentable, getABaseType:CustomReflectable, getABaseType:Decodable, getABaseType:Encodable, getABaseType:Equatable, getABaseType:FixedWidthInteger, getABaseType:Hashable, getABaseType:MirrorPath, getABaseType:SIMDScalar, getABaseType:Sendable, getABaseType:SignedInteger, getABaseType:_CustomPlaygroundQuickLookable, getABaseType:_ExpressibleByBuiltinIntegerLiteral, getABaseType:_HasCustomAnyHashableRepresentation, getFullName:Int, getName:Int, getUnderlyingType:Int |
2-
| nominaltype.swift:85:6:85:6 | j | Any? | getFullName:Any?, getName:Any?, getUnderlyingType:Any? |
3-
| nominaltype.swift:86:6:86:6 | a | A | getFullName:A, getName:A, getUnderlyingType:A |
4-
| nominaltype.swift:87:6:87:6 | a_alias | A_alias | getAliasedType:A, getFullName:A_alias, getName:A_alias, getUnderlyingType:A |
5-
| nominaltype.swift:88:6:88:6 | a_optional_alias | A_optional_alias | getAliasedType:A?, getFullName:A_optional_alias, getName:A_optional_alias, getUnderlyingType:A? |
6-
| nominaltype.swift:89:6:89:6 | b1 | B1 | getABaseType:A, getFullName:B1, getName:B1, getUnderlyingType:B1 |
7-
| nominaltype.swift:90:6:90:6 | b2 | B2 | getABaseType:A, getFullName:B2, getName:B2, getUnderlyingType:B2 |
8-
| nominaltype.swift:91:6:91:6 | b1_alias | B1_alias | getAliasedType:B1, getFullName:B1_alias, getName:B1_alias, getUnderlyingType:B1 |
9-
| nominaltype.swift:92:6:92:6 | b2_alias | B2_alias | getAliasedType:B2, getFullName:B2_alias, getName:B2_alias, getUnderlyingType:B2 |
10-
| nominaltype.swift:93:6:93:6 | p | P | getFullName:P, getName:P, getUnderlyingType:P |
11-
| nominaltype.swift:94:6:94:6 | p_alias | P_alias | getFullName:P_alias, getName:P_alias, getUnderlyingType:P_alias |
12-
| nominaltype.swift:95:6:95:6 | c1 | C1 | getABaseType:P, getFullName:C1, getName:C1, getUnderlyingType:C1 |
13-
| nominaltype.swift:96:6:96:6 | c2 | C2 | getABaseType:P, getFullName:C2, getName:C2, getUnderlyingType:C2 |
14-
| nominaltype.swift:97:6:97:6 | o | Outer | getFullName:Outer, getName:Outer, getUnderlyingType:Outer |
15-
| nominaltype.swift:98:6:98:6 | oi | Outer.Inner | getFullName:Outer.Inner, getName:Inner, getUnderlyingType:Outer.Inner |
16-
| nominaltype.swift:99:6:99:6 | oia | Outer.Inner.InnerAlias | getAliasedType:A, getFullName:Outer.Inner.InnerAlias, getName:InnerAlias, getUnderlyingType:A |
17-
| nominaltype.swift:100:6:100:6 | p1p2 | P1P2 | getFullName:P1P2, getName:P1P2, getUnderlyingType:P1P2 |
18-
| nominaltype.swift:101:6:101:6 | boxInt | Box<A> | getFullName:Box<A>, getName:Box<A>, getUnderlyingType:Box<A> |
19-
| nominaltype.swift:102:6:102:6 | d1 | D1 | getABaseType:P3, getFullName:D1, getName:D1, getUnderlyingType:D1 |
20-
| nominaltype.swift:103:6:103:6 | d2 | D2 | getABaseType:P4, getFullName:D2, getName:D2, getUnderlyingType:D2 |
1+
| nominaltype.swift:84:6:84:6 | i | Int | getABaseType:CVarArg, getABaseType:CodingKeyRepresentable, getABaseType:CustomReflectable, getABaseType:Decodable, getABaseType:Encodable, getABaseType:Equatable, getABaseType:FixedWidthInteger, getABaseType:Hashable, getABaseType:MirrorPath, getABaseType:SIMDScalar, getABaseType:Sendable, getABaseType:SignedInteger, getABaseType:_CustomPlaygroundQuickLookable, getABaseType:_ExpressibleByBuiltinIntegerLiteral, getABaseType:_HasCustomAnyHashableRepresentation, getCanonicalType:Int, getFullName:Int, getName:Int, getUnderlyingType:Int |
2+
| nominaltype.swift:85:6:85:6 | j | Any? | getCanonicalType:Optional<Any>, getFullName:Any?, getName:Any?, getUnderlyingType:Any? |
3+
| nominaltype.swift:86:6:86:6 | a | A | getCanonicalType:A, getFullName:A, getName:A, getUnderlyingType:A |
4+
| nominaltype.swift:87:6:87:6 | a_alias | A_alias | getAliasedType:A, getCanonicalType:A, getFullName:A_alias, getName:A_alias, getUnderlyingType:A |
5+
| nominaltype.swift:88:6:88:6 | a_optional_alias | A_optional_alias | getAliasedType:A?, getCanonicalType:Optional<A>, getFullName:A_optional_alias, getName:A_optional_alias, getUnderlyingType:A? |
6+
| nominaltype.swift:89:6:89:6 | b1 | B1 | getABaseType:A, getCanonicalType:B1, getFullName:B1, getName:B1, getUnderlyingType:B1 |
7+
| nominaltype.swift:90:6:90:6 | b2 | B2 | getABaseType:A, getCanonicalType:B2, getFullName:B2, getName:B2, getUnderlyingType:B2 |
8+
| nominaltype.swift:91:6:91:6 | b1_alias | B1_alias | getAliasedType:B1, getCanonicalType:B1, getFullName:B1_alias, getName:B1_alias, getUnderlyingType:B1 |
9+
| nominaltype.swift:92:6:92:6 | b2_alias | B2_alias | getAliasedType:B2, getCanonicalType:B2, getFullName:B2_alias, getName:B2_alias, getUnderlyingType:B2 |
10+
| nominaltype.swift:93:6:93:6 | p | P | getCanonicalType:P, getFullName:P, getName:P, getUnderlyingType:P |
11+
| nominaltype.swift:94:6:94:6 | p_alias | P_alias | getCanonicalType:P, getFullName:P_alias, getName:P_alias, getUnderlyingType:P_alias |
12+
| nominaltype.swift:95:6:95:6 | c1 | C1 | getABaseType:P, getCanonicalType:C1, getFullName:C1, getName:C1, getUnderlyingType:C1 |
13+
| nominaltype.swift:96:6:96:6 | c2 | C2 | getABaseType:P, getCanonicalType:C2, getFullName:C2, getName:C2, getUnderlyingType:C2 |
14+
| nominaltype.swift:97:6:97:6 | o | Outer | getCanonicalType:Outer, getFullName:Outer, getName:Outer, getUnderlyingType:Outer |
15+
| nominaltype.swift:98:6:98:6 | oi | Outer.Inner | getCanonicalType:Outer.Inner, getFullName:Outer.Inner, getName:Inner, getUnderlyingType:Outer.Inner |
16+
| nominaltype.swift:99:6:99:6 | oia | Outer.Inner.InnerAlias | getAliasedType:A, getCanonicalType:A, getFullName:Outer.Inner.InnerAlias, getName:InnerAlias, getUnderlyingType:A |
17+
| nominaltype.swift:100:6:100:6 | p1p2 | P1P2 | getCanonicalType:P1 & P2, getFullName:P1P2, getName:P1P2, getUnderlyingType:P1P2 |
18+
| nominaltype.swift:101:6:101:6 | boxInt | Box<A> | getCanonicalType:Box<A>, getFullName:Box<A>, getName:Box<A>, getUnderlyingType:Box<A> |
19+
| nominaltype.swift:102:6:102:6 | d1 | D1 | getABaseType:P3, getCanonicalType:D1, getFullName:D1, getName:D1, getUnderlyingType:D1 |
20+
| nominaltype.swift:103:6:103:6 | d2 | D2 | getABaseType:P4, getCanonicalType:D2, getFullName:D2, getName:D2, getUnderlyingType:D2 |

swift/ql/test/library-tests/elements/type/nominaltype/nominaltype.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ string describe(Type t) {
1010
result = "getAliasedType:" + t.(TypeAliasType).getAliasedType().toString()
1111
or
1212
result = "getABaseType:" + t.getABaseType().toString()
13+
or
14+
result = "getCanonicalType:" + t.getCanonicalType().toString()
1315
}
1416

1517
from VarDecl v, Type t

swift/schema.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ class AstNode(Locatable):
7777
@ql.hideable
7878
class Type(Element):
7979
name: string
80-
canonical_type: "Type"
80+
canonical_type: "Type" | desc("""
81+
This is the unique type we get after resolving aliases and desugaring. For example, given
82+
```
83+
typealias MyInt = Int
84+
```
85+
then `[MyInt?]` has the canonical type `Array<Optional<Int>>`.
86+
""")
8187

8288
@group("decl")
8389
class Decl(AstNode):

0 commit comments

Comments
 (0)