Swift: minimal 5.8 compatibility

This commit is contained in:
Paolo Tranquilli
2023-04-06 17:27:24 +02:00
committed by Alex Denisov
parent e8b12ce416
commit 396b57696c
12 changed files with 43 additions and 50 deletions

View File

@@ -95,6 +95,7 @@ MAP(swift::Expr, ExprTag)
MAP(swift::IdentityExpr, IdentityExprTag)
MAP(swift::ParenExpr, ParenExprTag)
MAP(swift::DotSelfExpr, DotSelfExprTag)
MAP(swift::MoveExpr, void) // TODO (introduced in 5.8)
MAP(swift::AwaitExpr, AwaitExprTag)
MAP(swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag)
MAP(swift::AnyTryExpr, AnyTryExprTag)
@@ -113,6 +114,8 @@ MAP(swift::Expr, ExprTag)
MAP(swift::AutoClosureExpr, AutoClosureExprTag)
MAP(swift::InOutExpr, InOutExprTag)
MAP(swift::VarargExpansionExpr, VarargExpansionExprTag)
MAP(swift::PackExpansionExpr, void) // TODO (introduced in 5.8)
MAP(swift::PackElementExpr, void) // TODO (introduced in 5.8)
MAP(swift::DynamicTypeExpr, DynamicTypeExprTag)
MAP(swift::RebindSelfInConstructorExpr, RebindSelfInInitializerExprTag)
MAP(swift::OpaqueValueExpr, OpaqueValueExprTag)
@@ -164,7 +167,6 @@ MAP(swift::Expr, ExprTag)
MAP(swift::DifferentiableFunctionExtractOriginalExpr, DifferentiableFunctionExtractOriginalExprTag)
MAP(swift::LinearFunctionExtractOriginalExpr, LinearFunctionExtractOriginalExprTag)
MAP(swift::LinearToDifferentiableFunctionExpr, LinearToDifferentiableFunctionExprTag)
MAP(swift::ReifyPackExpr, void) // experimental variadic generics
MAP(swift::ABISafeConversionExpr, AbiSafeConversionExprTag) // different acronym convention
MAP(swift::ExplicitCastExpr, ExplicitCastExprTag)
MAP(swift::CheckedCastExpr, CheckedCastExprTag)
@@ -173,7 +175,7 @@ MAP(swift::Expr, ExprTag)
MAP(swift::IsExpr, IsExprTag)
MAP(swift::CoerceExpr, CoerceExprTag)
MAP(swift::ArrowExpr, void) // not present after the Sema phase
MAP(swift::IfExpr, IfExprTag)
MAP(swift::TernaryExpr, IfExprTag)
MAP(swift::EnumIsCaseExpr, EnumIsCaseExprTag)
MAP(swift::AssignExpr, AssignExprTag)
MAP(swift::CodeCompletionExpr, void) // only generated for code editing
@@ -185,8 +187,8 @@ MAP(swift::Expr, ExprTag)
MAP(swift::KeyPathDotExpr, KeyPathDotExprTag)
MAP(swift::OneWayExpr, OneWayExprTag)
MAP(swift::TapExpr, TapExprTag)
MAP(swift::PackExpr, void) // experimental variadic generics
MAP(swift::TypeJoinExpr, void) // TODO (introduced in 5.8)
MAP(swift::MacroExpansionExpr, void) // TODO (introduced in 5.8)
MAP(swift::Decl, DeclTag)
MAP(swift::ValueDecl, ValueDeclTag)
MAP(swift::TypeDecl, TypeDeclTag)
@@ -196,11 +198,11 @@ MAP(swift::Decl, DeclTag)
MAP(swift::StructDecl, StructDeclTag)
MAP(swift::ClassDecl, ClassDeclTag)
MAP(swift::ProtocolDecl, ProtocolDeclTag)
MAP(swift::BuiltinTupleDecl, void) // TODO (introduced in 5.8)
MAP(swift::OpaqueTypeDecl, OpaqueTypeDeclTag)
MAP(swift::TypeAliasDecl, TypeAliasDeclTag)
MAP(swift::AbstractTypeParamDecl, AbstractTypeParamDeclTag)
MAP(swift::GenericTypeParamDecl, GenericTypeParamDeclTag)
MAP(swift::AssociatedTypeDecl, AssociatedTypeDeclTag)
MAP(swift::GenericTypeParamDecl, GenericTypeParamDeclTag)
MAP(swift::AssociatedTypeDecl, AssociatedTypeDeclTag)
MAP(swift::ModuleDecl, ModuleDeclTag)
MAP(swift::AbstractStorageDecl, AbstractStorageDeclTag)
MAP(swift::VarDecl, VarDeclTag)
@@ -213,6 +215,7 @@ MAP(swift::Decl, DeclTag)
MAP(swift::FuncDecl, AccessorOrNamedFunctionTag)
MAP_CONCRETE(swift::FuncDecl, NamedFunctionTag)
MAP(swift::AccessorDecl, AccessorTag)
MAP(swift::MacroDecl, void) // TODO (introduced in 5.8)
MAP(swift::EnumElementDecl, EnumElementDeclTag)
MAP(swift::ExtensionDecl, ExtensionDeclTag)
MAP(swift::TopLevelCodeDecl, TopLevelCodeDeclTag)
@@ -227,6 +230,7 @@ MAP(swift::Decl, DeclTag)
MAP(swift::InfixOperatorDecl, InfixOperatorDeclTag)
MAP(swift::PrefixOperatorDecl, PrefixOperatorDeclTag)
MAP(swift::PostfixOperatorDecl, PostfixOperatorDeclTag)
MAP(swift::MacroExpansionDecl, void) // TODO (introduced in 5.8)
MAP(swift::Pattern, PatternTag)
MAP(swift::ParenPattern, ParenPatternTag)
@@ -274,6 +278,7 @@ MAP(swift::TypeBase, TypeTag)
MAP(swift::StructType, StructTypeTag)
MAP(swift::ClassType, ClassTypeTag)
MAP(swift::ProtocolType, ProtocolTypeTag)
MAP(swift::BuiltinTupleType, void) // TODO (introduced in 5.8)
MAP(swift::BoundGenericType, BoundGenericTypeTag)
MAP(swift::BoundGenericClassType, BoundGenericClassTypeTag)
MAP(swift::BoundGenericEnumType, BoundGenericEnumTypeTag)
@@ -288,8 +293,10 @@ MAP(swift::TypeBase, TypeTag)
MAP(swift::ArchetypeType, ArchetypeTypeTag)
MAP(swift::PrimaryArchetypeType, PrimaryArchetypeTypeTag)
MAP(swift::OpaqueTypeArchetypeType, OpaqueTypeArchetypeTypeTag)
MAP(swift::OpenedArchetypeType, OpenedArchetypeTypeTag)
MAP(swift::SequenceArchetypeType, void) // experimental variadic generics
MAP(swift::LocalArchetypeType, OpenedArchetypeTypeTag) // TODO (introduced in 5.8)
MAP(swift::OpenedArchetypeType, OpenedArchetypeTypeTag)
MAP(swift::ElementArchetypeType, void) // TODO (introduced in 5.8)
MAP(swift::PackArchetypeType, void) // TODO (introduced in 5.8)
MAP(swift::GenericTypeParamType, GenericTypeParamTypeTag)
MAP(swift::DependentMemberType, DependentMemberTypeTag)
MAP(swift::AnyFunctionType, AnyFunctionTypeTag)
@@ -298,6 +305,7 @@ MAP(swift::TypeBase, TypeTag)
MAP(swift::SILFunctionType, void) // SIL types cannot really appear in the frontend run)
MAP(swift::SILBlockStorageType, void) // SIL types cannot really appear in the frontend run)
MAP(swift::SILBoxType, void) // SIL types cannot really appear in the frontend run)
MAP(swift::SILMoveOnlyWrappedType, void) // SIL types cannot really appear in the frontend run)
MAP(swift::SILTokenType, void) // SIL types cannot really appear in the frontend run)
MAP(swift::ProtocolCompositionType, ProtocolCompositionTypeTag)
MAP(swift::ParameterizedProtocolType, ParameterizedProtocolTypeTag)

View File

@@ -403,7 +403,7 @@ codeql::ForceValueExpr ExprTranslator::translateForceValueExpr(const swift::Forc
return entry;
}
codeql::IfExpr ExprTranslator::translateIfExpr(const swift::IfExpr& expr) {
codeql::IfExpr ExprTranslator::translateTernaryExpr(const swift::TernaryExpr& expr) {
auto entry = createExprEntry(expr);
entry.condition = dispatcher.fetchLabel(expr.getCondExpr());
entry.then_expr = dispatcher.fetchLabel(expr.getThenExpr());

View File

@@ -90,7 +90,7 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
codeql::LazyInitializationExpr translateLazyInitializerExpr(
const swift::LazyInitializerExpr& expr);
codeql::ForceValueExpr translateForceValueExpr(const swift::ForceValueExpr& expr);
codeql::IfExpr translateIfExpr(const swift::IfExpr& expr);
codeql::IfExpr translateTernaryExpr(const swift::TernaryExpr& expr);
codeql::KeyPathDotExpr translateKeyPathDotExpr(const swift::KeyPathDotExpr& expr);
codeql::KeyPathApplicationExpr translateKeyPathApplicationExpr(
const swift::KeyPathApplicationExpr& expr);