Swift: Handle InlineArrayTypes

This commit is contained in:
Jeroen Ketema
2025-10-31 10:15:07 +01:00
parent 72e8ec3951
commit f4d1e1c034
19 changed files with 220 additions and 7 deletions

View File

@@ -348,7 +348,7 @@ MAP(swift::TypeBase, TypeTag)
MAP(swift::ArraySliceType, ArraySliceTypeTag)
MAP(swift::OptionalType, OptionalTypeTag)
MAP(swift::VariadicSequenceType, VariadicSequenceTypeTag)
MAP(swift::InlineArrayType, void) // TODO: Swift 6.2
MAP(swift::InlineArrayType, InlineArrayTypeTag)
MAP(swift::DictionaryType, DictionaryTypeTag)
MAP(swift::AvailabilitySpec, AvailabilitySpecTag)

View File

@@ -88,6 +88,14 @@ codeql::ArraySliceType TypeTranslator::translateArraySliceType(const swift::Arra
return entry;
}
codeql::InlineArrayType TypeTranslator::translateInlineArrayType(
const swift::InlineArrayType& type) {
auto entry = createTypeEntry(type);
entry.count_type = dispatcher.fetchLabel(type.getCountType());
entry.element_type = dispatcher.fetchLabel(type.getElementType());
return entry;
}
codeql::DictionaryType TypeTranslator::translateDictionaryType(const swift::DictionaryType& type) {
auto entry = createTypeEntry(type);
entry.key_type = dispatcher.fetchLabel(type.getKeyType());

View File

@@ -28,6 +28,7 @@ class TypeTranslator : public TypeTranslatorBase<TypeTranslator> {
const swift::UnarySyntaxSugarType& type);
codeql::OptionalType translateOptionalType(const swift::OptionalType& type);
codeql::ArraySliceType translateArraySliceType(const swift::ArraySliceType& type);
codeql::InlineArrayType translateInlineArrayType(const swift::InlineArrayType& type);
codeql::DictionaryType translateDictionaryType(const swift::DictionaryType& type);
codeql::GenericFunctionType translateGenericFunctionType(const swift::GenericFunctionType& type);
codeql::GenericTypeParamType translateGenericTypeParamType(

View File

@@ -564,6 +564,7 @@ lib/codeql/swift/elements/type/FunctionType.qll 1a64eb24e8baa74ef2a8e4451f97442a
lib/codeql/swift/elements/type/GenericFunctionType.qll 8df1db2785c4e6b88f9af13eb7ba473f91459f57d19c4d706847ac6e3a02d64a 186efec4c23c372f9d9f7038d4b5a36f9c3184564e5b6899d2e467864977dd89
lib/codeql/swift/elements/type/GenericTypeParamType.qll d75c865295501f7efe27399ce93b30f6a4a217ed207e7227a5d9870cf536ad5f 1a764963700b872c8ea7afd586abbc0dadda68366555baefa6737d87b701a73f
lib/codeql/swift/elements/type/InOutType.qll 3ff69b884d2604f66290b188892f1d9d4321bf77a20bcda2ce5cb69e565b0cfb 3cd2b06bc606d84b1d73b8fcd2aea4d49aed0c8b98902b44dd6f19d298db7f9d
lib/codeql/swift/elements/type/InlineArrayType.qll 6af5235213a7d861944e7450143393bf3f56acbe4ac86770aa3920f39f7e61cb 7e04b96dd988e2f7edd7e34d5cf4a787cbcb94b8d0c21417e3e4829112dbe34e
lib/codeql/swift/elements/type/IntegerType.qll 118acea4a849506aeddd5df92e9f134bf611f8c08cb44e18dc56259df1c98e5f 6801c067c63e310f28fed70a7c1ed87d08be6b7070a7ec677517a93b6eab0c3f
lib/codeql/swift/elements/type/LValueType.qll e1e53b1467f7b4ff77a812ae9cd8ce151cfc21443a4da14319aee390c081775c 42f5a39fb2c1e5dad3fef6db56430c6063cb04b1ba9c1f2b9c68356aef6aef1c
lib/codeql/swift/elements/type/LocalArchetypeType.qll 449ff6d721a70a0f8f7a8e1604471513af1523bad6efcc49820154e4d42a426b 1121b807f15d442b708bb614b684ad3d0581c787bae4a16999b8dd7da5103ab6
@@ -666,6 +667,8 @@ lib/codeql/swift/elements/type/internal/GenericTypeParamTypeConstructor.qll b126
lib/codeql/swift/elements/type/internal/GenericTypeParamTypeImpl.qll efca259897a044fc967341a9fdb39497fc5e9bcb0b4ba33fa76cb926b98b3eb7 aaa621c691813a2f70f4071e3592d7760cef319904209770442ca0d0583f65a1
lib/codeql/swift/elements/type/internal/InOutTypeConstructor.qll 40550fd07551bc7c1692e08f1cb0692defca613c3c6403719efc5998eb1f1bfd 775f16224a455e336da239a179f84581b345803b9576aca119aeb3eef583d739
lib/codeql/swift/elements/type/internal/InOutTypeImpl.qll 28fc2931a424f551107b0ee49663d5d5307146c725353c5e484f0dd289f93dc0 ff12e91e30ee53bb8acdcf9e31261b6b1b0ae966babb4eacacb344c22aa1cb6e
lib/codeql/swift/elements/type/internal/InlineArrayTypeConstructor.qll 382c61399e3e51d8ffa41e5ee3c59d93fc4899284e715f7fb58696cad5d9ca54 0401ff7ff1c07d8d55e670f21a47377b6d650fe74b78c7d9daf9d23de30dbfdf
lib/codeql/swift/elements/type/internal/InlineArrayTypeImpl.qll b74965b9567b7bb6afdf1834ab3e372da0b13ca10244cbdeee55f71ad952e418 c026806f4f3e5fb416b0d1511c8e8aa6b31fa525b2987a0774d8750118dacad4
lib/codeql/swift/elements/type/internal/IntegerTypeConstructor.qll 39e33225066f7162309f888723f81893703ee0daba68f192e3277f922060160b 08903e4d0bc8889761d016d6b6c4b7f1bd061a08c97e2a151b59cc0400ea2199
lib/codeql/swift/elements/type/internal/IntegerTypeImpl.qll ba8e6e972dcea4dbe937083c819c5fd9eb49ba4b6176e040ce65d36a95fe31bd 88064b52d9430b67edd62ed37426f5adc8f6d80722370340d147b0a4ca90f70c
lib/codeql/swift/elements/type/internal/LValueTypeConstructor.qll e3ab6ebb6191a2553bd4a483067acf7131862bc7235af2da74c35e2250300da8 cfa65d0f22416408ee1e5e5af440166fe5f5b39ae9bf1b9ae92bd9f9f2954b76
@@ -718,7 +721,7 @@ lib/codeql/swift/elements/type/internal/UnresolvedTypeImpl.qll ee1499dd568753898
lib/codeql/swift/elements/type/internal/VariadicSequenceTypeConstructor.qll fc74a5a2a2effa28ef24509b20ee4373d97cf6e8c71840121bb031c6adedf584 c9b2effc1d01c13c5e6a74a111122fa79a2f6554dda3cb016d68ba397e566ec4
lib/codeql/swift/elements/type/internal/WeakStorageTypeConstructor.qll 5fdce3716aba6318522174a2c455a63480970222ae81c732fb19c6dd3ae2d271 60ea79d6943e129deba0deccb566cf9d73f78398b0f7f0212674d91287d6b2ae
lib/codeql/swift/elements/type/internal/WeakStorageTypeImpl.qll 74f79b458f3204ec2519bd654de21bc4fb6b76816bd8ca01990fe897563a1383 34e1810f74cecda5b580ed050438ae1d914b97a36b8f4e2de1c25254c0cac633
lib/codeql/swift/elements.qll 9af7c15501106ca3cc40447dbf7cda3fb0e45d7b77e25679e42a1d2d651aed55 9af7c15501106ca3cc40447dbf7cda3fb0e45d7b77e25679e42a1d2d651aed55
lib/codeql/swift/elements.qll ec0104a658330f595eac7dd8578d996905a6c2cf78765744c3967a8f3d1c3273 ec0104a658330f595eac7dd8578d996905a6c2cf78765744c3967a8f3d1c3273
lib/codeql/swift/generated/AstNode.qll 6fb80e9b230a1e3ae8193af40744f253d5cc81dc4239156924e5ab606c491efc e5c28418e9a38bde08f323a3986a199620189fc4a8a4dc8f670610a5d3d65b99
lib/codeql/swift/generated/AvailabilityInfo.qll e3a5274c43e72ff124b6988fd8be0c83a41b89337e11104150dd0ca7f51d8a11 889563791ca8d9758dbbccf64a0731c4bdbf721cad32bc6cd723f1072b6aa1de
lib/codeql/swift/generated/AvailabilitySpec.qll 1bd2a0ee085f802c99090e681ab3339fc5013024d79deef39f376de12ab76d37 658f2eb51860726cfa6808b3e3501d624e0734750d1420f7a25c89782f1f6c7e
@@ -734,11 +737,11 @@ lib/codeql/swift/generated/KeyPathComponent.qll e11dcf952045b5e6062e24c23515cff9
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 2d73f037f2a8d0f1d056ba7eb9d254275d46e5111617f262d8c618c3abb14050 e50636c770a5152be79e1cbc4528633233c2449c9c99c1a359e0e880bf93169f
lib/codeql/swift/generated/ParentChild.qll 4d697f5372ad82380dc375a59fa0619ee56c7d88be58530147cd8e160262bbe3 e164b712a41f20d0b9986804cd753fb5e55ceb55139234d98bdb332a8f248db4
lib/codeql/swift/generated/PureSynthConstructors.qll bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4
lib/codeql/swift/generated/Raw.qll 70e9ee68fe351433246ad62deab892587647630947220645c025460bdbd7ca6e 6948032896309b0885fda6f92269ac300f274d671a43d80bebb17e283c510efd
lib/codeql/swift/generated/Synth.qll d66a45f1572d722463cf3490ad1f3aefdf3197090c4d20f362fa2e71975095c2 36d89d310bb49a4d958e085203e16079bf77e1f32428808f995a00261b34820f
lib/codeql/swift/generated/SynthConstructors.qll 77fa549bc12afecb4d9fb4999b5c025aee27d4ec4e40b70afb0f5a22f7846a47 77fa549bc12afecb4d9fb4999b5c025aee27d4ec4e40b70afb0f5a22f7846a47
lib/codeql/swift/generated/Raw.qll f7dd5c3eb1afba1077dd6c291502e2b5dd5d18000ee581f7e3ad4f0050165c69 f042929df4651dfe587769cd3f539d07f97328c2fe17fbe19cbb8e4fbefe97f2
lib/codeql/swift/generated/Synth.qll 6af0f5778c6c6a9d9a518c00707501c3fdb3ccaa96fa06793549c2b1f28c9cbb 575829e7a2a4c7619c6d98f1b7ec47d978d0b3d77d5c1a87eae5e9f98612ef5b
lib/codeql/swift/generated/SynthConstructors.qll c40f01e1331bdbe238620a41d17409cefe34a6b23066708ef5d74f8631b54f48 c40f01e1331bdbe238620a41d17409cefe34a6b23066708ef5d74f8631b54f48
lib/codeql/swift/generated/UnknownFile.qll 247ddf2ebb49ce5ed4bf7bf91a969ddff37de6c78d43d8affccaf7eb586e06f2 452b29f0465ef45e978ef8b647b75e5a2a1e53f2a568fc003bc8f52f73b3fa4d
lib/codeql/swift/generated/UnknownLocation.qll d871000b4f53ffca4f67ea23ca5626e5dcce125d62a4d4b9969e08cc974af6fc b05971d7774e60790362fb810fb7086314f40a2de747b8cb1bc823ec6494a4dd
lib/codeql/swift/generated/UnspecifiedElement.qll d9ad4ba1ffff90cc465e8ba0dea8c4e8ba67dce5529b53b63ab6dc8e13c85e67 025218e1fee8ee382b63ad38009dfec73dc604d2ba80b9ad956c7c96eeed7022
@@ -1000,6 +1003,7 @@ lib/codeql/swift/generated/type/FunctionType.qll 739192b77787905a66d9c9970dc077c
lib/codeql/swift/generated/type/GenericFunctionType.qll 50743701a62cad6f2cbe8b331a45bd3b18f3154b860720355b831735fd2208b4 481b28aee3e473a74a66628acd2050cfee9807ebad8c8a0646783e3942b89297
lib/codeql/swift/generated/type/GenericTypeParamType.qll f266dffcd2f87f8411b796b97faa671a7bb5e6dd0aa67d3bfc9bbc06a47f1a3b 0e1625a7d2447faf75ec4c716ed1d5219b82ba8720450bc77d279e9854599758
lib/codeql/swift/generated/type/InOutType.qll 809a3bb1c5eec066416c2fce85df9116e7402a368c7e955abe6a01c7673cbdf4 7c614fa92e624890f3a83e7a7f3464f8a94f45b60beeb77f9295850567522ba7
lib/codeql/swift/generated/type/InlineArrayType.qll 90254c4b169240f55cf3d061474bb72cb9e107550d2ff1525e1ac6a38f03624a effa3759a6c2177f8586670c90445e7242a391bcffb3c354b5428221404ec926
lib/codeql/swift/generated/type/IntegerType.qll f2040268ae94c41f27a659c09c55360b20000d40440cb9513409a95379b3b37f 4397d31da9bad9e5167d6dc6cb7f26071bb80e00538bd8f55e7fc53e45e8bd32
lib/codeql/swift/generated/type/LValueType.qll 4a6422f21bd21b841d841cad9f7c01ce7eeb9ba6b5d1fa004fa44dc008eaa432 8914e356e0475f0f3b81c681295fa7a833fae2e24c491d8d6e552ad897be4184
lib/codeql/swift/generated/type/LocalArchetypeType.qll de4f291bab61ccb699609f39682cbe29936da3c8be51e9a5620b0bce384bc852 152a74964a40daa7419de15d646ee8b62d137a8a5d7c5d0b002d81d1fdf12c47
@@ -1197,6 +1201,7 @@ test/extractor-tests/generated/type/FunctionType/MISSING_SOURCE.txt 35fb32ea5393
test/extractor-tests/generated/type/GenericFunctionType/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d
test/extractor-tests/generated/type/GenericTypeParamType/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d
test/extractor-tests/generated/type/InOutType/InOutType.ql 611aea3776fbcd3763d798b58eba36522db9d4f8ae95dad133562abc6b9d0a9c 184e35f8ef3aa77b52d7d6dbd784fe4749793c50f0484195bd91f49bc2838509
test/extractor-tests/generated/type/InlineArrayType/InlineArrayType.ql e51c2fb11a7b19bcdd008944d16fd32b62a4460e53b792370aba45a8150a2b97 7c9541613e0a5ca33a1d73d03900de2a1dd5466a910e2a153e206a3ae650f8b8
test/extractor-tests/generated/type/IntegerType/IntegerType.ql 6f18b3b5b4c53ca5d5302a78b04fea929bce478fa5c342f01951379a405b4c8a 486c1ceef03d02b064381ba514ad19eeca250c83ce54354a08c3a7c94bd4fd11
test/extractor-tests/generated/type/LValueType/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d
test/extractor-tests/generated/type/MetatypeType/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d

5
swift/ql/.gitattributes generated vendored
View File

@@ -566,6 +566,7 @@
/lib/codeql/swift/elements/type/GenericFunctionType.qll linguist-generated
/lib/codeql/swift/elements/type/GenericTypeParamType.qll linguist-generated
/lib/codeql/swift/elements/type/InOutType.qll linguist-generated
/lib/codeql/swift/elements/type/InlineArrayType.qll linguist-generated
/lib/codeql/swift/elements/type/IntegerType.qll linguist-generated
/lib/codeql/swift/elements/type/LValueType.qll linguist-generated
/lib/codeql/swift/elements/type/LocalArchetypeType.qll linguist-generated
@@ -668,6 +669,8 @@
/lib/codeql/swift/elements/type/internal/GenericTypeParamTypeImpl.qll linguist-generated
/lib/codeql/swift/elements/type/internal/InOutTypeConstructor.qll linguist-generated
/lib/codeql/swift/elements/type/internal/InOutTypeImpl.qll linguist-generated
/lib/codeql/swift/elements/type/internal/InlineArrayTypeConstructor.qll linguist-generated
/lib/codeql/swift/elements/type/internal/InlineArrayTypeImpl.qll linguist-generated
/lib/codeql/swift/elements/type/internal/IntegerTypeConstructor.qll linguist-generated
/lib/codeql/swift/elements/type/internal/IntegerTypeImpl.qll linguist-generated
/lib/codeql/swift/elements/type/internal/LValueTypeConstructor.qll linguist-generated
@@ -1002,6 +1005,7 @@
/lib/codeql/swift/generated/type/GenericFunctionType.qll linguist-generated
/lib/codeql/swift/generated/type/GenericTypeParamType.qll linguist-generated
/lib/codeql/swift/generated/type/InOutType.qll linguist-generated
/lib/codeql/swift/generated/type/InlineArrayType.qll linguist-generated
/lib/codeql/swift/generated/type/IntegerType.qll linguist-generated
/lib/codeql/swift/generated/type/LValueType.qll linguist-generated
/lib/codeql/swift/generated/type/LocalArchetypeType.qll linguist-generated
@@ -1199,6 +1203,7 @@
/test/extractor-tests/generated/type/GenericFunctionType/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/type/GenericTypeParamType/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/type/InOutType/InOutType.ql linguist-generated
/test/extractor-tests/generated/type/InlineArrayType/InlineArrayType.ql linguist-generated
/test/extractor-tests/generated/type/IntegerType/IntegerType.ql linguist-generated
/test/extractor-tests/generated/type/LValueType/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/type/MetatypeType/MISSING_SOURCE.txt linguist-generated

View File

@@ -275,6 +275,7 @@ import codeql.swift.elements.type.FunctionType
import codeql.swift.elements.type.GenericFunctionType
import codeql.swift.elements.type.GenericTypeParamType
import codeql.swift.elements.type.InOutType
import codeql.swift.elements.type.InlineArrayType
import codeql.swift.elements.type.IntegerType
import codeql.swift.elements.type.LValueType
import codeql.swift.elements.type.LocalArchetypeType

View File

@@ -0,0 +1,10 @@
// generated by codegen/codegen.py, do not edit
/**
* This module provides the public class `InlineArrayType`.
*/
private import internal.InlineArrayTypeImpl
import codeql.swift.elements.type.SyntaxSugarType
import codeql.swift.elements.type.Type
final class InlineArrayType = Impl::InlineArrayType;

View File

@@ -0,0 +1,14 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module defines the hook used internally to tweak the characteristic predicate of
* `InlineArrayType` synthesized instances.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.Raw
/**
* The characteristic predicate of `InlineArrayType` synthesized instances.
* INTERNAL: Do not use.
*/
predicate constructInlineArrayType(Raw::InlineArrayType id) { any() }

View File

@@ -0,0 +1,16 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `InlineArrayType`.
*
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.type.InlineArrayType
/**
* INTERNAL: This module contains the customizable definition of `InlineArrayType` and should not
* be referenced directly.
*/
module Impl {
class InlineArrayType extends Generated::InlineArrayType { }
}

View File

@@ -3103,6 +3103,12 @@ private module Impl {
none()
}
private Element getImmediateChildOfInlineArrayType(
InlineArrayType e, int index, string partialPredicateCall
) {
none()
}
private Element getImmediateChildOfOpaqueTypeArchetypeType(
OpaqueTypeArchetypeType e, int index, string partialPredicateCall
) {
@@ -3675,6 +3681,8 @@ private module Impl {
or
result = getImmediateChildOfDictionaryType(e, index, partialAccessor)
or
result = getImmediateChildOfInlineArrayType(e, index, partialAccessor)
or
result = getImmediateChildOfOpaqueTypeArchetypeType(e, index, partialAccessor)
or
result = getImmediateChildOfPackArchetypeType(e, index, partialAccessor)

View File

@@ -3789,6 +3789,23 @@ module Raw {
Type getValueType() { dictionary_types(this, _, result) }
}
/**
* INTERNAL: Do not use.
*/
class InlineArrayType extends @inline_array_type, SyntaxSugarType {
override string toString() { result = "InlineArrayType" }
/**
* Gets the count type of this inline array type.
*/
Type getCountType() { inline_array_types(this, result, _) }
/**
* Gets the element type of this inline array type.
*/
Type getElementType() { inline_array_types(this, _, result) }
}
/**
* INTERNAL: Do not use.
*/

View File

@@ -1010,6 +1010,10 @@ module Synth {
* INTERNAL: Do not use.
*/
TInOutType(Raw::InOutType id) { constructInOutType(id) } or
/**
* INTERNAL: Do not use.
*/
TInlineArrayType(Raw::InlineArrayType id) { constructInlineArrayType(id) } or
/**
* INTERNAL: Do not use.
*/
@@ -1430,7 +1434,7 @@ module Synth {
/**
* INTERNAL: Do not use.
*/
class TSyntaxSugarType = TDictionaryType or TUnarySyntaxSugarType;
class TSyntaxSugarType = TDictionaryType or TInlineArrayType or TUnarySyntaxSugarType;
/**
* INTERNAL: Do not use.
@@ -3039,6 +3043,12 @@ module Synth {
*/
TInOutType convertInOutTypeFromRaw(Raw::Element e) { result = TInOutType(e) }
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TInlineArrayType`, if possible.
*/
TInlineArrayType convertInlineArrayTypeFromRaw(Raw::Element e) { result = TInlineArrayType(e) }
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TIntegerType`, if possible.
@@ -4122,6 +4132,8 @@ module Synth {
TSyntaxSugarType convertSyntaxSugarTypeFromRaw(Raw::Element e) {
result = convertDictionaryTypeFromRaw(e)
or
result = convertInlineArrayTypeFromRaw(e)
or
result = convertUnarySyntaxSugarTypeFromRaw(e)
}
@@ -5777,6 +5789,12 @@ module Synth {
*/
Raw::Element convertInOutTypeToRaw(TInOutType e) { e = TInOutType(result) }
/**
* INTERNAL: Do not use.
* Converts a synthesized `TInlineArrayType` to a raw DB element, if possible.
*/
Raw::Element convertInlineArrayTypeToRaw(TInlineArrayType e) { e = TInlineArrayType(result) }
/**
* INTERNAL: Do not use.
* Converts a synthesized `TIntegerType` to a raw DB element, if possible.
@@ -6860,6 +6878,8 @@ module Synth {
Raw::Element convertSyntaxSugarTypeToRaw(TSyntaxSugarType e) {
result = convertDictionaryTypeToRaw(e)
or
result = convertInlineArrayTypeToRaw(e)
or
result = convertUnarySyntaxSugarTypeToRaw(e)
}

View File

@@ -232,6 +232,7 @@ import codeql.swift.elements.type.internal.FunctionTypeConstructor
import codeql.swift.elements.type.internal.GenericFunctionTypeConstructor
import codeql.swift.elements.type.internal.GenericTypeParamTypeConstructor
import codeql.swift.elements.type.internal.InOutTypeConstructor
import codeql.swift.elements.type.internal.InlineArrayTypeConstructor
import codeql.swift.elements.type.internal.IntegerTypeConstructor
import codeql.swift.elements.type.internal.LValueTypeConstructor
import codeql.swift.elements.type.internal.MetatypeTypeConstructor

View File

@@ -0,0 +1,70 @@
// generated by codegen/codegen.py, do not edit
/**
* This module provides the generated definition of `InlineArrayType`.
* INTERNAL: Do not import directly.
*/
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.type.internal.SyntaxSugarTypeImpl::Impl as SyntaxSugarTypeImpl
import codeql.swift.elements.type.Type
/**
* INTERNAL: This module contains the fully generated definition of `InlineArrayType` and should not
* be referenced directly.
*/
module Generated {
/**
* INTERNAL: Do not reference the `Generated::InlineArrayType` class directly.
* Use the subclass `InlineArrayType`, where the following predicates are available.
*/
class InlineArrayType extends Synth::TInlineArrayType, SyntaxSugarTypeImpl::SyntaxSugarType {
override string getAPrimaryQlClass() { result = "InlineArrayType" }
/**
* Gets the count type of this inline array type.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Type getImmediateCountType() {
result =
Synth::convertTypeFromRaw(Synth::convertInlineArrayTypeToRaw(this)
.(Raw::InlineArrayType)
.getCountType())
}
/**
* Gets the count type of this inline array type.
*/
final Type getCountType() {
exists(Type immediate |
immediate = this.getImmediateCountType() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)
}
/**
* Gets the element type of this inline array type.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Type getImmediateElementType() {
result =
Synth::convertTypeFromRaw(Synth::convertInlineArrayTypeToRaw(this)
.(Raw::InlineArrayType)
.getElementType())
}
/**
* Gets the element type of this inline array type.
*/
final Type getElementType() {
exists(Type immediate |
immediate = this.getImmediateElementType() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)
}
}
}

View File

@@ -2520,6 +2520,7 @@ paren_types( //dir=type
@syntax_sugar_type =
@dictionary_type
| @inline_array_type
| @unary_syntax_sugar_type
;
@@ -2577,6 +2578,12 @@ dictionary_types( //dir=type
int value_type: @type_or_none ref
);
inline_array_types( //dir=type
unique int id: @inline_array_type,
int count_type: @type_or_none ref,
int element_type: @type_or_none ref
);
@local_archetype_type =
@element_archetype_type
| @existential_archetype_type

View File

@@ -0,0 +1 @@
| [42 of Int] | getName: | [42 of Int] | getCanonicalType: | InlineArray<42, Int> | getCountType: | 42 | getElementType: | Int |

View File

@@ -0,0 +1,20 @@
// generated by codegen/codegen.py, do not edit
import codeql.swift.elements
import TestUtils
query predicate instances(
InlineArrayType x, string getName__label, string getName, string getCanonicalType__label,
Type getCanonicalType, string getCountType__label, Type getCountType,
string getElementType__label, Type getElementType
) {
toBeTested(x) and
not x.isUnknown() and
getName__label = "getName:" and
getName = x.getName() and
getCanonicalType__label = "getCanonicalType:" and
getCanonicalType = x.getCanonicalType() and
getCountType__label = "getCountType:" and
getCountType = x.getCountType() and
getElementType__label = "getElementType:" and
getElementType = x.getElementType()
}

View File

@@ -0,0 +1,5 @@
struct Foo {
var x: [42 of Int]
}
//codeql-extractor-options: -disable-availability-checking

View File

@@ -1192,6 +1192,10 @@ class BuiltinIntegerLiteralType(AnyBuiltinIntegerType):
class BuiltinIntegerType(AnyBuiltinIntegerType):
width: optional[int]
class InlineArrayType(SyntaxSugarType):
count_type: Type
element_type: Type
class DictionaryType(SyntaxSugarType):
key_type: Type
value_type: Type