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

@@ -13,7 +13,7 @@ runs:
- uses: actions/setup-python@v4
with:
python-version-file: 'swift/.python-version'
- uses: swift-actions/setup-swift@da0e3e04b5e3e15dbc3861bd835ad9f0afe56296
- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf
with:
swift-version: "${{steps.get_swift_version.outputs.version}}"
- uses: ./.github/actions/fetch-codeql

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);

View File

@@ -383,7 +383,7 @@ lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0c6d
lib/codeql/swift/generated/ParentChild.qll 5c5ff9812efbed0adf465d1c8b9108c893c77ff946f6feaaec7223ad38664079 94038dcd8a5e98b959ce9f09b7b54b745b0df49b91339b9396017a209abe8bb7
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll f82d9ca416fe8bd59b5531b65b1c74c9f317b3297a6101544a11339a1cffce38 7f5c6d3309e66c134107afe55bae76dfc9a72cb7cdd6d4c3706b6b34cee09fa0
lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98
lib/codeql/swift/generated/Raw.qll 991f95f30bde82ba43237bd9c1a68d3f450038ef828edb89219fbf583dd1956a e3e6c41caac09d532453c28167622fae7057d846f35750873eacd48cd128b957
lib/codeql/swift/generated/Raw.qll 7904614a526f13c336402c38e8632c8ee32e0ee7a6b5a9c2ace22fab0a5927f8 273f958f5052ae025e7361dbfd6a7a505da5fa6b4f418e83aa2a1d5f8602c54d
lib/codeql/swift/generated/Synth.qll 551fdf7e4b53f9ee1314d1bb42c2638cf82f45bfa1f40a635dfa7b6072e4418c 9ab178464700a19951fc5285acacda4913addee81515d8e072b3d7055935a814
lib/codeql/swift/generated/SynthConstructors.qll 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4
lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6
@@ -450,7 +450,7 @@ lib/codeql/swift/generated/expr/BridgeFromObjCExpr.qll b9a6520d01613dfb8c7606177
lib/codeql/swift/generated/expr/BridgeToObjCExpr.qll 31ca13762aee9a6a17746f40ec4e1e929811c81fdadb27c48e0e7ce6a3a6222d 31ca13762aee9a6a17746f40ec4e1e929811c81fdadb27c48e0e7ce6a3a6222d
lib/codeql/swift/generated/expr/BuiltinLiteralExpr.qll 052f8d0e9109a0d4496da1ae2b461417951614c88dbc9d80220908734b3f70c6 536fa290bb75deae0517d53528237eab74664958bf7fdbf8041283415dda2142
lib/codeql/swift/generated/expr/CallExpr.qll c7dc105fcb6c0956e20d40f736db35bd7f38f41c3d872858972c2ca120110d36 c7dc105fcb6c0956e20d40f736db35bd7f38f41c3d872858972c2ca120110d36
lib/codeql/swift/generated/expr/CaptureListExpr.qll 671234408ead93c0d6abc453f774a88f0888956e6ad08d5a1c22aec72b2eec46 601e23e0356341fd6287fb9775f0e86bca6a0de46383e0912854e045e501d42c
lib/codeql/swift/generated/expr/CaptureListExpr.qll 300e3e7b60d49c321c9b6209ace7cd4665dc3db1b3f4227af476c3bdaf7da196 3ccc01074fa7cef8df1f2923fb3837af59360f5bd496ccbb5f0f77d02ac9311a
lib/codeql/swift/generated/expr/CheckedCastExpr.qll 146c24e72cda519676321d3bdb89d1953dfe1810d2710f04cfdc4210ace24c40 91093e0ba88ec3621b538d98454573b5eea6d43075a2ab0a08f80f9b9be336d3
lib/codeql/swift/generated/expr/ClassMetatypeToObjectExpr.qll 076c0f7369af3fffc8860429bd8e290962bf7fc8cf53bbba061de534e99cc8bf 076c0f7369af3fffc8860429bd8e290962bf7fc8cf53bbba061de534e99cc8bf
lib/codeql/swift/generated/expr/ClosureExpr.qll f194fc8c5f67fcf0219e8e2de93ee2b820c27a609b2986b68d57a54445f66b61 3cae87f6c6eefb32195f06bc4c95ff6634446ecf346d3a3c94dc05c1539f3de2

View File

@@ -1096,7 +1096,7 @@ module Raw {
/**
* Gets the closure body of this capture list expression.
*/
ExplicitClosureExpr getClosureBody() { capture_list_exprs(this, result) }
ClosureExpr getClosureBody() { capture_list_exprs(this, result) }
}
/**

View File

@@ -1,7 +1,7 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.expr.ExplicitClosureExpr
import codeql.swift.elements.expr.ClosureExpr
import codeql.swift.elements.expr.Expr
import codeql.swift.elements.decl.PatternBindingDecl
@@ -35,9 +35,9 @@ module Generated {
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
ExplicitClosureExpr getImmediateClosureBody() {
ClosureExpr getImmediateClosureBody() {
result =
Synth::convertExplicitClosureExprFromRaw(Synth::convertCaptureListExprToRaw(this)
Synth::convertClosureExprFromRaw(Synth::convertCaptureListExprToRaw(this)
.(Raw::CaptureListExpr)
.getClosureBody())
}
@@ -45,8 +45,8 @@ module Generated {
/**
* Gets the closure body of this capture list expression.
*/
final ExplicitClosureExpr getClosureBody() {
exists(ExplicitClosureExpr immediate |
final ClosureExpr getClosureBody() {
exists(ClosureExpr immediate |
immediate = this.getImmediateClosureBody() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)

View File

@@ -829,7 +829,7 @@ bind_optional_exprs( //dir=expr
capture_list_exprs( //dir=expr
unique int id: @capture_list_expr,
int closure_body: @explicit_closure_expr_or_none ref
int closure_body: @closure_expr_or_none ref
);
#keyset[id, index]
@@ -2457,6 +2457,11 @@ variadic_sequence_types( //dir=type
| @unspecified_element
;
@closure_expr_or_none =
@closure_expr
| @unspecified_element
;
@condition_element_or_none =
@condition_element
| @unspecified_element
@@ -2472,11 +2477,6 @@ variadic_sequence_types( //dir=type
| @unspecified_element
;
@explicit_closure_expr_or_none =
@explicit_closure_expr
| @unspecified_element
;
@expr_or_none =
@expr
| @unspecified_element

View File

@@ -2476,7 +2476,7 @@ cfg.swift:
# 377| Type = Derived
#-----| getParam(0): [ParamDecl] n
#-----| Type = Int
#-----| getBody(): [BraceStmt] { ... }
# 377| getBody(): [BraceStmt] { ... }
# 377| getElement(0): [CallExpr] call to _unimplementedInitializer(className:initName:file:line:column:)
# 377| getFunction(): [DeclRefExpr] _unimplementedInitializer(className:initName:file:line:column:)
# 377| getArgument(0): [Argument] : cfg.Derived
@@ -4769,7 +4769,7 @@ expressions.swift:
# 77| Type = Derived
#-----| getParam(0): [ParamDecl] x
#-----| Type = Int
#-----| getBody(): [BraceStmt] { ... }
# 77| getBody(): [BraceStmt] { ... }
# 77| getElement(0): [CallExpr] call to _unimplementedInitializer(className:initName:file:line:column:)
# 77| getFunction(): [DeclRefExpr] _unimplementedInitializer(className:initName:file:line:column:)
# 77| getArgument(0): [Argument] : expressions.Derived

View File

@@ -399,7 +399,7 @@ class CapturedDecl(Decl):
class CaptureListExpr(Expr):
binding_decls: list[PatternBindingDecl] | child
closure_body: "ExplicitClosureExpr" | child
closure_body: "ClosureExpr" | child
class CollectionExpr(Expr):
pass

View File

@@ -2,22 +2,7 @@ load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
cc_library(
name = "swift-llvm-support",
srcs = [
"libCodeQLSwiftFrontendTool.a",
] + select({
"@platforms//os:linux": [
"libCodeQLSwiftFrontendTool.so",
"libswiftCore.so",
],
"@platforms//os:macos": [
"libCodeQLSwiftFrontendTool.dylib",
"libswiftCore.dylib",
"libswiftCompatibility50.a",
"libswiftCompatibility51.a",
"libswiftCompatibilityConcurrency.a",
"libswiftCompatibilityDynamicReplacements.a",
],
}),
srcs = glob(["*.a", "*.so", "*.dylib"]),
hdrs = glob(["include/**/*", "stdlib/**/*" ]),
linkopts = [
"-lm",
@@ -34,7 +19,7 @@ cc_library(
],
"//conditions:default": [],
}),
includes = [ "include" ],
includes = ["include", "stdlib/public/SwiftShims"],
visibility = ["//visibility:public"],
)

View File

@@ -1,11 +1,11 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
_swift_prebuilt_version = "swift-5.7.3-RELEASE.142"
_swift_prebuilt_version = "swift-5.8.1-RELEASE.208"
_swift_sha_map = {
"Linux-X64": "398d8de54c8775c939dff95ed5bb0e04a9308a1982b4c1900cd4a5d01223f63b",
"macOS-ARM64": "397dd67ea99b9c9455794c6eb0f1664b6179fe542c7c1d3010314a3e8a905ae4",
"macOS-X64": "4b9d8e4e89f16a7c1e7edc7893aa189b37d5b4412be724a86ef59c49d11a6f75",
"Linux-X64": "1d93286d6219e5c5746938ab9287d90efea98039f022cb1433296ccbc1684bc0",
"macOS-ARM64": "a29ce5143cb2c68190e337a35ebb163e961a58b9d8826fe7f8daf4d8381ee75d",
"macOS-X64": "a7e63ea732750c783142083df20a34c8d337b9b9ba210fa6a9e5ada7b7880189",
}
_swift_arch_map = {