1212#include < swift/AST/Pattern.h>
1313#include < swift/AST/TypeRepr.h>
1414#include < swift/AST/Type.h>
15+ #include < swift/CodeQLSwiftVersion.h>
1516
1617namespace codeql {
1718
@@ -26,6 +27,9 @@ namespace codeql {
2627 using type = TAG; \
2728 };
2829
30+ #define CODEQL_SWIFT_VERSION_GE (MAJOR, MINOR ) \
31+ CODEQL_SWIFT_VERSION_MAJOR >= (MAJOR) && CODEQL_SWIFT_VERSION_MINOR >= (MINOR)
32+
2933// clang-format off
3034// use indentation to recreate all involved type hierarchies
3135MAP (std::filesystem::path, DbFileTag)
@@ -56,6 +60,9 @@ MAP(swift::Stmt, StmtTag)
5660 MAP (swift::FailStmt, FailStmtTag)
5761 MAP (swift::ThrowStmt, ThrowStmtTag)
5862 MAP (swift::PoundAssertStmt, PoundAssertStmtTag)
63+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
64+ MAP (swift::DiscardStmt, void ) // TODO (introduced in 5.9)
65+ #endif
5966
6067MAP (swift::Argument, ArgumentTag)
6168MAP (swift::KeyPathExpr::Component, KeyPathComponentTag)
@@ -95,7 +102,11 @@ MAP(swift::Expr, ExprTag)
95102 MAP (swift::IdentityExpr, IdentityExprTag)
96103 MAP (swift::ParenExpr, ParenExprTag)
97104 MAP (swift::DotSelfExpr, DotSelfExprTag)
98- MAP (swift::MoveExpr, void ) // TODO (introduced in 5.8)
105+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
106+ MAP (swift::BorrowExpr, void ) // TODO (introduced in 5.9)
107+ #else
108+ MAP (swift::MoveExpr, void ) // TODO (introduced in 5.8, gone in 5.9)
109+ #endif
99110 MAP (swift::AwaitExpr, AwaitExprTag)
100111 MAP (swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag)
101112 MAP (swift::AnyTryExpr, AnyTryExprTag)
@@ -189,6 +200,13 @@ MAP(swift::Expr, ExprTag)
189200 MAP (swift::TapExpr, TapExprTag)
190201 MAP (swift::TypeJoinExpr, void ) // TODO (introduced in 5.8)
191202 MAP (swift::MacroExpansionExpr, void ) // TODO (introduced in 5.8)
203+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
204+ MAP (swift::CopyExpr, void ) // TODO (introduced in 5.9)
205+ MAP(swift::ConsumeExpr, void ) // TODO (introduced in 5.9)
206+ MAP(swift::MaterializePackExpr, void ) // TODO (introduced in 5.9)
207+ MAP(swift::SingleValueStmtExpr, void ) // TODO (introduced in 5.9)
208+ #endif
209+
192210MAP (swift::Decl, DeclTag)
193211 MAP (swift::ValueDecl, ValueDeclTag)
194212 MAP (swift::TypeDecl, TypeDeclTag)
@@ -231,6 +249,9 @@ MAP(swift::Decl, DeclTag)
231249 MAP (swift::PrefixOperatorDecl, PrefixOperatorDeclTag)
232250 MAP (swift::PostfixOperatorDecl, PostfixOperatorDeclTag)
233251 MAP (swift::MacroExpansionDecl, void ) // TODO (introduced in 5.8)
252+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
253+ MAP (swift::MissingDecl, void ) // TODO (introduced in 5.9)
254+ #endif
234255
235256MAP (swift::Pattern, PatternTag)
236257 MAP (swift::ParenPattern, ParenPatternTag)
@@ -266,6 +287,10 @@ MAP(swift::TypeBase, TypeTag)
266287 MAP (swift::BuiltinUnsafeValueBufferType, BuiltinUnsafeValueBufferTypeTag)
267288 MAP (swift::BuiltinDefaultActorStorageType, BuiltinDefaultActorStorageTypeTag)
268289 MAP (swift::BuiltinVectorType, BuiltinVectorTypeTag)
290+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
291+ MAP (swift::BuiltinPackIndexType, void ) // TODO: (introduced in 5.9)
292+ MAP(swift::BuiltinNonDefaultDistributedActorStorageType, void ) // TODO: (introduced in 5.9)
293+ #endif
269294 MAP (swift::TupleType, TupleTypeTag)
270295 MAP (swift::ReferenceStorageType, ReferenceStorageTypeTag)
271296 MAP (swift::WeakStorageType, WeakStorageTypeTag)
@@ -307,13 +332,19 @@ MAP(swift::TypeBase, TypeTag)
307332 MAP (swift::SILBoxType, void ) // SIL types cannot really appear in the frontend run)
308333 MAP (swift::SILMoveOnlyWrappedType, void ) // SIL types cannot really appear in the frontend run)
309334 MAP (swift::SILTokenType, void ) // SIL types cannot really appear in the frontend run)
335+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
336+ MAP (swift::SILPackType, void ) // TODO: (introduced in 5.9)
337+ #endif
310338 MAP (swift::ProtocolCompositionType, ProtocolCompositionTypeTag)
311339 MAP (swift::ParameterizedProtocolType, ParameterizedProtocolTypeTag)
312340 MAP (swift::ExistentialType, ExistentialTypeTag)
313341 MAP (swift::LValueType, LValueTypeTag)
314342 MAP (swift::InOutType, InOutTypeTag)
315343 MAP (swift::PackType, void ) // experimental variadic generics
316344 MAP (swift::PackExpansionType, void ) // experimental variadic generics
345+ #if CODEQL_SWIFT_VERSION_GE(5, 9)
346+ MAP (swift::PackElementType, void ) // TODO: (introduced in 5.9)
347+ #endif
317348 MAP (swift::TypeVariableType, void ) // created during type checking and only used for constraint checking
318349 MAP (swift::SugarType, SugarTypeTag)
319350 MAP (swift::ParenType, ParenTypeTag)
0 commit comments