Skip to content

Commit d937234

Browse files
committed
Swift: add stubs for new types
1 parent 13fe02e commit d937234

19 files changed

+196
-1
lines changed

swift/codegen/schema.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ ModuleType:
140140
_extends: Type
141141
module: ModuleDecl
142142

143+
PackType:
144+
_extends: Type
145+
146+
PackExpansionType:
147+
_extends: Type
148+
149+
ParameterizedProtocolType:
150+
_extends: Type
151+
143152
PlaceholderType:
144153
_extends: Type
145154

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ import codeql.swift.elements.type.NominalType
259259
import codeql.swift.elements.type.OpaqueTypeArchetypeType
260260
import codeql.swift.elements.type.OpenedArchetypeType
261261
import codeql.swift.elements.type.OptionalType
262+
import codeql.swift.elements.type.PackExpansionType
263+
import codeql.swift.elements.type.PackType
264+
import codeql.swift.elements.type.ParameterizedProtocolType
262265
import codeql.swift.elements.type.ParenType
263266
import codeql.swift.elements.type.PlaceholderType
264267
import codeql.swift.elements.type.PrimaryArchetypeType
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.type.PackExpansionType
3+
4+
class PackExpansionType extends PackExpansionTypeBase { }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.Raw
3+
4+
predicate constructPackExpansionType(Raw::PackExpansionType id) { any() }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.type.PackType
3+
4+
class PackType extends PackTypeBase { }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.Raw
3+
4+
predicate constructPackType(Raw::PackType id) { any() }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.type.ParameterizedProtocolType
3+
4+
class ParameterizedProtocolType extends ParameterizedProtocolTypeBase { }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.Raw
3+
4+
predicate constructParameterizedProtocolType(Raw::ParameterizedProtocolType id) { any() }

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,6 +3883,49 @@ private module Impl {
38833883
)
38843884
}
38853885

3886+
private Element getImmediateChildOfPackExpansionType(
3887+
PackExpansionType e, int index, string partialPredicateCall
3888+
) {
3889+
exists(int b, int bType, int n |
3890+
b = 0 and
3891+
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
3892+
n = bType and
3893+
(
3894+
none()
3895+
or
3896+
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
3897+
)
3898+
)
3899+
}
3900+
3901+
private Element getImmediateChildOfPackType(PackType e, int index, string partialPredicateCall) {
3902+
exists(int b, int bType, int n |
3903+
b = 0 and
3904+
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
3905+
n = bType and
3906+
(
3907+
none()
3908+
or
3909+
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
3910+
)
3911+
)
3912+
}
3913+
3914+
private Element getImmediateChildOfParameterizedProtocolType(
3915+
ParameterizedProtocolType e, int index, string partialPredicateCall
3916+
) {
3917+
exists(int b, int bType, int n |
3918+
b = 0 and
3919+
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
3920+
n = bType and
3921+
(
3922+
none()
3923+
or
3924+
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
3925+
)
3926+
)
3927+
}
3928+
38863929
private Element getImmediateChildOfPlaceholderType(
38873930
PlaceholderType e, int index, string partialPredicateCall
38883931
) {
@@ -5158,6 +5201,12 @@ private module Impl {
51585201
or
51595202
result = getImmediateChildOfModuleType(e, index, partialAccessor)
51605203
or
5204+
result = getImmediateChildOfPackExpansionType(e, index, partialAccessor)
5205+
or
5206+
result = getImmediateChildOfPackType(e, index, partialAccessor)
5207+
or
5208+
result = getImmediateChildOfParameterizedProtocolType(e, index, partialAccessor)
5209+
or
51615210
result = getImmediateChildOfPlaceholderType(e, index, partialAccessor)
51625211
or
51635212
result = getImmediateChildOfProtocolCompositionType(e, index, partialAccessor)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,18 @@ module Raw {
12581258
ModuleDecl getModule() { module_types(this, result) }
12591259
}
12601260

1261+
class PackExpansionType extends @pack_expansion_type, Type {
1262+
override string toString() { result = "PackExpansionType" }
1263+
}
1264+
1265+
class PackType extends @pack_type, Type {
1266+
override string toString() { result = "PackType" }
1267+
}
1268+
1269+
class ParameterizedProtocolType extends @parameterized_protocol_type, Type {
1270+
override string toString() { result = "ParameterizedProtocolType" }
1271+
}
1272+
12611273
class PlaceholderType extends @placeholder_type, Type {
12621274
override string toString() { result = "PlaceholderType" }
12631275
}

0 commit comments

Comments
 (0)