Swift: Add upgrade and downgrade scripts

This commit is contained in:
Jeroen Ketema
2025-10-22 11:30:06 +02:00
parent 2843761471
commit e415772688
16 changed files with 11489 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
class AvailabilitySpec extends @availability_spec {
string toString() { none() }
}
query predicate new_other_availability_specs(AvailabilitySpec id) {
availability_specs(id) and
availability_spec_is_wildcard(id)
}
query predicate new_platform_version_availability_specs(
AvailabilitySpec id, string platform, string version
) {
availability_specs(id) and
availability_spec_platforms(id, platform) and
availability_spec_versions(id, version)
}

View File

@@ -0,0 +1,57 @@
class KeyPathComponent extends @key_path_component {
string toString() { none() }
}
class Element extends @element {
string toString() { none() }
}
class ArgumentOrNone extends @argument_or_none {
string toString() { none() }
}
class TypeOrNone extends @type_or_none {
string toString() { none() }
}
class ValueDeclOrNone extends @value_decl_or_none {
string toString() { none() }
}
predicate isKeyPathComponentWithNewKind(KeyPathComponent id) {
key_path_components(id, 3, _) or key_path_components(id, 4, _)
}
query predicate new_key_path_components(KeyPathComponent id, int kind, TypeOrNone component_type) {
exists(int old_kind |
key_path_components(id, old_kind, component_type) and
not isKeyPathComponentWithNewKind(id) and
if old_kind < 5 then kind = old_kind else kind = old_kind - 2
)
}
query predicate new_key_path_component_subscript_arguments(
KeyPathComponent id, int index, ArgumentOrNone subscript_argument
) {
key_path_component_subscript_arguments(id, index, subscript_argument) and
not isKeyPathComponentWithNewKind(id)
}
query predicate new_key_path_component_tuple_indices(KeyPathComponent id, int tuple_index) {
key_path_component_tuple_indices(id, tuple_index) and
not isKeyPathComponentWithNewKind(id)
}
query predicate new_key_path_component_decl_refs(KeyPathComponent id, ValueDeclOrNone decl_ref) {
key_path_component_decl_refs(id, decl_ref) and
not isKeyPathComponentWithNewKind(id)
}
query predicate new_unspecified_elements(Element id, string property, string error) {
unspecified_elements(id, property, error)
or
isKeyPathComponentWithNewKind(id) and
property = "" and
error =
"UnresolvedApply and Apply KeyPathComponents removed during database downgrade. Please update your CodeQL."
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
class ExistentialArchetypeType extends @existential_archetype_type {
string toString() { none() }
}
from ExistentialArchetypeType id
where existential_archetype_types(id)
select id

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
description: Upgrade to Swift 6.2
compatibility: partial
availability_specs.rel: delete
availability_spec_platforms.rel: delete
availability_spec_versions.rel: delete
availability_spec_is_wildcard.rel: delete
other_availability_specs.rel: run availability_specs.qlo new_other_availability_specs
platform_version_availability_specs.rel: run availability_specs.qlo new_platform_version_availability_specs
existential_archetype_types.rel: delete
opened_archetype_types.rel: run opened_archetype_types.qlo
key_path_components.rel: run key_path_components.qlo new_key_path_components
key_path_component_subscript_arguments.rel: run key_path_components.qlo new_key_path_component_subscript_arguments
key_path_component_tuple_indices.rel: run key_path_components.qlo new_key_path_component_tuple_indices
key_path_component_decl_refs.rel: run key_path_components.qlo new_key_path_component_decl_refs
unspecified_elements.rel: run key_path_components.qlo new_unspecified_elements

View File

@@ -724,13 +724,13 @@ lib/codeql/swift/generated/Diagnostics.qll 03ea201db80d33b18f7f6c71267044c695c25
lib/codeql/swift/generated/Element.qll bf8f688e05f44f18384067c3cab7f05796764e2b4cce7ff24da419c3dae26194 820390ffbb1012f73267668626f7d0ccd368500331c91bbc276fcb1c25037e41
lib/codeql/swift/generated/ErrorElement.qll b39bd7c8b4e2011f4a6889e073ebf5b628db32f36f50b067250ae730d9f26561 fd859ec969ba434049e7ba4e78271cc8cebc8b058d2e96e4d47a22064cbb5a21
lib/codeql/swift/generated/File.qll 476ac95566ef0080e0ad8c3da144b1be1d945d2f33a24f0864d85ff7c56a09b1 3134018bb50166cbf2690f64bba551cace350e4a7e6e25bcded18f997ad1835b
lib/codeql/swift/generated/KeyPathComponent.qll 713f514d23f252777d7a207bf894aec3d614691a05b2dc250b3e50fa41c97a96 46fa3f1666a48ab8a3998f409581be9869b7d74ece6ff65725dc25c86d5a4dff
lib/codeql/swift/generated/KeyPathComponent.qll 99d1699394bb7f9ff904e2d44149f20d3e08e35df171a6141f111c9ac9138b62 d8f62f60cc2c1e73146af79e5567c04cd273b73bfb5202bda964ec15032cb040
lib/codeql/swift/generated/Locatable.qll 1d37fa20de71c0b9986bfd7a7c0cb82ab7bf3fda2d2008700f955ad82ce109a7 e97d4d4fb8a4800e0008cc00f60c8ed9b1ebd5f1140fd85e68b034616178d721
lib/codeql/swift/generated/Location.qll 5e20316c3e480ddfe632b7e88e016c19f10a67df1f6ae9c8f128755a6907d6f5 5a0af2d070bcb2ed53d6d0282bf9c60dc64c2dce89c21fdd485e9c7893c1c8fa
lib/codeql/swift/generated/MacroRole.qll facf907e75490d69cd401c491215e4719324d751f40ea46c86ccf24cf3663c1f 969d8d4b44e3f1a9c193a152a4d83a303e56d2dbb871fc920c47a33f699cf018
lib/codeql/swift/generated/ParentChild.qll 88a8941821b1f511925eb8955ff25065a6004c61aa866854ee941d7556b1eb6d 6e32b4902cea8a78a9b2775826d64300987932c406212d841deeab7c48a5ef8b
lib/codeql/swift/generated/PureSynthConstructors.qll bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4
lib/codeql/swift/generated/Raw.qll 3491b6ec8362d409e5274fa7079d8910bdf6248b85d25986fce006fdd2927922 841eefe35c74ceda0ff24e7170137fd131d726f0c1f112c6b7e62ecb479e0aaf
lib/codeql/swift/generated/Raw.qll aa47e81ab3004a0049da3a85f25456bba15ed37329622153c154a296024077f3 46e9fb37fadc23d168fd43cbe77a792ba8e56aab7f4a3a984add1928efd4ac78
lib/codeql/swift/generated/Synth.qll a472fca73084eedab9ca8bb2fb82e7573d525444bb8d3729a3d18e06647fd96d b19984583774e30dae481d3d5cc95ebf2843c04dd952eb16cbf8a702ae52bbd8
lib/codeql/swift/generated/SynthConstructors.qll f3687a56d2fd9bc38d95d9ca335f558a91c865bd0bd1c7c73affedefd7514183 f3687a56d2fd9bc38d95d9ca335f558a91c865bd0bd1c7c73affedefd7514183
lib/codeql/swift/generated/UnknownFile.qll 247ddf2ebb49ce5ed4bf7bf91a969ddff37de6c78d43d8affccaf7eb586e06f2 452b29f0465ef45e978ef8b647b75e5a2a1e53f2a568fc003bc8f52f73b3fa4d

View File

@@ -30,7 +30,6 @@ module Generated {
* INTERNAL: Do not use.
*
* TODO: Swift 6.2 update with UnresolvedApply and Apply
* TODO: Swift 6.2 make sure to adjust in dbscheme upgrade/downgrade
*
* This is 5 for properties, 6 for array and dictionary subscripts, 7 for optional forcing
* (`!`), 8 for optional chaining (`?`), 9 for implicit optional wrapping, 10 for `self`,

View File

@@ -227,7 +227,6 @@ module Raw {
* INTERNAL: Do not use.
*
* TODO: Swift 6.2 update with UnresolvedApply and Apply
* TODO: Swift 6.2 make sure to adjust in dbscheme upgrade/downgrade
*
* This is 5 for properties, 6 for array and dictionary subscripts, 7 for optional forcing
* (`!`), 8 for optional chaining (`?`), 9 for implicit optional wrapping, 10 for `self`,

View File

@@ -0,0 +1,21 @@
class AvailabilitySpec extends @availability_spec {
string toString() { none() }
}
query predicate new_availability_specs(AvailabilitySpec id) {
platform_version_availability_specs(id, _, _)
or
other_availability_specs(id)
}
query predicate new_availability_spec_platforms(AvailabilitySpec id, string platform) {
platform_version_availability_specs(id, platform, _)
}
query predicate new_availability_spec_versions(AvailabilitySpec id, string version) {
platform_version_availability_specs(id, _, version)
}
query predicate new_availability_spec_is_wildcard(AvailabilitySpec id) {
other_availability_specs(id)
}

View File

@@ -0,0 +1,7 @@
class OpenedArchetypeType extends @opened_archetype_type {
string toString() { none() }
}
from OpenedArchetypeType id
where opened_archetype_types(id)
select id

View File

@@ -0,0 +1,13 @@
class KeyPathComponent extends @key_path_component {
string toString() { none() }
}
class TypeOrNone extends @type_or_none {
string toString() { none() }
}
from KeyPathComponent id, int kind, int new_kind, TypeOrNone component_type
where
key_path_components(id, kind, component_type) and
if kind < 3 then new_kind = kind else new_kind = kind + 2
select id, new_kind, component_type

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
description: Upgrade to Swift 6.2
compatibility: full
availability_specs.rel: run availability_specs.qlo new_availability_specs
availability_spec_platforms.rel: run availability_specs.qlo new_availability_spec_platforms
availability_spec_versions.rel: run availability_specs.qlo new_availability_spec_versions
availability_spec_is_wildcard.rel: run availability_specs.qlo new_availability_spec_is_wildcard
existential_archetype_types.rel: run existential_archetype_types.qlo
key_path_components.rel: run key_path_components.qlo
opened_archetype_types.rel: delete
other_availability_specs.rel: delete
platform_version_availability_specs.rel: delete

View File

@@ -487,7 +487,6 @@ class KeyPathComponent(AstNode):
INTERNAL: Do not use.
TODO: Swift 6.2 update with UnresolvedApply and Apply
TODO: Swift 6.2 make sure to adjust in dbscheme upgrade/downgrade
This is 5 for properties, 6 for array and dictionary subscripts, 7 for optional forcing
(`!`), 8 for optional chaining (`?`), 9 for implicit optional wrapping, 10 for `self`,