Swift: Support BuiltinFixedArrayType

This commit is contained in:
Jeroen Ketema
2025-05-02 14:32:04 +02:00
parent c74fca929a
commit 98384bf4c2
16 changed files with 161 additions and 9 deletions

View File

@@ -250,6 +250,7 @@ import codeql.swift.elements.type.BoundGenericType
import codeql.swift.elements.type.BuiltinBridgeObjectType
import codeql.swift.elements.type.BuiltinDefaultActorStorageType
import codeql.swift.elements.type.BuiltinExecutorType
import codeql.swift.elements.type.BuiltinFixedArrayType
import codeql.swift.elements.type.BuiltinFloatType
import codeql.swift.elements.type.BuiltinIntegerLiteralType
import codeql.swift.elements.type.BuiltinIntegerType

View File

@@ -0,0 +1,12 @@
// generated by codegen/codegen.py, do not edit
/**
* This module provides the public class `BuiltinFixedArrayType`.
*/
private import internal.BuiltinFixedArrayTypeImpl
import codeql.swift.elements.type.BuiltinType
/**
* A builtin type representing N values stored contiguously.
*/
final class BuiltinFixedArrayType = Impl::BuiltinFixedArrayType;

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
* `BuiltinFixedArrayType` synthesized instances.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.Raw
/**
* The characteristic predicate of `BuiltinFixedArrayType` synthesized instances.
* INTERNAL: Do not use.
*/
predicate constructBuiltinFixedArrayType(Raw::BuiltinFixedArrayType id) { any() }

View File

@@ -0,0 +1,19 @@
// 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 `BuiltinFixedArrayType`.
*
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.type.BuiltinFixedArrayType
/**
* INTERNAL: This module contains the customizable definition of `BuiltinFixedArrayType` and should not
* be referenced directly.
*/
module Impl {
/**
* A builtin type representing N values stored contiguously.
*/
class BuiltinFixedArrayType extends Generated::BuiltinFixedArrayType { }
}

View File

@@ -4564,6 +4564,22 @@ private module Impl {
)
}
private Element getImmediateChildOfBuiltinFixedArrayType(
BuiltinFixedArrayType e, int index, string partialPredicateCall
) {
exists(int b, int bBuiltinType, int n |
b = 0 and
bBuiltinType =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and
n = bBuiltinType and
(
none()
or
result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfBuiltinFloatType(
BuiltinFloatType e, int index, string partialPredicateCall
) {
@@ -5679,6 +5695,8 @@ private module Impl {
or
result = getImmediateChildOfBuiltinExecutorType(e, index, partialAccessor)
or
result = getImmediateChildOfBuiltinFixedArrayType(e, index, partialAccessor)
or
result = getImmediateChildOfBuiltinFloatType(e, index, partialAccessor)
or
result = getImmediateChildOfBuiltinJobType(e, index, partialAccessor)

View File

@@ -3546,6 +3546,14 @@ module Raw {
override string toString() { result = "BuiltinExecutorType" }
}
/**
* INTERNAL: Do not use.
* A builtin type representing N values stored contiguously.
*/
class BuiltinFixedArrayType extends @builtin_fixed_array_type, BuiltinType {
override string toString() { result = "BuiltinFixedArrayType" }
}
/**
* INTERNAL: Do not use.
*/

View File

@@ -900,6 +900,10 @@ module Synth {
* INTERNAL: Do not use.
*/
TBuiltinExecutorType(Raw::BuiltinExecutorType id) { constructBuiltinExecutorType(id) } or
/**
* INTERNAL: Do not use.
*/
TBuiltinFixedArrayType(Raw::BuiltinFixedArrayType id) { constructBuiltinFixedArrayType(id) } or
/**
* INTERNAL: Do not use.
*/
@@ -1389,8 +1393,8 @@ module Synth {
*/
class TBuiltinType =
TAnyBuiltinIntegerType or TBuiltinBridgeObjectType or TBuiltinDefaultActorStorageType or
TBuiltinExecutorType or TBuiltinFloatType or TBuiltinJobType or TBuiltinNativeObjectType or
TBuiltinRawPointerType or TBuiltinRawUnsafeContinuationType or
TBuiltinExecutorType or TBuiltinFixedArrayType or TBuiltinFloatType or TBuiltinJobType or
TBuiltinNativeObjectType or TBuiltinRawPointerType or TBuiltinRawUnsafeContinuationType or
TBuiltinUnsafeValueBufferType or TBuiltinVectorType;
/**
@@ -2861,6 +2865,14 @@ module Synth {
result = TBuiltinExecutorType(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TBuiltinFixedArrayType`, if possible.
*/
TBuiltinFixedArrayType convertBuiltinFixedArrayTypeFromRaw(Raw::Element e) {
result = TBuiltinFixedArrayType(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TBuiltinFloatType`, if possible.
@@ -4022,6 +4034,8 @@ module Synth {
or
result = convertBuiltinExecutorTypeFromRaw(e)
or
result = convertBuiltinFixedArrayTypeFromRaw(e)
or
result = convertBuiltinFloatTypeFromRaw(e)
or
result = convertBuiltinJobTypeFromRaw(e)
@@ -5593,6 +5607,14 @@ module Synth {
e = TBuiltinExecutorType(result)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TBuiltinFixedArrayType` to a raw DB element, if possible.
*/
Raw::Element convertBuiltinFixedArrayTypeToRaw(TBuiltinFixedArrayType e) {
e = TBuiltinFixedArrayType(result)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TBuiltinFloatType` to a raw DB element, if possible.
@@ -6754,6 +6776,8 @@ module Synth {
or
result = convertBuiltinExecutorTypeToRaw(e)
or
result = convertBuiltinFixedArrayTypeToRaw(e)
or
result = convertBuiltinFloatTypeToRaw(e)
or
result = convertBuiltinJobTypeToRaw(e)

View File

@@ -207,6 +207,7 @@ import codeql.swift.elements.type.internal.BoundGenericStructTypeConstructor
import codeql.swift.elements.type.internal.BuiltinBridgeObjectTypeConstructor
import codeql.swift.elements.type.internal.BuiltinDefaultActorStorageTypeConstructor
import codeql.swift.elements.type.internal.BuiltinExecutorTypeConstructor
import codeql.swift.elements.type.internal.BuiltinFixedArrayTypeConstructor
import codeql.swift.elements.type.internal.BuiltinFloatTypeConstructor
import codeql.swift.elements.type.internal.BuiltinIntegerLiteralTypeConstructor
import codeql.swift.elements.type.internal.BuiltinIntegerTypeConstructor

View File

@@ -0,0 +1,24 @@
// generated by codegen/codegen.py, do not edit
/**
* This module provides the generated definition of `BuiltinFixedArrayType`.
* INTERNAL: Do not import directly.
*/
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.type.internal.BuiltinTypeImpl::Impl as BuiltinTypeImpl
/**
* INTERNAL: This module contains the fully generated definition of `BuiltinFixedArrayType` and should not
* be referenced directly.
*/
module Generated {
/**
* A builtin type representing N values stored contiguously.
* INTERNAL: Do not reference the `Generated::BuiltinFixedArrayType` class directly.
* Use the subclass `BuiltinFixedArrayType`, where the following predicates are available.
*/
class BuiltinFixedArrayType extends Synth::TBuiltinFixedArrayType, BuiltinTypeImpl::BuiltinType {
override string getAPrimaryQlClass() { result = "BuiltinFixedArrayType" }
}
}