Swift: NestedArchetypeType was removed

This commit is contained in:
Alex Denisov
2022-09-21 18:37:30 +02:00
parent 61d5cdc421
commit 13fe02edfa
15 changed files with 1221 additions and 132 deletions

1218
swift/codegen/schema.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -234,15 +234,6 @@ void TypeVisitor::emitAnyGenericType(swift::AnyGenericType* type,
}
}
codeql::NestedArchetypeType TypeVisitor::translateNestedArchetypeType(
const swift::NestedArchetypeType& type) {
auto entry = createTypeEntry(type);
entry.parent = dispatcher_.fetchLabel(type.getParent());
entry.associated_type_declaration = dispatcher_.fetchLabel(type.getAssocType());
fillArchetypeType(type, entry);
return entry;
}
void TypeVisitor::fillType(const swift::TypeBase& type, codeql::Type& entry) {
entry.name = type.getString();
entry.canonical_type = dispatcher_.fetchLabel(type.getCanonicalType());

View File

@@ -39,7 +39,6 @@ class TypeVisitor : public TypeVisitorBase<TypeVisitor> {
void visitBoundGenericType(swift::BoundGenericType* type);
codeql::PrimaryArchetypeType translatePrimaryArchetypeType(
const swift::PrimaryArchetypeType& type);
codeql::NestedArchetypeType translateNestedArchetypeType(const swift::NestedArchetypeType& type);
codeql::ExistentialType translateExistentialType(const swift::ExistentialType& type);
codeql::DynamicSelfType translateDynamicSelfType(const swift::DynamicSelfType& type);
codeql::VariadicSequenceType translateVariadicSequenceType(

View File

@@ -254,7 +254,6 @@ import codeql.swift.elements.type.InOutType
import codeql.swift.elements.type.LValueType
import codeql.swift.elements.type.MetatypeType
import codeql.swift.elements.type.ModuleType
import codeql.swift.elements.type.NestedArchetypeType
import codeql.swift.elements.type.NominalOrBoundGenericNominalType
import codeql.swift.elements.type.NominalType
import codeql.swift.elements.type.OpaqueTypeArchetypeType

View File

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

View File

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

View File

@@ -4526,22 +4526,6 @@ private module Impl {
)
}
private Element getImmediateChildOfNestedArchetypeType(
NestedArchetypeType e, int index, string partialPredicateCall
) {
exists(int b, int bArchetypeType, int n |
b = 0 and
bArchetypeType =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and
n = bArchetypeType and
(
none()
or
result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfNominalType(
NominalType e, int index, string partialPredicateCall
) {
@@ -5240,8 +5224,6 @@ private module Impl {
or
result = getImmediateChildOfDictionaryType(e, index, partialAccessor)
or
result = getImmediateChildOfNestedArchetypeType(e, index, partialAccessor)
or
result = getImmediateChildOfOpaqueTypeArchetypeType(e, index, partialAccessor)
or
result = getImmediateChildOfOpenedArchetypeType(e, index, partialAccessor)

View File

@@ -1437,14 +1437,6 @@ module Raw {
Type getValueType() { dictionary_types(this, _, result) }
}
class NestedArchetypeType extends @nested_archetype_type, ArchetypeType {
override string toString() { result = "NestedArchetypeType" }
ArchetypeType getParent() { nested_archetype_types(this, result, _) }
AssociatedTypeDecl getAssociatedTypeDeclaration() { nested_archetype_types(this, _, result) }
}
class NominalType extends @nominal_type, NominalOrBoundGenericNominalType { }
class OpaqueTypeArchetypeType extends @opaque_type_archetype_type, ArchetypeType {

View File

@@ -277,7 +277,6 @@ module Synth {
TLValueType(Raw::LValueType id) { constructLValueType(id) } or
TMetatypeType(Raw::MetatypeType id) { constructMetatypeType(id) } or
TModuleType(Raw::ModuleType id) { constructModuleType(id) } or
TNestedArchetypeType(Raw::NestedArchetypeType id) { constructNestedArchetypeType(id) } or
TOpaqueTypeArchetypeType(Raw::OpaqueTypeArchetypeType id) {
constructOpaqueTypeArchetypeType(id)
} or
@@ -441,8 +440,8 @@ module Synth {
class TAnyMetatypeType = TExistentialMetatypeType or TMetatypeType;
class TArchetypeType =
TNestedArchetypeType or TOpaqueTypeArchetypeType or TOpenedArchetypeType or
TPrimaryArchetypeType or TSequenceArchetypeType;
TOpaqueTypeArchetypeType or TOpenedArchetypeType or TPrimaryArchetypeType or
TSequenceArchetypeType;
class TBoundGenericType =
TBoundGenericClassType or TBoundGenericEnumType or TBoundGenericStructType;
@@ -1285,11 +1284,6 @@ module Synth {
cached
TModuleType convertModuleTypeFromRaw(Raw::Element e) { result = TModuleType(e) }
cached
TNestedArchetypeType convertNestedArchetypeTypeFromRaw(Raw::Element e) {
result = TNestedArchetypeType(e)
}
cached
TOpaqueTypeArchetypeType convertOpaqueTypeArchetypeTypeFromRaw(Raw::Element e) {
result = TOpaqueTypeArchetypeType(e)
@@ -2000,8 +1994,6 @@ module Synth {
cached
TArchetypeType convertArchetypeTypeFromRaw(Raw::Element e) {
result = convertNestedArchetypeTypeFromRaw(e)
or
result = convertOpaqueTypeArchetypeTypeFromRaw(e)
or
result = convertOpenedArchetypeTypeFromRaw(e)
@@ -2961,11 +2953,6 @@ module Synth {
cached
Raw::Element convertModuleTypeToRaw(TModuleType e) { e = TModuleType(result) }
cached
Raw::Element convertNestedArchetypeTypeToRaw(TNestedArchetypeType e) {
e = TNestedArchetypeType(result)
}
cached
Raw::Element convertOpaqueTypeArchetypeTypeToRaw(TOpaqueTypeArchetypeType e) {
e = TOpaqueTypeArchetypeType(result)
@@ -3676,8 +3663,6 @@ module Synth {
cached
Raw::Element convertArchetypeTypeToRaw(TArchetypeType e) {
result = convertNestedArchetypeTypeToRaw(e)
or
result = convertOpaqueTypeArchetypeTypeToRaw(e)
or
result = convertOpenedArchetypeTypeToRaw(e)

View File

@@ -205,7 +205,6 @@ import codeql.swift.elements.type.InOutTypeConstructor
import codeql.swift.elements.type.LValueTypeConstructor
import codeql.swift.elements.type.MetatypeTypeConstructor
import codeql.swift.elements.type.ModuleTypeConstructor
import codeql.swift.elements.type.NestedArchetypeTypeConstructor
import codeql.swift.elements.type.OpaqueTypeArchetypeTypeConstructor
import codeql.swift.elements.type.OpenedArchetypeTypeConstructor
import codeql.swift.elements.type.OptionalTypeConstructor

View File

@@ -1,29 +0,0 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.type.ArchetypeType
import codeql.swift.elements.decl.AssociatedTypeDecl
class NestedArchetypeTypeBase extends Synth::TNestedArchetypeType, ArchetypeType {
override string getAPrimaryQlClass() { result = "NestedArchetypeType" }
ArchetypeType getImmediateParent() {
result =
Synth::convertArchetypeTypeFromRaw(Synth::convertNestedArchetypeTypeToRaw(this)
.(Raw::NestedArchetypeType)
.getParent())
}
final ArchetypeType getParent() { result = getImmediateParent().resolve() }
AssociatedTypeDecl getImmediateAssociatedTypeDeclaration() {
result =
Synth::convertAssociatedTypeDeclFromRaw(Synth::convertNestedArchetypeTypeToRaw(this)
.(Raw::NestedArchetypeType)
.getAssociatedTypeDeclaration())
}
final AssociatedTypeDecl getAssociatedTypeDeclaration() {
result = getImmediateAssociatedTypeDeclaration().resolve()
}
}

View File

@@ -2007,8 +2007,7 @@ unresolved_types( //dir=type
;
@archetype_type =
@nested_archetype_type
| @opaque_type_archetype_type
@opaque_type_archetype_type
| @opened_archetype_type
| @primary_archetype_type
| @sequence_archetype_type
@@ -2169,12 +2168,6 @@ dictionary_types( //dir=type
int value_type: @type ref
);
nested_archetype_types( //dir=type
unique int id: @nested_archetype_type,
int parent: @archetype_type ref,
int associated_type_declaration: @associated_type_decl ref
);
@nominal_type =
@class_type
| @enum_type

View File

@@ -1,18 +0,0 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from
NestedArchetypeType x, string getName, Type getCanonicalType, Type getInterfaceType,
ArchetypeType getParent, AssociatedTypeDecl getAssociatedTypeDeclaration
where
toBeTested(x) and
not x.isUnknown() and
getName = x.getName() and
getCanonicalType = x.getCanonicalType() and
getInterfaceType = x.getInterfaceType() and
getParent = x.getParent() and
getAssociatedTypeDeclaration = x.getAssociatedTypeDeclaration()
select x, "getName:", getName, "getCanonicalType:", getCanonicalType, "getInterfaceType:",
getInterfaceType, "getParent:", getParent, "getAssociatedTypeDeclaration:",
getAssociatedTypeDeclaration

View File

@@ -1,7 +0,0 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from NestedArchetypeType x, int index
where toBeTested(x) and not x.isUnknown()
select x, index, x.getProtocol(index)

View File

@@ -1,7 +0,0 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from NestedArchetypeType x
where toBeTested(x) and not x.isUnknown()
select x, x.getSuperclass()