Swift: extract ProtocolComposition- and BuiltinType

This commit is contained in:
Paolo Tranquilli
2022-06-28 11:57:11 +02:00
parent b41cbaec33
commit 57981384df
70 changed files with 303 additions and 262 deletions

View File

@@ -14,14 +14,14 @@ _directories:
Element:
is_unknown: predicate
_pragma: skip_qltest
_pragma: qltest_skip
File:
name: string
Locatable:
location: Location?
_pragma: skip_qltest
_pragma: qltest_skip
Location:
file: File
@@ -29,7 +29,7 @@ Location:
start_column: int
end_line: int
end_column: int
_pragma: skip_qltest
_pragma: qltest_skip
Type:
diagnostics_name: string
@@ -85,6 +85,7 @@ AnyMetatypeType:
BuiltinType:
_extends: Type
_pragma: qltest_collapse_hierarchy
DependentMemberType:
_extends: Type
@@ -114,6 +115,7 @@ PlaceholderType:
ProtocolCompositionType:
_extends: Type
members: Type*
ExistentialType:
_extends: Type
@@ -393,7 +395,7 @@ EnumIsCaseExpr:
ErrorExpr:
_extends: Expr
_pragma: skip_qltest # unexpected emission
_pragma: qltest_skip # unexpected emission
ExplicitCastExpr:
_extends: Expr
@@ -468,7 +470,7 @@ ObjCSelectorExpr:
_children:
sub_expr: Expr
method: AbstractFunctionDecl
_pragma: skip_qltest # to be tested in integration tests
_pragma: qltest_skip # to be tested in integration tests
OneWayExpr:
_extends: Expr
@@ -510,7 +512,7 @@ SequenceExpr:
_extends: Expr
_children:
elements: Expr*
_pragma: skip_qltest # we should really never extract these, as these should be resolved to trees of operations
_pragma: qltest_skip # we should really never extract these, as these should be resolved to trees of operations
SuperRefExpr:
_extends: Expr
@@ -542,7 +544,7 @@ TypeExpr:
UnresolvedDeclRefExpr:
_extends: Expr
name: string?
_pragma: skip_qltest # we should really never extract these
_pragma: qltest_skip # we should really never extract these
UnresolvedDotExpr:
_extends: Expr
@@ -553,15 +555,15 @@ UnresolvedDotExpr:
UnresolvedMemberExpr:
_extends: Expr
name: string
_pragma: skip_qltest # we should really never extract these
_pragma: qltest_skip # we should really never extract these
UnresolvedPatternExpr:
_extends: Expr
_pragma: skip_qltest # we should really never extract these
_pragma: qltest_skip # we should really never extract these
UnresolvedSpecializeExpr:
_extends: Expr
_pragma: skip_qltest # we should really never extract these
_pragma: qltest_skip # we should really never extract these
VarargExpansionExpr:
_extends: Expr
@@ -698,6 +700,7 @@ BuiltinIntegerLiteralType:
BuiltinIntegerType:
_extends: AnyBuiltinIntegerType
_pragma: qltest_uncollapse_hierarchy
width: int?
NestedArchetypeType:
@@ -830,11 +833,11 @@ ArrayToPointerExpr:
BridgeFromObjCExpr:
_extends: ImplicitConversionExpr
_pragma: skip_qltest # to be tested in integration tests
_pragma: qltest_skip # to be tested in integration tests
BridgeToObjCExpr:
_extends: ImplicitConversionExpr
_pragma: skip_qltest # to be tested in integration tests
_pragma: qltest_skip # to be tested in integration tests
ClassMetatypeToObjectExpr:
_extends: ImplicitConversionExpr
@@ -844,7 +847,7 @@ CollectionUpcastConversionExpr:
ConditionalBridgeFromObjCExpr:
_extends: ImplicitConversionExpr
_pragma: skip_qltest # to be tested in integration tests
_pragma: qltest_skip # to be tested in integration tests
CovariantFunctionConversionExpr:
_extends: ImplicitConversionExpr

View File

@@ -304,4 +304,74 @@ void TypeVisitor::fillReferenceStorageType(const swift::ReferenceStorageType& ty
fillType(type, entry);
}
codeql::ProtocolCompositionType TypeVisitor::translateProtocolCompositionType(
const swift::ProtocolCompositionType& type) {
auto entry = createEntry(type);
entry.members = dispatcher_.fetchRepeatedLabels(type.getMembers());
return entry;
}
codeql::BuiltinIntegerLiteralType TypeVisitor::translateBuiltinIntegerLiteralType(
const swift::BuiltinIntegerLiteralType& type) {
return createEntry(type);
}
codeql::BuiltinIntegerType TypeVisitor::translateBuiltinIntegerType(
const swift::BuiltinIntegerType& type) {
auto entry = createEntry(type);
if (type.isFixedWidth()) {
entry.width = type.getFixedWidth();
}
return entry;
}
codeql::BuiltinBridgeObjectType TypeVisitor::translateBuiltinBridgeObjectType(
const swift::BuiltinBridgeObjectType& type) {
return createEntry(type);
}
codeql::BuiltinDefaultActorStorageType TypeVisitor::translateBuiltinDefaultActorStorageType(
const swift::BuiltinDefaultActorStorageType& type) {
return createEntry(type);
}
codeql::BuiltinExecutorType TypeVisitor::translateBuiltinExecutorType(
const swift::BuiltinExecutorType& type) {
return createEntry(type);
}
codeql::BuiltinFloatType TypeVisitor::translateBuiltinFloatType(
const swift::BuiltinFloatType& type) {
return createEntry(type);
}
codeql::BuiltinJobType TypeVisitor::translateBuiltinJobType(const swift::BuiltinJobType& type) {
return createEntry(type);
}
codeql::BuiltinNativeObjectType TypeVisitor::translateBuiltinNativeObjectType(
const swift::BuiltinNativeObjectType& type) {
return createEntry(type);
}
codeql::BuiltinRawPointerType TypeVisitor::translateBuiltinRawPointerType(
const swift::BuiltinRawPointerType& type) {
return createEntry(type);
}
codeql::BuiltinRawUnsafeContinuationType TypeVisitor::translateBuiltinRawUnsafeContinuationType(
const swift::BuiltinRawUnsafeContinuationType& type) {
return createEntry(type);
}
codeql::BuiltinUnsafeValueBufferType TypeVisitor::translateBuiltinUnsafeValueBufferType(
const swift::BuiltinUnsafeValueBufferType& type) {
return createEntry(type);
}
codeql::BuiltinVectorType TypeVisitor::translateBuiltinVectorType(
const swift::BuiltinVectorType& type) {
return createEntry(type);
}
} // namespace codeql

View File

@@ -47,6 +47,27 @@ class TypeVisitor : public TypeVisitorBase<TypeVisitor> {
const swift::UnmanagedStorageType& type);
codeql::WeakStorageType translateWeakStorageType(const swift::WeakStorageType& type);
codeql::UnownedStorageType translateUnownedStorageType(const swift::UnownedStorageType& type);
codeql::ProtocolCompositionType translateProtocolCompositionType(
const swift::ProtocolCompositionType& type);
codeql::BuiltinIntegerLiteralType translateBuiltinIntegerLiteralType(
const swift::BuiltinIntegerLiteralType& type);
codeql::BuiltinIntegerType translateBuiltinIntegerType(const swift::BuiltinIntegerType& type);
codeql::BuiltinBridgeObjectType translateBuiltinBridgeObjectType(
const swift::BuiltinBridgeObjectType& type);
codeql::BuiltinDefaultActorStorageType translateBuiltinDefaultActorStorageType(
const swift::BuiltinDefaultActorStorageType& type);
codeql::BuiltinExecutorType translateBuiltinExecutorType(const swift::BuiltinExecutorType& type);
codeql::BuiltinFloatType translateBuiltinFloatType(const swift::BuiltinFloatType& type);
codeql::BuiltinJobType translateBuiltinJobType(const swift::BuiltinJobType& type);
codeql::BuiltinNativeObjectType translateBuiltinNativeObjectType(
const swift::BuiltinNativeObjectType& type);
codeql::BuiltinRawPointerType translateBuiltinRawPointerType(
const swift::BuiltinRawPointerType& type);
codeql::BuiltinRawUnsafeContinuationType translateBuiltinRawUnsafeContinuationType(
const swift::BuiltinRawUnsafeContinuationType& type);
codeql::BuiltinUnsafeValueBufferType translateBuiltinUnsafeValueBufferType(
const swift::BuiltinUnsafeValueBufferType& type);
codeql::BuiltinVectorType translateBuiltinVectorType(const swift::BuiltinVectorType& type);
private:
void fillType(const swift::TypeBase& type, codeql::Type& entry);
@@ -58,6 +79,13 @@ class TypeVisitor : public TypeVisitorBase<TypeVisitor> {
void emitAnyFunctionType(const swift::AnyFunctionType* type, TrapLabel<AnyFunctionTypeTag> label);
void emitBoundGenericType(swift::BoundGenericType* type, TrapLabel<BoundGenericTypeTag> label);
void emitAnyGenericType(swift::AnyGenericType* type, TrapLabel<AnyGenericTypeTag> label);
template <typename T>
auto createEntry(const T& type) {
TrapClassOf<T> entry{dispatcher_.assignNewLabel(type)};
fillType(type, entry);
return entry;
}
};
} // namespace codeql

View File

@@ -1,6 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.type.ExistentialType
private import codeql.swift.elements.type.ProtocolType
class ExistentialType extends ExistentialTypeBase {
override ProtocolType getConstraint() { result = super.getConstraint() }
}
class ExistentialType extends ExistentialTypeBase { }

View File

@@ -3,4 +3,15 @@ import codeql.swift.elements.type.Type
class ProtocolCompositionTypeBase extends @protocol_composition_type, Type {
override string getAPrimaryQlClass() { result = "ProtocolCompositionType" }
Type getMember(int index) {
exists(Type x |
protocol_composition_type_members(this, index, x) and
result = x.resolve()
)
}
Type getAMember() { result = getMember(_) }
int getNumberOfMembers() { result = count(getAMember()) }
}

View File

@@ -274,6 +274,13 @@ protocol_composition_types( //dir=type
unique int id: @protocol_composition_type
);
#keyset[id, index]
protocol_composition_type_members( //dir=type
int id: @protocol_composition_type ref,
int index: int ref,
int member: @type ref
);
existential_types( //dir=type
unique int id: @existential_type,
int constraint: @type ref

View File

@@ -9,13 +9,18 @@ predicate toBeTested(Element e) {
(
e = loc
or
e = loc.(ValueDecl).getInterfaceType()
or
e = loc.(NominalTypeDecl).getType()
or
e = loc.(VarDecl).getType()
or
e = loc.(Expr).getType()
exists(Type t |
(e = t or e = t.(ExistentialType).getConstraint() or e = t.getCanonicalType()) and
(
t = loc.(ValueDecl).getInterfaceType()
or
t = loc.(NominalTypeDecl).getType()
or
t = loc.(VarDecl).getType()
or
t = loc.(Expr).getType()
)
)
)
)
}

View File

@@ -2,10 +2,9 @@
import codeql.swift.elements
import TestUtils
from File x, string isUnknown, string getName
from File x, string getName
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getName = x.getName()
select x, "isUnknown:", isUnknown, "getName:", getName
select x, "getName:", getName

View File

@@ -1,4 +0,0 @@
// 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

@@ -3,17 +3,16 @@ import codeql.swift.elements
import TestUtils
from
AccessorDecl x, string isUnknown, Type getInterfaceType, string getName, string isGetter,
string isSetter, string isWillSet, string isDidSet
AccessorDecl x, Type getInterfaceType, string getName, string isGetter, string isSetter,
string isWillSet, string isDidSet
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getInterfaceType = x.getInterfaceType() and
getName = x.getName() and
(if x.isGetter() then isGetter = "yes" else isGetter = "no") and
(if x.isSetter() then isSetter = "yes" else isSetter = "no") and
(if x.isWillSet() then isWillSet = "yes" else isWillSet = "no") and
if x.isDidSet() then isDidSet = "yes" else isDidSet = "no"
select x, "isUnknown:", isUnknown, "getInterfaceType:", getInterfaceType, "getName:", getName,
"isGetter:", isGetter, "isSetter:", isSetter, "isWillSet:", isWillSet, "isDidSet:", isDidSet
select x, "getInterfaceType:", getInterfaceType, "getName:", getName, "isGetter:", isGetter,
"isSetter:", isSetter, "isWillSet:", isWillSet, "isDidSet:", isDidSet

View File

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

View File

@@ -2,11 +2,10 @@
import codeql.swift.elements
import TestUtils
from AssociatedTypeDecl x, string isUnknown, Type getInterfaceType, string getName
from AssociatedTypeDecl x, Type getInterfaceType, string getName
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getInterfaceType = x.getInterfaceType() and
getName = x.getName()
select x, "isUnknown:", isUnknown, "getInterfaceType:", getInterfaceType, "getName:", getName
select x, "getInterfaceType:", getInterfaceType, "getName:", getName

View File

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

View File

@@ -2,13 +2,11 @@
import codeql.swift.elements
import TestUtils
from ClassDecl x, string isUnknown, Type getInterfaceType, string getName, Type getType
from ClassDecl x, Type getInterfaceType, string getName, Type getType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getInterfaceType = x.getInterfaceType() and
getName = x.getName() and
getType = x.getType()
select x, "isUnknown:", isUnknown, "getInterfaceType:", getInterfaceType, "getName:", getName,
"getType:", getType
select x, "getInterfaceType:", getInterfaceType, "getName:", getName, "getType:", getType

View File

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

View File

@@ -2,11 +2,10 @@
import codeql.swift.elements
import TestUtils
from ConcreteFuncDecl x, string isUnknown, Type getInterfaceType, string getName
from ConcreteFuncDecl x, Type getInterfaceType, string getName
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getInterfaceType = x.getInterfaceType() and
getName = x.getName()
select x, "isUnknown:", isUnknown, "getInterfaceType:", getInterfaceType, "getName:", getName
select x, "getInterfaceType:", getInterfaceType, "getName:", getName

View File

@@ -2,13 +2,11 @@
import codeql.swift.elements
import TestUtils
from EnumDecl x, string isUnknown, Type getInterfaceType, string getName, Type getType
from EnumDecl x, Type getInterfaceType, string getName, Type getType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getInterfaceType = x.getInterfaceType() and
getName = x.getName() and
getType = x.getType()
select x, "isUnknown:", isUnknown, "getInterfaceType:", getInterfaceType, "getName:", getName,
"getType:", getType
select x, "getInterfaceType:", getInterfaceType, "getName:", getName, "getType:", getType

View File

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

View File

@@ -1,4 +0,0 @@
// 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

@@ -1,11 +0,0 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from BridgeToObjCExpr x, string isUnknown, Expr getSubExpr
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getSubExpr = x.getSubExpr()
select x, "isUnknown:", isUnknown, "getSubExpr:", getSubExpr

View File

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

View File

@@ -1,4 +0,0 @@
// 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

@@ -2,10 +2,9 @@
import codeql.swift.elements
import TestUtils
from DotSelfExpr x, string isUnknown, Expr getSubExpr
from DotSelfExpr x, Expr getSubExpr
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getSubExpr = x.getSubExpr()
select x, "isUnknown:", isUnknown, "getSubExpr:", getSubExpr
select x, "getSubExpr:", getSubExpr

View File

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

View File

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -2,11 +2,10 @@
import codeql.swift.elements
import TestUtils
from UnresolvedDotExpr x, string isUnknown, Expr getBase, string getName
from UnresolvedDotExpr x, Expr getBase, string getName
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getBase = x.getBase() and
getName = x.getName()
select x, "isUnknown:", isUnknown, "getBase:", getBase, "getName:", getName
select x, "getBase:", getBase, "getName:", getName

View File

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

View File

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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,5 @@
| Builtin.Int8 | getDiagnosticsName: | Builtin.Int8 | getCanonicalType: | Builtin.Int8 |
| Builtin.Int16 | getDiagnosticsName: | Builtin.Int16 | getCanonicalType: | Builtin.Int16 |
| Builtin.Int32 | getDiagnosticsName: | Builtin.Int32 | getCanonicalType: | Builtin.Int32 |
| Builtin.Int64 | getDiagnosticsName: | Builtin.Int64 | getCanonicalType: | Builtin.Int64 |
| Builtin.Word | getDiagnosticsName: | Builtin.Word | getCanonicalType: | Builtin.Word |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from BuiltinIntegerType x, string getDiagnosticsName, Type getCanonicalType
where
toBeTested(x) and
not x.isUnknown() and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType()
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType

View File

@@ -0,0 +1,4 @@
| Builtin.Int8 | 8 |
| Builtin.Int16 | 16 |
| Builtin.Int32 | 32 |
| Builtin.Int64 | 64 |

View File

@@ -2,6 +2,6 @@
import codeql.swift.elements
import TestUtils
from BridgeToObjCExpr x
from BuiltinIntegerType x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()
select x, x.getWidth()

View File

@@ -1,4 +0,0 @@
// 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,8 @@
//codeql-extractor-options: -parse-stdlib
func foo(
_: Builtin.Int8,
_: Builtin.Int16,
_: Builtin.Int32,
_: Builtin.Int64,
_: Builtin.Word
) {}

View File

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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,11 @@
| Builtin.BridgeObject | getDiagnosticsName: | Builtin.BridgeObject | getCanonicalType: | Builtin.BridgeObject |
| Builtin.DefaultActorStorage | getDiagnosticsName: | Builtin.DefaultActorStorage | getCanonicalType: | Builtin.DefaultActorStorage |
| Builtin.Executor | getDiagnosticsName: | Builtin.Executor | getCanonicalType: | Builtin.Executor |
| Builtin.FPIEEE32 | getDiagnosticsName: | Builtin.FPIEEE32 | getCanonicalType: | Builtin.FPIEEE32 |
| Builtin.FPIEEE64 | getDiagnosticsName: | Builtin.FPIEEE64 | getCanonicalType: | Builtin.FPIEEE64 |
| Builtin.IntLiteral | getDiagnosticsName: | Builtin.IntLiteral | getCanonicalType: | Builtin.IntLiteral |
| Builtin.Job | getDiagnosticsName: | Builtin.Job | getCanonicalType: | Builtin.Job |
| Builtin.NativeObject | getDiagnosticsName: | Builtin.NativeObject | getCanonicalType: | Builtin.NativeObject |
| Builtin.RawPointer | getDiagnosticsName: | Builtin.RawPointer | getCanonicalType: | Builtin.RawPointer |
| Builtin.RawUnsafeContinuation | getDiagnosticsName: | Builtin.RawUnsafeContinuation | getCanonicalType: | Builtin.RawUnsafeContinuation |
| Builtin.UnsafeValueBuffer | getDiagnosticsName: | Builtin.UnsafeValueBuffer | getCanonicalType: | Builtin.UnsafeValueBuffer |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from BuiltinType x, string getDiagnosticsName, Type getCanonicalType
where
toBeTested(x) and
not x.isUnknown() and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType()
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType

View File

@@ -0,0 +1,14 @@
//codeql-extractor-options: -parse-stdlib
func foo(
_: Builtin.IntLiteral,
_: Builtin.FPIEEE32,
_: Builtin.FPIEEE64,
_: Builtin.BridgeObject,
_: Builtin.DefaultActorStorage,
_: Builtin.Executor,
_: Builtin.Job,
_: Builtin.NativeObject,
_: Builtin.RawPointer,
_: Builtin.RawUnsafeContinuation,
_: Builtin.UnsafeValueBuffer
) {}

View File

@@ -1,4 +0,0 @@
// 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

@@ -1,4 +0,0 @@
// 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

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
DynamicSelfType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getStaticSelfType
from DynamicSelfType x, string getDiagnosticsName, Type getCanonicalType, Type getStaticSelfType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getStaticSelfType = x.getStaticSelfType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getStaticSelfType:", getStaticSelfType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getStaticSelfType:", getStaticSelfType

View File

@@ -1,2 +1,3 @@
| ExplicitExistential | getDiagnosticsName: | ExplicitExistential | getCanonicalType: | ExplicitExistential | getConstraint: | ExplicitExistential |
| ImplicitExistential | getDiagnosticsName: | ImplicitExistential | getCanonicalType: | ImplicitExistential | getConstraint: | ImplicitExistential |
| P1 & P2 | getDiagnosticsName: | P1 & P2 | getCanonicalType: | P1 & P2 | getConstraint: | P1 & P2 |

View File

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
ExistentialType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getConstraint
from ExistentialType x, string getDiagnosticsName, Type getCanonicalType, Type getConstraint
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getConstraint = x.getConstraint()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getConstraint:", getConstraint
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getConstraint:", getConstraint

View File

@@ -1,5 +1,8 @@
protocol ExplicitExistential {}
protocol ImplicitExistential {}
protocol P1 {}
protocol P2 {}
func foo1(_: any ExplicitExistential) {}
func foo2(_: ImplicitExistential) {} // valid for now, will be an error in some future swift release
func foo3(_: any P1 & P2) {}

View File

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
InOutType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getObjectType
from InOutType x, string getDiagnosticsName, Type getCanonicalType, Type getObjectType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getObjectType = x.getObjectType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getObjectType:", getObjectType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getObjectType:", getObjectType

View File

@@ -3,19 +3,17 @@ import codeql.swift.elements
import TestUtils
from
NestedArchetypeType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
string getName, Type getInterfaceType, ArchetypeType getParent,
AssociatedTypeDecl getAssociatedTypeDeclaration
NestedArchetypeType x, string getDiagnosticsName, Type getCanonicalType, string getName,
Type getInterfaceType, ArchetypeType getParent, AssociatedTypeDecl getAssociatedTypeDeclaration
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getName = x.getName() and
getInterfaceType = x.getInterfaceType() and
getParent = x.getParent() and
getAssociatedTypeDeclaration = x.getAssociatedTypeDeclaration()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getName:", getName, "getInterfaceType:", getInterfaceType, "getParent:",
getParent, "getAssociatedTypeDeclaration:", getAssociatedTypeDeclaration
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getName:", getName, "getInterfaceType:", getInterfaceType, "getParent:", getParent,
"getAssociatedTypeDeclaration:", getAssociatedTypeDeclaration

View File

@@ -3,15 +3,14 @@ import codeql.swift.elements
import TestUtils
from
PrimaryArchetypeType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
string getName, Type getInterfaceType
PrimaryArchetypeType x, string getDiagnosticsName, Type getCanonicalType, string getName,
Type getInterfaceType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getName = x.getName() and
getInterfaceType = x.getInterfaceType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getName:", getName, "getInterfaceType:", getInterfaceType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getName:", getName, "getInterfaceType:", getInterfaceType

View File

@@ -1,4 +0,0 @@
// 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 @@
| P1 & (P2 & P3) | getDiagnosticsName: | P1 & (P2 & P3) | getCanonicalType: | P1 & P2 & P3 |
| P1 & P2 & P3 | getDiagnosticsName: | P1 & P2 & P3 | getCanonicalType: | P1 & P2 & P3 |
| P1 & P23 | getDiagnosticsName: | P1 & P23 | getCanonicalType: | P1 & P2 & P3 |
| P2 & P4 | getDiagnosticsName: | P2 & P4 | getCanonicalType: | P2 & P4 |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ProtocolCompositionType x, string getDiagnosticsName, Type getCanonicalType
where
toBeTested(x) and
not x.isUnknown() and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType()
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType

View File

@@ -0,0 +1,9 @@
| P1 & (P2 & P3) | 0 | P1 |
| P1 & (P2 & P3) | 1 | (P2 & P3) |
| P1 & P2 & P3 | 0 | P1 |
| P1 & P2 & P3 | 1 | P2 |
| P1 & P2 & P3 | 2 | P3 |
| P1 & P23 | 0 | P1 |
| P1 & P23 | 1 | P23 |
| P2 & P4 | 0 | P2 |
| P2 & P4 | 1 | P4 |

View File

@@ -2,6 +2,6 @@
import codeql.swift.elements
import TestUtils
from ConcreteFuncDecl x
from ProtocolCompositionType x, int index
where toBeTested(x) and not x.isUnknown()
select x, x.getLocation()
select x, index, x.getMember(index)

View File

@@ -0,0 +1,13 @@
protocol P1 {}
protocol P2 {}
protocol P3 {}
var x: P1 & P2 & P3
protocol P4: P1 {}
var y: P1 & P2 & P4
var z: P1 & (P2 & P3)
typealias P23 = P2 & P3
var zz: P1 & P23

View File

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
UnmanagedStorageType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getReferentType
from UnmanagedStorageType x, string getDiagnosticsName, Type getCanonicalType, Type getReferentType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getReferentType = x.getReferentType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getReferentType:", getReferentType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getReferentType:", getReferentType

View File

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
UnownedStorageType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getReferentType
from UnownedStorageType x, string getDiagnosticsName, Type getCanonicalType, Type getReferentType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getReferentType = x.getReferentType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getReferentType:", getReferentType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getReferentType:", getReferentType

View File

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
VariadicSequenceType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getBaseType
from VariadicSequenceType x, string getDiagnosticsName, Type getCanonicalType, Type getBaseType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getBaseType = x.getBaseType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getBaseType:", getBaseType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getBaseType:", getBaseType

View File

@@ -2,15 +2,12 @@
import codeql.swift.elements
import TestUtils
from
WeakStorageType x, string isUnknown, string getDiagnosticsName, Type getCanonicalType,
Type getReferentType
from WeakStorageType x, string getDiagnosticsName, Type getCanonicalType, Type getReferentType
where
toBeTested(x) and
not x.isUnknown() and
(if x.isUnknown() then isUnknown = "yes" else isUnknown = "no") and
getDiagnosticsName = x.getDiagnosticsName() and
getCanonicalType = x.getCanonicalType() and
getReferentType = x.getReferentType()
select x, "isUnknown:", isUnknown, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:",
getCanonicalType, "getReferentType:", getReferentType
select x, "getDiagnosticsName:", getDiagnosticsName, "getCanonicalType:", getCanonicalType,
"getReferentType:", getReferentType