Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift: QLDoc and test for getCanonicalType #14618

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions swift/ql/.generated.list

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions swift/ql/lib/codeql/swift/generated/Raw.qll

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions swift/ql/lib/codeql/swift/generated/type/Type.qll

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
| 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 |
| nominaltype.swift:85:6:85:6 | j | Any? | getFullName:Any?, getName:Any?, getUnderlyingType:Any? |
| nominaltype.swift:86:6:86:6 | a | A | getFullName:A, getName:A, getUnderlyingType:A |
| nominaltype.swift:87:6:87:6 | a_alias | A_alias | getAliasedType:A, getFullName:A_alias, getName:A_alias, getUnderlyingType:A |
| nominaltype.swift:88:6:88:6 | a_optional_alias | A_optional_alias | getAliasedType:A?, getFullName:A_optional_alias, getName:A_optional_alias, getUnderlyingType:A? |
| nominaltype.swift:89:6:89:6 | b1 | B1 | getABaseType:A, getFullName:B1, getName:B1, getUnderlyingType:B1 |
| nominaltype.swift:90:6:90:6 | b2 | B2 | getABaseType:A, getFullName:B2, getName:B2, getUnderlyingType:B2 |
| nominaltype.swift:91:6:91:6 | b1_alias | B1_alias | getAliasedType:B1, getFullName:B1_alias, getName:B1_alias, getUnderlyingType:B1 |
| nominaltype.swift:92:6:92:6 | b2_alias | B2_alias | getAliasedType:B2, getFullName:B2_alias, getName:B2_alias, getUnderlyingType:B2 |
| nominaltype.swift:93:6:93:6 | p | P | getFullName:P, getName:P, getUnderlyingType:P |
| nominaltype.swift:94:6:94:6 | p_alias | P_alias | getFullName:P_alias, getName:P_alias, getUnderlyingType:P_alias |
| nominaltype.swift:95:6:95:6 | c1 | C1 | getABaseType:P, getFullName:C1, getName:C1, getUnderlyingType:C1 |
| nominaltype.swift:96:6:96:6 | c2 | C2 | getABaseType:P, getFullName:C2, getName:C2, getUnderlyingType:C2 |
| nominaltype.swift:97:6:97:6 | o | Outer | getFullName:Outer, getName:Outer, getUnderlyingType:Outer |
| nominaltype.swift:98:6:98:6 | oi | Outer.Inner | getFullName:Outer.Inner, getName:Inner, getUnderlyingType:Outer.Inner |
| nominaltype.swift:99:6:99:6 | oia | Outer.Inner.InnerAlias | getAliasedType:A, getFullName:Outer.Inner.InnerAlias, getName:InnerAlias, getUnderlyingType:A |
| nominaltype.swift:100:6:100:6 | p1p2 | P1P2 | getFullName:P1P2, getName:P1P2, getUnderlyingType:P1P2 |
| nominaltype.swift:101:6:101:6 | boxInt | Box<A> | getFullName:Box<A>, getName:Box<A>, getUnderlyingType:Box<A> |
| nominaltype.swift:102:6:102:6 | d1 | D1 | getABaseType:P3, getFullName:D1, getName:D1, getUnderlyingType:D1 |
| nominaltype.swift:103:6:103:6 | d2 | D2 | getABaseType:P4, getFullName:D2, getName:D2, getUnderlyingType:D2 |
| 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 |
| nominaltype.swift:85:6:85:6 | j | Any? | getCanonicalType:Optional<Any>, getFullName:Any?, getName:Any?, getUnderlyingType:Any? |
| nominaltype.swift:86:6:86:6 | a | A | getCanonicalType:A, getFullName:A, getName:A, getUnderlyingType:A |
| nominaltype.swift:87:6:87:6 | a_alias | A_alias | getAliasedType:A, getCanonicalType:A, getFullName:A_alias, getName:A_alias, getUnderlyingType:A |
| 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? |
| nominaltype.swift:89:6:89:6 | b1 | B1 | getABaseType:A, getCanonicalType:B1, getFullName:B1, getName:B1, getUnderlyingType:B1 |
| nominaltype.swift:90:6:90:6 | b2 | B2 | getABaseType:A, getCanonicalType:B2, getFullName:B2, getName:B2, getUnderlyingType:B2 |
| nominaltype.swift:91:6:91:6 | b1_alias | B1_alias | getAliasedType:B1, getCanonicalType:B1, getFullName:B1_alias, getName:B1_alias, getUnderlyingType:B1 |
| nominaltype.swift:92:6:92:6 | b2_alias | B2_alias | getAliasedType:B2, getCanonicalType:B2, getFullName:B2_alias, getName:B2_alias, getUnderlyingType:B2 |
| nominaltype.swift:93:6:93:6 | p | P | getCanonicalType:P, getFullName:P, getName:P, getUnderlyingType:P |
| nominaltype.swift:94:6:94:6 | p_alias | P_alias | getCanonicalType:P, getFullName:P_alias, getName:P_alias, getUnderlyingType:P_alias |
| nominaltype.swift:95:6:95:6 | c1 | C1 | getABaseType:P, getCanonicalType:C1, getFullName:C1, getName:C1, getUnderlyingType:C1 |
| nominaltype.swift:96:6:96:6 | c2 | C2 | getABaseType:P, getCanonicalType:C2, getFullName:C2, getName:C2, getUnderlyingType:C2 |
| nominaltype.swift:97:6:97:6 | o | Outer | getCanonicalType:Outer, getFullName:Outer, getName:Outer, getUnderlyingType:Outer |
| nominaltype.swift:98:6:98:6 | oi | Outer.Inner | getCanonicalType:Outer.Inner, getFullName:Outer.Inner, getName:Inner, getUnderlyingType:Outer.Inner |
| nominaltype.swift:99:6:99:6 | oia | Outer.Inner.InnerAlias | getAliasedType:A, getCanonicalType:A, getFullName:Outer.Inner.InnerAlias, getName:InnerAlias, getUnderlyingType:A |
| nominaltype.swift:100:6:100:6 | p1p2 | P1P2 | getCanonicalType:P1 & P2, getFullName:P1P2, getName:P1P2, getUnderlyingType:P1P2 |
| nominaltype.swift:101:6:101:6 | boxInt | Box<A> | getCanonicalType:Box<A>, getFullName:Box<A>, getName:Box<A>, getUnderlyingType:Box<A> |
| nominaltype.swift:102:6:102:6 | d1 | D1 | getABaseType:P3, getCanonicalType:D1, getFullName:D1, getName:D1, getUnderlyingType:D1 |
| nominaltype.swift:103:6:103:6 | d2 | D2 | getABaseType:P4, getCanonicalType:D2, getFullName:D2, getName:D2, getUnderlyingType:D2 |
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ string describe(Type t) {
result = "getAliasedType:" + t.(TypeAliasType).getAliasedType().toString()
or
result = "getABaseType:" + t.getABaseType().toString()
or
result = "getCanonicalType:" + t.getCanonicalType().toString()
}

from VarDecl v, Type t
Expand Down
8 changes: 7 additions & 1 deletion swift/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ class AstNode(Locatable):
@ql.hideable
class Type(Element):
name: string
canonical_type: "Type"
canonical_type: "Type" | desc("""
This is the unique type we get after resolving aliases and desugaring. For example, given
```
typealias MyInt = Int
```
then `[MyInt?]` has the canonical type `Array<Optional<Int>>`.
""")

@group("decl")
class Decl(AstNode):
Expand Down