Swift: add stubs for new types

This commit is contained in:
Alex Denisov
2022-09-21 18:39:12 +02:00
parent 13fe02edfa
commit d937234f83
19 changed files with 196 additions and 1 deletions

View File

@@ -140,6 +140,15 @@ ModuleType:
_extends: Type
module: ModuleDecl
PackType:
_extends: Type
PackExpansionType:
_extends: Type
ParameterizedProtocolType:
_extends: Type
PlaceholderType:
_extends: Type

View File

@@ -259,6 +259,9 @@ import codeql.swift.elements.type.NominalType
import codeql.swift.elements.type.OpaqueTypeArchetypeType
import codeql.swift.elements.type.OpenedArchetypeType
import codeql.swift.elements.type.OptionalType
import codeql.swift.elements.type.PackExpansionType
import codeql.swift.elements.type.PackType
import codeql.swift.elements.type.ParameterizedProtocolType
import codeql.swift.elements.type.ParenType
import codeql.swift.elements.type.PlaceholderType
import codeql.swift.elements.type.PrimaryArchetypeType

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.type.PackExpansionType
class PackExpansionType extends PackExpansionTypeBase { }

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.Raw
predicate constructPackExpansionType(Raw::PackExpansionType id) { any() }

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.type.PackType
class PackType extends PackTypeBase { }

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.Raw
predicate constructPackType(Raw::PackType id) { any() }

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.type.ParameterizedProtocolType
class ParameterizedProtocolType extends ParameterizedProtocolTypeBase { }

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.Raw
predicate constructParameterizedProtocolType(Raw::ParameterizedProtocolType id) { any() }

View File

@@ -3883,6 +3883,49 @@ private module Impl {
)
}
private Element getImmediateChildOfPackExpansionType(
PackExpansionType e, int index, string partialPredicateCall
) {
exists(int b, int bType, int n |
b = 0 and
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
n = bType and
(
none()
or
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfPackType(PackType e, int index, string partialPredicateCall) {
exists(int b, int bType, int n |
b = 0 and
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
n = bType and
(
none()
or
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfParameterizedProtocolType(
ParameterizedProtocolType e, int index, string partialPredicateCall
) {
exists(int b, int bType, int n |
b = 0 and
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
n = bType and
(
none()
or
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfPlaceholderType(
PlaceholderType e, int index, string partialPredicateCall
) {
@@ -5158,6 +5201,12 @@ private module Impl {
or
result = getImmediateChildOfModuleType(e, index, partialAccessor)
or
result = getImmediateChildOfPackExpansionType(e, index, partialAccessor)
or
result = getImmediateChildOfPackType(e, index, partialAccessor)
or
result = getImmediateChildOfParameterizedProtocolType(e, index, partialAccessor)
or
result = getImmediateChildOfPlaceholderType(e, index, partialAccessor)
or
result = getImmediateChildOfProtocolCompositionType(e, index, partialAccessor)

View File

@@ -1258,6 +1258,18 @@ module Raw {
ModuleDecl getModule() { module_types(this, result) }
}
class PackExpansionType extends @pack_expansion_type, Type {
override string toString() { result = "PackExpansionType" }
}
class PackType extends @pack_type, Type {
override string toString() { result = "PackType" }
}
class ParameterizedProtocolType extends @parameterized_protocol_type, Type {
override string toString() { result = "ParameterizedProtocolType" }
}
class PlaceholderType extends @placeholder_type, Type {
override string toString() { result = "PlaceholderType" }
}

View File

@@ -282,6 +282,11 @@ module Synth {
} or
TOpenedArchetypeType(Raw::OpenedArchetypeType id) { constructOpenedArchetypeType(id) } or
TOptionalType(Raw::OptionalType id) { constructOptionalType(id) } or
TPackExpansionType(Raw::PackExpansionType id) { constructPackExpansionType(id) } or
TPackType(Raw::PackType id) { constructPackType(id) } or
TParameterizedProtocolType(Raw::ParameterizedProtocolType id) {
constructParameterizedProtocolType(id)
} or
TParenType(Raw::ParenType id) { constructParenType(id) } or
TPlaceholderType(Raw::PlaceholderType id) { constructPlaceholderType(id) } or
TPrimaryArchetypeType(Raw::PrimaryArchetypeType id) { constructPrimaryArchetypeType(id) } or
@@ -467,7 +472,8 @@ module Synth {
class TType =
TAnyFunctionType or TAnyGenericType or TAnyMetatypeType or TBuiltinType or
TDependentMemberType or TDynamicSelfType or TErrorType or TExistentialType or TInOutType or
TLValueType or TModuleType or TPlaceholderType or TProtocolCompositionType or
TLValueType or TModuleType or TPackExpansionType or TPackType or
TParameterizedProtocolType or TPlaceholderType or TProtocolCompositionType or
TReferenceStorageType or TSilBlockStorageType or TSilBoxType or TSilFunctionType or
TSilTokenType or TSubstitutableType or TSugarType or TTupleType or TTypeVariableType or
TUnresolvedType;
@@ -1297,6 +1303,19 @@ module Synth {
cached
TOptionalType convertOptionalTypeFromRaw(Raw::Element e) { result = TOptionalType(e) }
cached
TPackExpansionType convertPackExpansionTypeFromRaw(Raw::Element e) {
result = TPackExpansionType(e)
}
cached
TPackType convertPackTypeFromRaw(Raw::Element e) { result = TPackType(e) }
cached
TParameterizedProtocolType convertParameterizedProtocolTypeFromRaw(Raw::Element e) {
result = TParameterizedProtocolType(e)
}
cached
TParenType convertParenTypeFromRaw(Raw::Element e) { result = TParenType(e) }
@@ -2111,6 +2130,12 @@ module Synth {
or
result = convertModuleTypeFromRaw(e)
or
result = convertPackExpansionTypeFromRaw(e)
or
result = convertPackTypeFromRaw(e)
or
result = convertParameterizedProtocolTypeFromRaw(e)
or
result = convertPlaceholderTypeFromRaw(e)
or
result = convertProtocolCompositionTypeFromRaw(e)
@@ -2966,6 +2991,19 @@ module Synth {
cached
Raw::Element convertOptionalTypeToRaw(TOptionalType e) { e = TOptionalType(result) }
cached
Raw::Element convertPackExpansionTypeToRaw(TPackExpansionType e) {
e = TPackExpansionType(result)
}
cached
Raw::Element convertPackTypeToRaw(TPackType e) { e = TPackType(result) }
cached
Raw::Element convertParameterizedProtocolTypeToRaw(TParameterizedProtocolType e) {
e = TParameterizedProtocolType(result)
}
cached
Raw::Element convertParenTypeToRaw(TParenType e) { e = TParenType(result) }
@@ -3780,6 +3818,12 @@ module Synth {
or
result = convertModuleTypeToRaw(e)
or
result = convertPackExpansionTypeToRaw(e)
or
result = convertPackTypeToRaw(e)
or
result = convertParameterizedProtocolTypeToRaw(e)
or
result = convertPlaceholderTypeToRaw(e)
or
result = convertProtocolCompositionTypeToRaw(e)

View File

@@ -208,6 +208,9 @@ import codeql.swift.elements.type.ModuleTypeConstructor
import codeql.swift.elements.type.OpaqueTypeArchetypeTypeConstructor
import codeql.swift.elements.type.OpenedArchetypeTypeConstructor
import codeql.swift.elements.type.OptionalTypeConstructor
import codeql.swift.elements.type.PackExpansionTypeConstructor
import codeql.swift.elements.type.PackTypeConstructor
import codeql.swift.elements.type.ParameterizedProtocolTypeConstructor
import codeql.swift.elements.type.ParenTypeConstructor
import codeql.swift.elements.type.PlaceholderTypeConstructor
import codeql.swift.elements.type.PrimaryArchetypeTypeConstructor

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.type.Type
class PackExpansionTypeBase extends Synth::TPackExpansionType, Type {
override string getAPrimaryQlClass() { result = "PackExpansionType" }
}

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.type.Type
class PackTypeBase extends Synth::TPackType, Type {
override string getAPrimaryQlClass() { result = "PackType" }
}

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.type.Type
class ParameterizedProtocolTypeBase extends Synth::TParameterizedProtocolType, Type {
override string getAPrimaryQlClass() { result = "ParameterizedProtocolType" }
}

View File

@@ -1789,6 +1789,9 @@ while_stmts( //dir=stmt
| @in_out_type
| @l_value_type
| @module_type
| @pack_expansion_type
| @pack_type
| @parameterized_protocol_type
| @placeholder_type
| @protocol_composition_type
| @reference_storage_type
@@ -1921,6 +1924,18 @@ module_types( //dir=type
int module: @module_decl ref
);
pack_expansion_types( //dir=type
unique int id: @pack_expansion_type
);
pack_types( //dir=type
unique int id: @pack_type
);
parameterized_protocol_types( //dir=type
unique int id: @parameterized_protocol_type
);
placeholder_types( //dir=type
unique int id: @placeholder_type
);

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted