Skip to content

Commit eb14348

Browse files
committed
Merge branch 'main' into redsun82/swift-error-element
2 parents d3ff490 + 7b6cb70 commit eb14348

26 files changed

+132
-148
lines changed

swift/extractor/infra/SwiftTagTraits.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ using PackExprTag = void;
2525
using PackTypeTag = void;
2626
using ReifyPackExprTag = void;
2727
using PackExpansionTypeTag = void;
28+
using SequenceArchetypeTypeTag = void;
2829
// Placeholder types appear in ambiguous types but are anyway transformed to UnresolvedType
2930
using PlaceholderTypeTag = void;
3031
// SIL types that cannot really appear in the frontend run
3132
using SILBlockStorageTypeTag = void;
3233
using SILBoxTypeTag = void;
3334
using SILFunctionTypeTag = void;
3435
using SILTokenTypeTag = void;
36+
// This is created during type checking and is only used for constraint checking
37+
using TypeVariableTypeTag = void;
3538

3639
#define MAP_TYPE_TO_TAG(TYPE, TAG) \
3740
template <> \

swift/extractor/translators/TypeTranslator.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,20 @@ codeql::OpaqueTypeArchetypeType TypeTranslator::translateOpaqueTypeArchetypeType
258258
entry.declaration = dispatcher.fetchLabel(type.getDecl());
259259
return entry;
260260
}
261+
262+
codeql::ErrorType TypeTranslator::translateErrorType(const swift::ErrorType& type) {
263+
return createTypeEntry(type);
264+
}
265+
266+
codeql::UnresolvedType TypeTranslator::translateUnresolvedType(const swift::UnresolvedType& type) {
267+
return createTypeEntry(type);
268+
}
269+
270+
codeql::ParameterizedProtocolType TypeTranslator::translateParameterizedProtocolType(
271+
const swift::ParameterizedProtocolType& type) {
272+
auto entry = createTypeEntry(type);
273+
entry.base = dispatcher.fetchLabel(type.getBaseType());
274+
entry.args = dispatcher.fetchRepeatedLabels(type.getArgs());
275+
return entry;
276+
}
261277
} // namespace codeql

swift/extractor/translators/TypeTranslator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class TypeTranslator : public TypeTranslatorBase<TypeTranslator> {
7171
codeql::ModuleType translateModuleType(const swift::ModuleType& type);
7272
codeql::OpaqueTypeArchetypeType translateOpaqueTypeArchetypeType(
7373
const swift::OpaqueTypeArchetypeType& type);
74+
codeql::ErrorType translateErrorType(const swift::ErrorType& type);
75+
codeql::UnresolvedType translateUnresolvedType(const swift::UnresolvedType& type);
76+
codeql::ParameterizedProtocolType translateParameterizedProtocolType(
77+
const swift::ParameterizedProtocolType& type);
7478

7579
private:
7680
void fillType(const swift::TypeBase& type, codeql::Type& entry);

swift/ql/lib/codeql/swift/elements.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ import codeql.swift.elements.type.PrimaryArchetypeType
263263
import codeql.swift.elements.type.ProtocolCompositionType
264264
import codeql.swift.elements.type.ProtocolType
265265
import codeql.swift.elements.type.ReferenceStorageType
266-
import codeql.swift.elements.type.SequenceArchetypeType
267266
import codeql.swift.elements.type.StructType
268267
import codeql.swift.elements.type.SubstitutableType
269268
import codeql.swift.elements.type.SugarType
@@ -272,7 +271,6 @@ import codeql.swift.elements.type.TupleType
272271
import codeql.swift.elements.type.Type
273272
import codeql.swift.elements.type.TypeAliasType
274273
import codeql.swift.elements.type.TypeRepr
275-
import codeql.swift.elements.type.TypeVariableType
276274
import codeql.swift.elements.type.UnarySyntaxSugarType
277275
import codeql.swift.elements.type.UnboundGenericType
278276
import codeql.swift.elements.type.UnmanagedStorageType

swift/ql/lib/codeql/swift/elements/type/SequenceArchetypeType.qll

Lines changed: 0 additions & 4 deletions
This file was deleted.

swift/ql/lib/codeql/swift/elements/type/SequenceArchetypeTypeConstructor.qll

Lines changed: 0 additions & 4 deletions
This file was deleted.

swift/ql/lib/codeql/swift/elements/type/TypeVariableType.qll

Lines changed: 0 additions & 4 deletions
This file was deleted.

swift/ql/lib/codeql/swift/elements/type/TypeVariableTypeConstructor.qll

Lines changed: 0 additions & 4 deletions
This file was deleted.

swift/ql/lib/codeql/swift/generated/ParentChild.qll

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4001,21 +4001,6 @@ private module Impl {
40014001
)
40024002
}
40034003

4004-
private Element getImmediateChildOfTypeVariableType(
4005-
TypeVariableType e, int index, string partialPredicateCall
4006-
) {
4007-
exists(int b, int bType, int n |
4008-
b = 0 and
4009-
bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and
4010-
n = bType and
4011-
(
4012-
none()
4013-
or
4014-
result = getImmediateChildOfType(e, index - b, partialPredicateCall)
4015-
)
4016-
)
4017-
}
4018-
40194004
private Element getImmediateChildOfUnresolvedType(
40204005
UnresolvedType e, int index, string partialPredicateCall
40214006
) {
@@ -4570,22 +4555,6 @@ private module Impl {
45704555
)
45714556
}
45724557

4573-
private Element getImmediateChildOfSequenceArchetypeType(
4574-
SequenceArchetypeType e, int index, string partialPredicateCall
4575-
) {
4576-
exists(int b, int bArchetypeType, int n |
4577-
b = 0 and
4578-
bArchetypeType =
4579-
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and
4580-
n = bArchetypeType and
4581-
(
4582-
none()
4583-
or
4584-
result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall)
4585-
)
4586-
)
4587-
}
4588-
45894558
private Element getImmediateChildOfUnarySyntaxSugarType(
45904559
UnarySyntaxSugarType e, int index, string partialPredicateCall
45914560
) {
@@ -5136,8 +5105,6 @@ private module Impl {
51365105
or
51375106
result = getImmediateChildOfTupleType(e, index, partialAccessor)
51385107
or
5139-
result = getImmediateChildOfTypeVariableType(e, index, partialAccessor)
5140-
or
51415108
result = getImmediateChildOfUnresolvedType(e, index, partialAccessor)
51425109
or
51435110
result = getImmediateChildOfBuiltinBridgeObjectType(e, index, partialAccessor)
@@ -5194,8 +5161,6 @@ private module Impl {
51945161
or
51955162
result = getImmediateChildOfPrimaryArchetypeType(e, index, partialAccessor)
51965163
or
5197-
result = getImmediateChildOfSequenceArchetypeType(e, index, partialAccessor)
5198-
or
51995164
result = getImmediateChildOfArraySliceType(e, index, partialAccessor)
52005165
or
52015166
result = getImmediateChildOfBoundGenericClassType(e, index, partialAccessor)

swift/ql/lib/codeql/swift/generated/Raw.qll

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,10 @@ module Raw {
13241324

13251325
class ParameterizedProtocolType extends @parameterized_protocol_type, Type {
13261326
override string toString() { result = "ParameterizedProtocolType" }
1327+
1328+
ProtocolType getBase() { parameterized_protocol_types(this, result) }
1329+
1330+
Type getArg(int index) { parameterized_protocol_type_args(this, index, result) }
13271331
}
13281332

13291333
class ProtocolCompositionType extends @protocol_composition_type, Type {
@@ -1348,10 +1352,6 @@ module Raw {
13481352
string getName(int index) { tuple_type_names(this, index, result) }
13491353
}
13501354

1351-
class TypeVariableType extends @type_variable_type, Type {
1352-
override string toString() { result = "TypeVariableType" }
1353-
}
1354-
13551355
class UnresolvedType extends @unresolved_type, Type, ErrorElement {
13561356
override string toString() { result = "UnresolvedType" }
13571357
}
@@ -1501,10 +1501,6 @@ module Raw {
15011501
override string toString() { result = "PrimaryArchetypeType" }
15021502
}
15031503

1504-
class SequenceArchetypeType extends @sequence_archetype_type, ArchetypeType {
1505-
override string toString() { result = "SequenceArchetypeType" }
1506-
}
1507-
15081504
class UnarySyntaxSugarType extends @unary_syntax_sugar_type, SyntaxSugarType {
15091505
Type getBaseType() { unary_syntax_sugar_types(this, result) }
15101506
}

0 commit comments

Comments
 (0)