Skip to content

Commit 396b576

Browse files
redsun82AlexDenisov
authored andcommitted
Swift: minimal 5.8 compatibility
1 parent e8b12ce commit 396b576

File tree

12 files changed

+43
-50
lines changed

12 files changed

+43
-50
lines changed

swift/actions/run-integration-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ runs:
1313
- uses: actions/setup-python@v4
1414
with:
1515
python-version-file: 'swift/.python-version'
16-
- uses: swift-actions/setup-swift@da0e3e04b5e3e15dbc3861bd835ad9f0afe56296
16+
- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf
1717
with:
1818
swift-version: "${{steps.get_swift_version.outputs.version}}"
1919
- uses: ./.github/actions/fetch-codeql

swift/extractor/infra/SwiftTagTraits.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ MAP(swift::Expr, ExprTag)
9595
MAP(swift::IdentityExpr, IdentityExprTag)
9696
MAP(swift::ParenExpr, ParenExprTag)
9797
MAP(swift::DotSelfExpr, DotSelfExprTag)
98+
MAP(swift::MoveExpr, void) // TODO (introduced in 5.8)
9899
MAP(swift::AwaitExpr, AwaitExprTag)
99100
MAP(swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag)
100101
MAP(swift::AnyTryExpr, AnyTryExprTag)
@@ -113,6 +114,8 @@ MAP(swift::Expr, ExprTag)
113114
MAP(swift::AutoClosureExpr, AutoClosureExprTag)
114115
MAP(swift::InOutExpr, InOutExprTag)
115116
MAP(swift::VarargExpansionExpr, VarargExpansionExprTag)
117+
MAP(swift::PackExpansionExpr, void) // TODO (introduced in 5.8)
118+
MAP(swift::PackElementExpr, void) // TODO (introduced in 5.8)
116119
MAP(swift::DynamicTypeExpr, DynamicTypeExprTag)
117120
MAP(swift::RebindSelfInConstructorExpr, RebindSelfInInitializerExprTag)
118121
MAP(swift::OpaqueValueExpr, OpaqueValueExprTag)
@@ -164,7 +167,6 @@ MAP(swift::Expr, ExprTag)
164167
MAP(swift::DifferentiableFunctionExtractOriginalExpr, DifferentiableFunctionExtractOriginalExprTag)
165168
MAP(swift::LinearFunctionExtractOriginalExpr, LinearFunctionExtractOriginalExprTag)
166169
MAP(swift::LinearToDifferentiableFunctionExpr, LinearToDifferentiableFunctionExprTag)
167-
MAP(swift::ReifyPackExpr, void) // experimental variadic generics
168170
MAP(swift::ABISafeConversionExpr, AbiSafeConversionExprTag) // different acronym convention
169171
MAP(swift::ExplicitCastExpr, ExplicitCastExprTag)
170172
MAP(swift::CheckedCastExpr, CheckedCastExprTag)
@@ -173,7 +175,7 @@ MAP(swift::Expr, ExprTag)
173175
MAP(swift::IsExpr, IsExprTag)
174176
MAP(swift::CoerceExpr, CoerceExprTag)
175177
MAP(swift::ArrowExpr, void) // not present after the Sema phase
176-
MAP(swift::IfExpr, IfExprTag)
178+
MAP(swift::TernaryExpr, IfExprTag)
177179
MAP(swift::EnumIsCaseExpr, EnumIsCaseExprTag)
178180
MAP(swift::AssignExpr, AssignExprTag)
179181
MAP(swift::CodeCompletionExpr, void) // only generated for code editing
@@ -185,8 +187,8 @@ MAP(swift::Expr, ExprTag)
185187
MAP(swift::KeyPathDotExpr, KeyPathDotExprTag)
186188
MAP(swift::OneWayExpr, OneWayExprTag)
187189
MAP(swift::TapExpr, TapExprTag)
188-
MAP(swift::PackExpr, void) // experimental variadic generics
189-
190+
MAP(swift::TypeJoinExpr, void) // TODO (introduced in 5.8)
191+
MAP(swift::MacroExpansionExpr, void) // TODO (introduced in 5.8)
190192
MAP(swift::Decl, DeclTag)
191193
MAP(swift::ValueDecl, ValueDeclTag)
192194
MAP(swift::TypeDecl, TypeDeclTag)
@@ -196,11 +198,11 @@ MAP(swift::Decl, DeclTag)
196198
MAP(swift::StructDecl, StructDeclTag)
197199
MAP(swift::ClassDecl, ClassDeclTag)
198200
MAP(swift::ProtocolDecl, ProtocolDeclTag)
201+
MAP(swift::BuiltinTupleDecl, void) // TODO (introduced in 5.8)
199202
MAP(swift::OpaqueTypeDecl, OpaqueTypeDeclTag)
200203
MAP(swift::TypeAliasDecl, TypeAliasDeclTag)
201-
MAP(swift::AbstractTypeParamDecl, AbstractTypeParamDeclTag)
202-
MAP(swift::GenericTypeParamDecl, GenericTypeParamDeclTag)
203-
MAP(swift::AssociatedTypeDecl, AssociatedTypeDeclTag)
204+
MAP(swift::GenericTypeParamDecl, GenericTypeParamDeclTag)
205+
MAP(swift::AssociatedTypeDecl, AssociatedTypeDeclTag)
204206
MAP(swift::ModuleDecl, ModuleDeclTag)
205207
MAP(swift::AbstractStorageDecl, AbstractStorageDeclTag)
206208
MAP(swift::VarDecl, VarDeclTag)
@@ -213,6 +215,7 @@ MAP(swift::Decl, DeclTag)
213215
MAP(swift::FuncDecl, AccessorOrNamedFunctionTag)
214216
MAP_CONCRETE(swift::FuncDecl, NamedFunctionTag)
215217
MAP(swift::AccessorDecl, AccessorTag)
218+
MAP(swift::MacroDecl, void) // TODO (introduced in 5.8)
216219
MAP(swift::EnumElementDecl, EnumElementDeclTag)
217220
MAP(swift::ExtensionDecl, ExtensionDeclTag)
218221
MAP(swift::TopLevelCodeDecl, TopLevelCodeDeclTag)
@@ -227,6 +230,7 @@ MAP(swift::Decl, DeclTag)
227230
MAP(swift::InfixOperatorDecl, InfixOperatorDeclTag)
228231
MAP(swift::PrefixOperatorDecl, PrefixOperatorDeclTag)
229232
MAP(swift::PostfixOperatorDecl, PostfixOperatorDeclTag)
233+
MAP(swift::MacroExpansionDecl, void) // TODO (introduced in 5.8)
230234

231235
MAP(swift::Pattern, PatternTag)
232236
MAP(swift::ParenPattern, ParenPatternTag)
@@ -274,6 +278,7 @@ MAP(swift::TypeBase, TypeTag)
274278
MAP(swift::StructType, StructTypeTag)
275279
MAP(swift::ClassType, ClassTypeTag)
276280
MAP(swift::ProtocolType, ProtocolTypeTag)
281+
MAP(swift::BuiltinTupleType, void) // TODO (introduced in 5.8)
277282
MAP(swift::BoundGenericType, BoundGenericTypeTag)
278283
MAP(swift::BoundGenericClassType, BoundGenericClassTypeTag)
279284
MAP(swift::BoundGenericEnumType, BoundGenericEnumTypeTag)
@@ -288,8 +293,10 @@ MAP(swift::TypeBase, TypeTag)
288293
MAP(swift::ArchetypeType, ArchetypeTypeTag)
289294
MAP(swift::PrimaryArchetypeType, PrimaryArchetypeTypeTag)
290295
MAP(swift::OpaqueTypeArchetypeType, OpaqueTypeArchetypeTypeTag)
291-
MAP(swift::OpenedArchetypeType, OpenedArchetypeTypeTag)
292-
MAP(swift::SequenceArchetypeType, void) // experimental variadic generics
296+
MAP(swift::LocalArchetypeType, OpenedArchetypeTypeTag) // TODO (introduced in 5.8)
297+
MAP(swift::OpenedArchetypeType, OpenedArchetypeTypeTag)
298+
MAP(swift::ElementArchetypeType, void) // TODO (introduced in 5.8)
299+
MAP(swift::PackArchetypeType, void) // TODO (introduced in 5.8)
293300
MAP(swift::GenericTypeParamType, GenericTypeParamTypeTag)
294301
MAP(swift::DependentMemberType, DependentMemberTypeTag)
295302
MAP(swift::AnyFunctionType, AnyFunctionTypeTag)
@@ -298,6 +305,7 @@ MAP(swift::TypeBase, TypeTag)
298305
MAP(swift::SILFunctionType, void) // SIL types cannot really appear in the frontend run)
299306
MAP(swift::SILBlockStorageType, void) // SIL types cannot really appear in the frontend run)
300307
MAP(swift::SILBoxType, void) // SIL types cannot really appear in the frontend run)
308+
MAP(swift::SILMoveOnlyWrappedType, void) // SIL types cannot really appear in the frontend run)
301309
MAP(swift::SILTokenType, void) // SIL types cannot really appear in the frontend run)
302310
MAP(swift::ProtocolCompositionType, ProtocolCompositionTypeTag)
303311
MAP(swift::ParameterizedProtocolType, ParameterizedProtocolTypeTag)

swift/extractor/translators/ExprTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ codeql::ForceValueExpr ExprTranslator::translateForceValueExpr(const swift::Forc
403403
return entry;
404404
}
405405

406-
codeql::IfExpr ExprTranslator::translateIfExpr(const swift::IfExpr& expr) {
406+
codeql::IfExpr ExprTranslator::translateTernaryExpr(const swift::TernaryExpr& expr) {
407407
auto entry = createExprEntry(expr);
408408
entry.condition = dispatcher.fetchLabel(expr.getCondExpr());
409409
entry.then_expr = dispatcher.fetchLabel(expr.getThenExpr());

swift/extractor/translators/ExprTranslator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
9090
codeql::LazyInitializationExpr translateLazyInitializerExpr(
9191
const swift::LazyInitializerExpr& expr);
9292
codeql::ForceValueExpr translateForceValueExpr(const swift::ForceValueExpr& expr);
93-
codeql::IfExpr translateIfExpr(const swift::IfExpr& expr);
93+
codeql::IfExpr translateTernaryExpr(const swift::TernaryExpr& expr);
9494
codeql::KeyPathDotExpr translateKeyPathDotExpr(const swift::KeyPathDotExpr& expr);
9595
codeql::KeyPathApplicationExpr translateKeyPathApplicationExpr(
9696
const swift::KeyPathApplicationExpr& expr);

swift/ql/.generated.list

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/generated/expr/CaptureListExpr.qll

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/swift.dbscheme

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/test/library-tests/ast/PrintAst.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ cfg.swift:
24762476
# 377| Type = Derived
24772477
#-----| getParam(0): [ParamDecl] n
24782478
#-----| Type = Int
2479-
#-----| getBody(): [BraceStmt] { ... }
2479+
# 377| getBody(): [BraceStmt] { ... }
24802480
# 377| getElement(0): [CallExpr] call to _unimplementedInitializer(className:initName:file:line:column:)
24812481
# 377| getFunction(): [DeclRefExpr] _unimplementedInitializer(className:initName:file:line:column:)
24822482
# 377| getArgument(0): [Argument] : cfg.Derived
@@ -4769,7 +4769,7 @@ expressions.swift:
47694769
# 77| Type = Derived
47704770
#-----| getParam(0): [ParamDecl] x
47714771
#-----| Type = Int
4772-
#-----| getBody(): [BraceStmt] { ... }
4772+
# 77| getBody(): [BraceStmt] { ... }
47734773
# 77| getElement(0): [CallExpr] call to _unimplementedInitializer(className:initName:file:line:column:)
47744774
# 77| getFunction(): [DeclRefExpr] _unimplementedInitializer(className:initName:file:line:column:)
47754775
# 77| getArgument(0): [Argument] : expressions.Derived

swift/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class CapturedDecl(Decl):
399399

400400
class CaptureListExpr(Expr):
401401
binding_decls: list[PatternBindingDecl] | child
402-
closure_body: "ExplicitClosureExpr" | child
402+
closure_body: "ClosureExpr" | child
403403

404404
class CollectionExpr(Expr):
405405
pass

0 commit comments

Comments
 (0)