mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge remote-tracking branch 'origin/rc/3.10' into alexdenisov/rc3.10_mergeback
This commit is contained in:
@@ -64,6 +64,13 @@ pkg_runfiles(
|
||||
prefix = "tools/" + codeql_platform,
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "resource-dir-arch",
|
||||
srcs = ["//swift/third_party/swift-llvm-support:swift-resource-dir"],
|
||||
prefix = "resource-dir/" + codeql_platform,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "swift-test-sdk-arch",
|
||||
srcs = ["//swift/third_party/swift-llvm-support:swift-test-sdk"],
|
||||
@@ -76,6 +83,7 @@ pkg_filegroup(
|
||||
srcs = [
|
||||
":extractor",
|
||||
":swift-test-sdk-arch",
|
||||
":resource-dir-arch",
|
||||
] + select({
|
||||
"@platforms//os:linux": [
|
||||
":incompatible-os",
|
||||
|
||||
@@ -44,10 +44,10 @@ runs:
|
||||
mkdir -p bazel-cache/{repository,disk}
|
||||
echo build --repository_cache=bazel-cache/repository --disk_cache=bazel-cache/disk > local.bazelrc
|
||||
echo test --test_output=errors >> local.bazelrc
|
||||
- name: Print unextracted entities
|
||||
shell: bash
|
||||
run: |
|
||||
bazel run //swift/extractor/print_unextracted
|
||||
# - name: Print unextracted entities
|
||||
# shell: bash
|
||||
# run: |
|
||||
# bazel run //swift/extractor/print_unextracted
|
||||
- uses: ./swift/actions/share-extractor-pack
|
||||
- name: Build Swift extractor
|
||||
shell: bash
|
||||
|
||||
@@ -4,18 +4,12 @@ runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: ./swift/actions/share-extractor-pack
|
||||
- name: Get Swift version
|
||||
id: get_swift_version
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION=$(swift/extractor-pack/tools/*/extractor --version | awk '/version/ { print $3 }')
|
||||
echo "version=$VERSION" | tee -a $GITHUB_OUTPUT
|
||||
- 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}}"
|
||||
swift-version: "5.8"
|
||||
- uses: ./.github/actions/fetch-codeql
|
||||
- id: query-cache
|
||||
uses: ./.github/actions/cache-query-compilation
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
class Element extends @element {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
newtype TAddedUnspecifiedElement =
|
||||
TNonExplicitClosureExprClosureBody(Element list, Element body) {
|
||||
capture_list_exprs(list, body) and not explicit_closure_exprs(body)
|
||||
}
|
||||
|
||||
module Fresh = QlBuiltins::NewEntity<TAddedUnspecifiedElement>;
|
||||
|
||||
class TNewElement = @element or Fresh::EntityId;
|
||||
|
||||
class NewElement extends TNewElement {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
query predicate new_unspecified_elements(NewElement u, string property, string error) {
|
||||
unspecified_elements(u, property, error)
|
||||
or
|
||||
u = Fresh::map(TNonExplicitClosureExprClosureBody(_, _)) and
|
||||
property = "closure_body" and
|
||||
error = "while downgrading: closure_body not an @explicit_closure_expr"
|
||||
}
|
||||
|
||||
query predicate new_unspecified_element_parents(NewElement u, Element parent) {
|
||||
unspecified_element_parents(u, parent)
|
||||
or
|
||||
u = Fresh::map(TNonExplicitClosureExprClosureBody(parent, _))
|
||||
}
|
||||
|
||||
query predicate new_capture_list_exprs(Element list, NewElement body) {
|
||||
capture_list_exprs(list, body) and explicit_closure_exprs(body)
|
||||
or
|
||||
body = Fresh::map(TNonExplicitClosureExprClosureBody(list, _))
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
description: Revert making closure_body have type @abstract_closure_expr
|
||||
compatibility: backwards
|
||||
unspecified_elements.rel: run downgrade.qlo new_unspecified_elements
|
||||
unspecified_element_parents.rel: run downgrade.qlo new_unspecified_element_parents
|
||||
capture_list_exprs.rel: run downgrade.qlo new_capture_list_exprs
|
||||
@@ -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)
|
||||
|
||||
@@ -174,7 +174,9 @@ codeql::TrapDomain invocationTrapDomain(codeql::SwiftExtractorState& state) {
|
||||
return std::move(maybeDomain.value());
|
||||
}
|
||||
|
||||
codeql::SwiftExtractorConfiguration configure(int argc, char** argv) {
|
||||
codeql::SwiftExtractorConfiguration configure(int argc,
|
||||
char** argv,
|
||||
const std::string& resourceDir) {
|
||||
codeql::SwiftExtractorConfiguration configuration{};
|
||||
configuration.trapDir = getenv_or("CODEQL_EXTRACTOR_SWIFT_TRAP_DIR", "extractor-out/trap/swift");
|
||||
configuration.sourceArchiveDir =
|
||||
@@ -182,6 +184,13 @@ codeql::SwiftExtractorConfiguration configure(int argc, char** argv) {
|
||||
configuration.scratchDir =
|
||||
getenv_or("CODEQL_EXTRACTOR_SWIFT_SCRATCH_DIR", "extractor-out/working");
|
||||
configuration.frontendOptions.assign(argv + 1, argv + argc);
|
||||
// TODO: Should be moved to the tracer config
|
||||
for (int i = 0; i < argc - 1; i++) {
|
||||
if (std::string("-resource-dir") == configuration.frontendOptions[i]) {
|
||||
configuration.frontendOptions[i + 1] = resourceDir.c_str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@@ -214,7 +223,9 @@ int main(int argc, char** argv, char** envp) {
|
||||
INITIALIZE_LLVM();
|
||||
initializeSwiftModules();
|
||||
|
||||
const auto configuration = configure(argc, argv);
|
||||
std::string resourceDir = getenv_or("CODEQL_EXTRACTOR_SWIFT_ROOT", ".") + "/resource-dir/" +
|
||||
getenv_or("CODEQL_PLATFORM", ".");
|
||||
const auto configuration = configure(argc, argv, resourceDir);
|
||||
LOG_INFO("calling extractor with arguments \"{}\"", argDump(argc, argv));
|
||||
LOG_DEBUG("environment:\n{}\n", envDump(envp));
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
4
swift/ql/.generated.list
generated
4
swift/ql/.generated.list
generated
@@ -383,7 +383,7 @@ lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0c6d
|
||||
lib/codeql/swift/generated/ParentChild.qll f8647fba02b9acca7bf2870dfaee5709e2d3e3a12d27b012dd1e17f7df2e56e5 75d3501c2a59d931dd537321475687a73ff517e5caaae4ce2e0c2daec0d94df4
|
||||
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
|
||||
|
||||
2
swift/ql/lib/codeql/swift/generated/Raw.qll
generated
2
swift/ql/lib/codeql/swift/generated/Raw.qll
generated
@@ -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) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
|
||||
12
swift/ql/lib/swift.dbscheme
generated
12
swift/ql/lib/swift.dbscheme
generated
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: New entities added
|
||||
compatibility: full
|
||||
@@ -1,5 +1,6 @@
|
||||
import swift
|
||||
import TestUtils
|
||||
|
||||
from Locatable e
|
||||
where e instanceof ErrorElement
|
||||
where e instanceof ErrorElement and toBeTested(e)
|
||||
select e, e.getPrimaryQlClasses()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
| functions.swift:5:1:7:1 | bar(_:d:) | 0 | functions.swift:5:10:5:15 | x |
|
||||
| functions.swift:5:1:7:1 | bar(_:d:) | 1 | functions.swift:5:20:5:25 | y |
|
||||
| functions.swift:10:5:10:28 | noBody(x:) | 0 | functions.swift:10:17:10:20 | x |
|
||||
| functions.swift:13:1:15:1 | variadic(_:) | 0 | functions.swift:13:15:13:23 | ints |
|
||||
| functions.swift:13:1:15:1 | variadic(_:) | 0 | functions.swift:13:15:13:26 | ints |
|
||||
| functions.swift:17:1:19:1 | generic(x:y:) | 0 | functions.swift:17:20:17:23 | x |
|
||||
| functions.swift:17:1:19:1 | generic(x:y:) | 1 | functions.swift:17:26:17:29 | y |
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
doubleIndexes
|
||||
| method_lookups.swift:44:13:44:13 | [AutoClosureExpr] { ... } | 2 | getParam(0) | 4 | getParam(1) | file://:0:0:0:0 | [ParamDecl] argument |
|
||||
| method_lookups.swift:44:13:44:13 | [AutoClosureExpr] { ... } | 4 | getParam(1) | 2 | getParam(0) | file://:0:0:0:0 | [ParamDecl] argument |
|
||||
| method_lookups.swift:44:11:44:13 | [AutoClosureExpr] { ... } | 2 | getParam(0) | 4 | getParam(1) | file://:0:0:0:0 | [ParamDecl] argument |
|
||||
| method_lookups.swift:44:11:44:13 | [AutoClosureExpr] { ... } | 4 | getParam(1) | 2 | getParam(0) | file://:0:0:0:0 | [ParamDecl] argument |
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
| method_lookups.swift:33:3:33:5 | .bar() | hasType: | yes | getBase: | method_lookups.swift:33:3:33:3 | X.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:33:5:33:5 | bar() |
|
||||
| method_lookups.swift:34:3:34:3 | X.init() | hasType: | yes | getBase: | method_lookups.swift:34:3:34:3 | X.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:34:3:34:3 | X.init() |
|
||||
| method_lookups.swift:34:3:34:7 | .baz(_:) | hasType: | yes | getBase: | method_lookups.swift:34:3:34:5 | call to X.init() | hasMember: | yes | getMethodRef: | method_lookups.swift:34:7:34:7 | baz(_:) |
|
||||
| method_lookups.swift:36:11:36:13 | (no string representation) | hasType: | yes | getBase: | method_lookups.swift:36:11:36:11 | X.Type | hasMember: | no | getMethodRef: | method_lookups.swift:36:13:36:13 | { ... } |
|
||||
| method_lookups.swift:36:13:36:13 | .bar() | hasType: | yes | getBase: | file://:0:0:0:0 | self | hasMember: | yes | getMethodRef: | method_lookups.swift:36:13:36:13 | bar() |
|
||||
| method_lookups.swift:36:11:36:13 | .bar() | hasType: | yes | getBase: | method_lookups.swift:36:11:36:11 | X.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:36:13:36:13 | bar() |
|
||||
| method_lookups.swift:37:11:37:11 | X.init() | hasType: | yes | getBase: | method_lookups.swift:37:11:37:11 | X.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:37:11:37:11 | X.init() |
|
||||
| method_lookups.swift:37:11:37:15 | (no string representation) | hasType: | yes | getBase: | method_lookups.swift:37:11:37:13 | call to X.init() | hasMember: | no | getMethodRef: | method_lookups.swift:37:15:37:15 | { ... } |
|
||||
| method_lookups.swift:37:15:37:15 | .baz(_:) | hasType: | yes | getBase: | file://:0:0:0:0 | self | hasMember: | yes | getMethodRef: | method_lookups.swift:37:15:37:15 | baz(_:) |
|
||||
@@ -18,15 +17,13 @@
|
||||
| method_lookups.swift:41:3:41:5 | .foo(_:_:) | hasType: | yes | getBase: | method_lookups.swift:41:3:41:3 | Y.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:41:5:41:5 | foo(_:_:) |
|
||||
| method_lookups.swift:42:9:42:9 | Y.init() | hasType: | yes | getBase: | method_lookups.swift:42:9:42:9 | Y.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:42:9:42:9 | Y.init() |
|
||||
| method_lookups.swift:42:9:42:13 | .baz(_:) | hasType: | yes | getBase: | method_lookups.swift:42:9:42:11 | call to Y.init() | hasMember: | yes | getMethodRef: | method_lookups.swift:42:13:42:13 | baz(_:) |
|
||||
| method_lookups.swift:44:11:44:13 | (no string representation) | hasType: | yes | getBase: | method_lookups.swift:44:11:44:11 | Y.Type | hasMember: | no | getMethodRef: | method_lookups.swift:44:13:44:13 | { ... } |
|
||||
| method_lookups.swift:44:13:44:13 | .foo(_:_:) | hasType: | yes | getBase: | file://:0:0:0:0 | self | hasMember: | yes | getMethodRef: | method_lookups.swift:44:13:44:13 | foo(_:_:) |
|
||||
| method_lookups.swift:44:11:44:13 | .foo(_:_:) | hasType: | yes | getBase: | method_lookups.swift:44:11:44:11 | Y.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:44:13:44:13 | foo(_:_:) |
|
||||
| method_lookups.swift:47:1:47:1 | Task<Success, Never>.init(priority:operation:) | hasType: | yes | getBase: | method_lookups.swift:47:1:47:1 | Task<(), Never>.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:47:1:47:1 | Task<Success, Never>.init(priority:operation:) |
|
||||
| method_lookups.swift:48:9:48:11 | .foo(_:_:) | hasType: | yes | getBase: | method_lookups.swift:48:9:48:9 | Z.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:48:11:48:11 | foo(_:_:) |
|
||||
| method_lookups.swift:49:9:49:11 | .bar() | hasType: | yes | getBase: | method_lookups.swift:49:9:49:9 | Z.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:49:11:49:11 | bar() |
|
||||
| method_lookups.swift:50:9:50:9 | Z.init() | hasType: | yes | getBase: | method_lookups.swift:50:9:50:9 | Z.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:50:9:50:9 | Z.init() |
|
||||
| method_lookups.swift:50:9:50:13 | .baz(_:) | hasType: | yes | getBase: | method_lookups.swift:50:9:50:11 | call to Z.init() | hasMember: | yes | getMethodRef: | method_lookups.swift:50:13:50:13 | baz(_:) |
|
||||
| method_lookups.swift:52:11:52:13 | (no string representation) | hasType: | yes | getBase: | method_lookups.swift:52:11:52:11 | Z.Type | hasMember: | no | getMethodRef: | method_lookups.swift:52:13:52:13 | { ... } |
|
||||
| method_lookups.swift:52:13:52:13 | .bar() | hasType: | yes | getBase: | file://:0:0:0:0 | self | hasMember: | yes | getMethodRef: | method_lookups.swift:52:13:52:13 | bar() |
|
||||
| method_lookups.swift:52:11:52:13 | .bar() | hasType: | yes | getBase: | method_lookups.swift:52:11:52:11 | Z.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:52:13:52:13 | bar() |
|
||||
| method_lookups.swift:53:11:53:23 | (no string representation) | hasType: | yes | getBase: | method_lookups.swift:53:18:53:20 | call to Z.init() | hasMember: | no | getMethodRef: | method_lookups.swift:53:23:53:23 | { ... } |
|
||||
| method_lookups.swift:53:18:53:18 | Z.init() | hasType: | yes | getBase: | method_lookups.swift:53:18:53:18 | Z.Type | hasMember: | yes | getMethodRef: | method_lookups.swift:53:18:53:18 | Z.init() |
|
||||
| method_lookups.swift:53:23:53:23 | .baz(_:) | hasType: | yes | getBase: | file://:0:0:0:0 | self | hasMember: | yes | getMethodRef: | method_lookups.swift:53:23:53:23 | baz(_:) |
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
| method_lookups.swift:33:3:33:5 | .bar() | method_lookups.swift:3:3:3:21 | bar() |
|
||||
| method_lookups.swift:34:3:34:3 | X.init() | method_lookups.swift:6:3:8:3 | X.init() |
|
||||
| method_lookups.swift:34:3:34:7 | .baz(_:) | method_lookups.swift:4:3:4:21 | baz(_:) |
|
||||
| method_lookups.swift:36:13:36:13 | .bar() | method_lookups.swift:3:3:3:21 | bar() |
|
||||
| method_lookups.swift:36:11:36:13 | .bar() | method_lookups.swift:3:3:3:21 | bar() |
|
||||
| method_lookups.swift:37:11:37:11 | X.init() | method_lookups.swift:6:3:8:3 | X.init() |
|
||||
| method_lookups.swift:37:15:37:15 | .baz(_:) | method_lookups.swift:4:3:4:21 | baz(_:) |
|
||||
| method_lookups.swift:40:1:40:1 | Task<Success, Never>.init(priority:operation:) | file://:0:0:0:0 | Task<Success, Never>.init(priority:operation:) |
|
||||
| method_lookups.swift:41:3:41:5 | .foo(_:_:) | method_lookups.swift:12:3:12:35 | foo(_:_:) |
|
||||
| method_lookups.swift:42:9:42:9 | Y.init() | method_lookups.swift:15:3:17:3 | Y.init() |
|
||||
| method_lookups.swift:42:9:42:13 | .baz(_:) | method_lookups.swift:13:3:13:21 | baz(_:) |
|
||||
| method_lookups.swift:44:13:44:13 | .foo(_:_:) | method_lookups.swift:12:3:12:35 | foo(_:_:) |
|
||||
| method_lookups.swift:44:11:44:13 | .foo(_:_:) | method_lookups.swift:12:3:12:35 | foo(_:_:) |
|
||||
| method_lookups.swift:47:1:47:1 | Task<Success, Never>.init(priority:operation:) | file://:0:0:0:0 | Task<Success, Never>.init(priority:operation:) |
|
||||
| method_lookups.swift:48:9:48:11 | .foo(_:_:) | method_lookups.swift:22:3:22:35 | foo(_:_:) |
|
||||
| method_lookups.swift:49:9:49:11 | .bar() | method_lookups.swift:23:3:23:21 | bar() |
|
||||
| method_lookups.swift:50:9:50:9 | Z.init() | method_lookups.swift:26:3:28:3 | Z.init() |
|
||||
| method_lookups.swift:50:9:50:13 | .baz(_:) | method_lookups.swift:24:3:24:21 | baz(_:) |
|
||||
| method_lookups.swift:52:13:52:13 | .bar() | method_lookups.swift:23:3:23:21 | bar() |
|
||||
| method_lookups.swift:52:11:52:13 | .bar() | method_lookups.swift:23:3:23:21 | bar() |
|
||||
| method_lookups.swift:53:18:53:18 | Z.init() | method_lookups.swift:26:3:28:3 | Z.init() |
|
||||
| method_lookups.swift:53:23:53:23 | .baz(_:) | method_lookups.swift:24:3:24:21 | baz(_:) |
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
| method_lookups.swift:33:3:33:5 | .bar() | () -> () |
|
||||
| method_lookups.swift:34:3:34:3 | X.init() | () -> X |
|
||||
| method_lookups.swift:34:3:34:7 | .baz(_:) | (Int) -> () |
|
||||
| method_lookups.swift:36:11:36:13 | (no string representation) | () -> () |
|
||||
| method_lookups.swift:36:13:36:13 | .bar() | () -> () |
|
||||
| method_lookups.swift:36:11:36:13 | .bar() | () -> () |
|
||||
| method_lookups.swift:37:11:37:11 | X.init() | () -> X |
|
||||
| method_lookups.swift:37:11:37:15 | (no string representation) | (Int) -> () |
|
||||
| method_lookups.swift:37:15:37:15 | .baz(_:) | (Int) -> () |
|
||||
@@ -18,15 +17,13 @@
|
||||
| method_lookups.swift:41:3:41:5 | .foo(_:_:) | (Int, Int) -> () |
|
||||
| method_lookups.swift:42:9:42:9 | Y.init() | () -> Y |
|
||||
| method_lookups.swift:42:9:42:13 | .baz(_:) | (Int) -> () |
|
||||
| method_lookups.swift:44:11:44:13 | (no string representation) | (Int, Int) -> () |
|
||||
| method_lookups.swift:44:13:44:13 | .foo(_:_:) | (Int, Int) -> () |
|
||||
| method_lookups.swift:44:11:44:13 | .foo(_:_:) | (Int, Int) -> () |
|
||||
| method_lookups.swift:47:1:47:1 | Task<Success, Never>.init(priority:operation:) | (TaskPriority?, __owned @escaping @Sendable () async -> ()) -> Task<(), Never> |
|
||||
| method_lookups.swift:48:9:48:11 | .foo(_:_:) | @MainActor (Int, Int) -> () |
|
||||
| method_lookups.swift:49:9:49:11 | .bar() | @MainActor () -> () |
|
||||
| method_lookups.swift:50:9:50:9 | Z.init() | @MainActor () -> Z |
|
||||
| method_lookups.swift:50:9:50:13 | .baz(_:) | @MainActor (Int) -> () |
|
||||
| method_lookups.swift:52:11:52:13 | (no string representation) | @MainActor () -> () |
|
||||
| method_lookups.swift:52:13:52:13 | .bar() | () -> () |
|
||||
| method_lookups.swift:52:11:52:13 | .bar() | () -> () |
|
||||
| method_lookups.swift:53:11:53:23 | (no string representation) | @MainActor (Int) -> () |
|
||||
| method_lookups.swift:53:18:53:18 | Z.init() | @MainActor () -> Z |
|
||||
| method_lookups.swift:53:23:53:23 | .baz(_:) | (Int) -> () |
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
| run_under: $CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor -sdk $CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk -c -primary-file filtered_in.swift |
|
||||
| run_under: $CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor -sdk $CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk -c -primary-file unfiltered.swift |
|
||||
| run_under: $CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor -sdk $CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk -resource-dir $CODEQL_EXTRACTOR_SWIFT_ROOT/resource-dir/$CODEQL_PLATFORM -c -primary-file filtered_in.swift |
|
||||
| run_under: $CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor -sdk $CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk -resource-dir $CODEQL_EXTRACTOR_SWIFT_ROOT/resource-dir/$CODEQL_PLATFORM -c -primary-file unfiltered.swift |
|
||||
|
||||
256
swift/ql/test/extractor-tests/updates/PrintAst.expected
Normal file
256
swift/ql/test/extractor-tests/updates/PrintAst.expected
Normal file
@@ -0,0 +1,256 @@
|
||||
v5.8.swift:
|
||||
# 1| [Comment] // https://github.com/apple/swift/blob/main/CHANGELOG.md#swift-58
|
||||
# 1|
|
||||
# 4| [StructDecl] Temperature
|
||||
# 5| getMember(0): [PatternBindingDecl] var ... = ...
|
||||
# 5| getPattern(0): [TypedPattern] ... as ...
|
||||
# 5| getSubPattern(): [NamedPattern] degreesCelsius
|
||||
# 5| getTypeRepr(): [TypeRepr] Double
|
||||
# 5| getMember(1): [ConcreteVarDecl] degreesCelsius
|
||||
# 5| Type = Double
|
||||
# 5| getAccessor(0): [Accessor] get
|
||||
# 5| InterfaceType = (Temperature) -> () -> Double
|
||||
# 5| getSelfParam(): [ParamDecl] self
|
||||
# 5| Type = Temperature
|
||||
# 5| getBody(): [BraceStmt] { ... }
|
||||
#-----| getElement(0): [ReturnStmt] return ...
|
||||
#-----| getResult(): [MemberRefExpr] .degreesCelsius
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
# 5| getAccessor(1): [Accessor] set
|
||||
# 5| InterfaceType = (inout Temperature) -> (Double) -> ()
|
||||
# 5| getSelfParam(): [ParamDecl] self
|
||||
# 5| Type = Temperature
|
||||
# 5| getParam(0): [ParamDecl] value
|
||||
# 5| Type = Double
|
||||
# 5| getBody(): [BraceStmt] { ... }
|
||||
#-----| getElement(0): [AssignExpr] ... = ...
|
||||
#-----| getDest(): [MemberRefExpr] .degreesCelsius
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
#-----| getSource(): [DeclRefExpr] value
|
||||
# 5| getAccessor(2): [Accessor] _modify
|
||||
# 5| InterfaceType = (inout Temperature) -> () -> ()
|
||||
# 5| getSelfParam(): [ParamDecl] self
|
||||
# 5| Type = Temperature
|
||||
# 5| getBody(): [BraceStmt] { ... }
|
||||
# 5| getElement(0): [YieldStmt] yield ...
|
||||
#-----| getResult(0): [InOutExpr] &...
|
||||
#-----| getSubExpr(): [MemberRefExpr] .degreesCelsius
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
# 4| getMember(2): [Initializer] Temperature.init(degreesCelsius:)
|
||||
# 4| InterfaceType = (Temperature.Type) -> (Double) -> Temperature
|
||||
# 4| getSelfParam(): [ParamDecl] self
|
||||
# 4| Type = Temperature
|
||||
# 4| getParam(0): [ParamDecl] degreesCelsius
|
||||
# 4| Type = Double
|
||||
# 7| [Comment] // ...
|
||||
# 7|
|
||||
# 10| [ExtensionDecl] extension of Temperature
|
||||
# 13| getMember(0): [PatternBindingDecl] var ... = ...
|
||||
# 13| getPattern(0): [TypedPattern] ... as ...
|
||||
# 13| getSubPattern(): [NamedPattern] degreesFahrenheit
|
||||
# 13| getTypeRepr(): [TypeRepr] Double
|
||||
# 13| getMember(1): [ConcreteVarDecl] degreesFahrenheit
|
||||
# 13| Type = Double
|
||||
# 13| getAccessor(0): [Accessor] get
|
||||
# 13| InterfaceType = (Temperature) -> () -> Double
|
||||
# 13| getSelfParam(): [ParamDecl] self
|
||||
# 13| Type = Temperature
|
||||
# 13| getBody(): [BraceStmt] { ... }
|
||||
# 14| getElement(0): [ReturnStmt] return ...
|
||||
# 14| getResult(): [BinaryExpr] ... .+(_:_:) ...
|
||||
# 14| getFunction(): [MethodLookupExpr] .+(_:_:)
|
||||
# 14| getBase(): [TypeExpr] Double.Type
|
||||
# 14| getTypeRepr(): [TypeRepr] Double
|
||||
# 14| getMethodRef(): [DeclRefExpr] +(_:_:)
|
||||
# 14| getArgument(0): [Argument] : ... ./(_:_:) ...
|
||||
# 14| getExpr(): [BinaryExpr] ... ./(_:_:) ...
|
||||
# 14| getFunction(): [MethodLookupExpr] ./(_:_:)
|
||||
# 14| getBase(): [TypeExpr] Double.Type
|
||||
# 14| getTypeRepr(): [TypeRepr] Double
|
||||
# 14| getMethodRef(): [DeclRefExpr] /(_:_:)
|
||||
# 14| getArgument(0): [Argument] : ... .*(_:_:) ...
|
||||
# 14| getExpr(): [BinaryExpr] ... .*(_:_:) ...
|
||||
# 14| getFunction(): [MethodLookupExpr] .*(_:_:)
|
||||
# 14| getBase(): [TypeExpr] Double.Type
|
||||
# 14| getTypeRepr(): [TypeRepr] Double
|
||||
# 14| getMethodRef(): [DeclRefExpr] *(_:_:)
|
||||
# 14| getArgument(0): [Argument] : .degreesCelsius
|
||||
# 14| getExpr(): [MemberRefExpr] .degreesCelsius
|
||||
# 14| getBase(): [DeclRefExpr] self
|
||||
# 14| getArgument(1): [Argument] : 9
|
||||
# 14| getExpr(): [IntegerLiteralExpr] 9
|
||||
# 14| getArgument(1): [Argument] : 5
|
||||
# 14| getExpr(): [IntegerLiteralExpr] 5
|
||||
# 14| getExpr().getFullyConverted(): [ParenExpr] (...)
|
||||
# 14| getArgument(1): [Argument] : 32
|
||||
# 14| getExpr(): [IntegerLiteralExpr] 32
|
||||
# 18| [NamedFunction] collectionDowncast(_:)
|
||||
# 18| InterfaceType = ([Any]) -> ()
|
||||
# 18| getParam(0): [ParamDecl] arr
|
||||
# 18| Type = [Any]
|
||||
# 18| getBody(): [BraceStmt] { ... }
|
||||
# 19| getElement(0): [SwitchStmt] switch arr { ... }
|
||||
# 19| getExpr(): [DeclRefExpr] arr
|
||||
# 20| getCase(0): [CaseStmt] case ...
|
||||
# 21| getBody(): [BraceStmt] { ... }
|
||||
# 21| getElement(0): [IntegerLiteralExpr] 0
|
||||
# 20| getLabel(0): [CaseLabelItem] ... is ...
|
||||
# 20| getPattern(): [IsPattern] ... is ...
|
||||
# 20| getCastTypeRepr(): [TypeRepr] [Int]
|
||||
# 20| getSubPattern(): [NamedPattern] ints
|
||||
# 20| getPattern().getFullyUnresolved(): [BindingPattern] let ...
|
||||
# 22| getCase(1): [CaseStmt] case ...
|
||||
# 23| getBody(): [BraceStmt] { ... }
|
||||
# 23| getElement(0): [IntegerLiteralExpr] 1
|
||||
# 22| getLabel(0): [CaseLabelItem] ... is ...
|
||||
# 22| getPattern(): [IsPattern] ... is ...
|
||||
# 22| getCastTypeRepr(): [TypeRepr] [Bool]
|
||||
# 24| getCase(2): [CaseStmt] case ...
|
||||
# 25| getBody(): [BraceStmt] { ... }
|
||||
# 25| getElement(0): [IntegerLiteralExpr] 2
|
||||
# 24| getLabel(0): [CaseLabelItem] _
|
||||
# 24| getPattern(): [AnyPattern] _
|
||||
# 20| [ConcreteVarDecl] ints
|
||||
# 20| Type = [Int]
|
||||
# 29| [StructDecl] Button
|
||||
# 30| getMember(0): [PatternBindingDecl] var ... = ...
|
||||
#-----| getInit(0): [NilLiteralExpr] nil
|
||||
# 30| getPattern(0): [TypedPattern] ... as ...
|
||||
# 30| getSubPattern(): [NamedPattern] tapHandler
|
||||
# 30| getTypeRepr(): [TypeRepr] (() -> ())?
|
||||
# 30| getMember(1): [ConcreteVarDecl] tapHandler
|
||||
# 30| Type = (() -> ())?
|
||||
# 30| getAccessor(0): [Accessor] get
|
||||
# 30| InterfaceType = (Button) -> () -> (() -> ())?
|
||||
# 30| getSelfParam(): [ParamDecl] self
|
||||
# 30| Type = Button
|
||||
# 30| getBody(): [BraceStmt] { ... }
|
||||
#-----| getElement(0): [ReturnStmt] return ...
|
||||
#-----| getResult(): [MemberRefExpr] .tapHandler
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
# 30| getAccessor(1): [Accessor] set
|
||||
# 30| InterfaceType = (inout Button) -> ((() -> ())?) -> ()
|
||||
# 30| getSelfParam(): [ParamDecl] self
|
||||
# 30| Type = Button
|
||||
# 30| getParam(0): [ParamDecl] value
|
||||
# 30| Type = (() -> ())?
|
||||
# 30| getBody(): [BraceStmt] { ... }
|
||||
#-----| getElement(0): [AssignExpr] ... = ...
|
||||
#-----| getDest(): [MemberRefExpr] .tapHandler
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
#-----| getSource(): [DeclRefExpr] value
|
||||
# 30| getAccessor(2): [Accessor] _modify
|
||||
# 30| InterfaceType = (inout Button) -> () -> ()
|
||||
# 30| getSelfParam(): [ParamDecl] self
|
||||
# 30| Type = Button
|
||||
# 30| getBody(): [BraceStmt] { ... }
|
||||
# 30| getElement(0): [YieldStmt] yield ...
|
||||
#-----| getResult(0): [InOutExpr] &...
|
||||
#-----| getSubExpr(): [MemberRefExpr] .tapHandler
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
# 29| getMember(2): [Initializer] Button.init()
|
||||
# 29| InterfaceType = (Button.Type) -> () -> Button
|
||||
# 29| getSelfParam(): [ParamDecl] self
|
||||
# 29| Type = Button
|
||||
# 29| getBody(): [BraceStmt] { ... }
|
||||
# 29| getElement(0): [ReturnStmt] return
|
||||
# 29| getMember(3): [Initializer] Button.init(tapHandler:)
|
||||
# 29| InterfaceType = (Button.Type) -> ((() -> ())?) -> Button
|
||||
# 29| getSelfParam(): [ParamDecl] self
|
||||
# 29| Type = Button
|
||||
# 29| getParam(0): [ParamDecl] tapHandler
|
||||
# 29| Type = (() -> ())?
|
||||
# 33| [ClassDecl] ViewController
|
||||
# 34| getMember(0): [PatternBindingDecl] var ... = ...
|
||||
# 34| getInit(0): [CallExpr] call to Button.init()
|
||||
# 34| getFunction(): [MethodLookupExpr] Button.init()
|
||||
# 34| getBase(): [TypeExpr] Button.Type
|
||||
# 34| getTypeRepr(): [TypeRepr] Button
|
||||
# 34| getMethodRef(): [DeclRefExpr] Button.init()
|
||||
# 34| getPattern(0): [TypedPattern] ... as ...
|
||||
# 34| getSubPattern(): [NamedPattern] button
|
||||
# 34| getTypeRepr(): [TypeRepr] Button
|
||||
# 34| getMember(1): [ConcreteVarDecl] button
|
||||
# 34| Type = Button
|
||||
# 34| getAccessor(0): [Accessor] get
|
||||
# 34| InterfaceType = (ViewController) -> () -> Button
|
||||
# 34| getSelfParam(): [ParamDecl] self
|
||||
# 34| Type = ViewController
|
||||
# 34| getBody(): [BraceStmt] { ... }
|
||||
#-----| getElement(0): [ReturnStmt] return ...
|
||||
#-----| getResult(): [MemberRefExpr] .button
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
# 34| getAccessor(1): [Accessor] set
|
||||
# 34| InterfaceType = (ViewController) -> (Button) -> ()
|
||||
# 34| getSelfParam(): [ParamDecl] self
|
||||
# 34| Type = ViewController
|
||||
# 34| getParam(0): [ParamDecl] value
|
||||
# 34| Type = Button
|
||||
# 34| getBody(): [BraceStmt] { ... }
|
||||
#-----| getElement(0): [AssignExpr] ... = ...
|
||||
#-----| getDest(): [MemberRefExpr] .button
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
#-----| getSource(): [DeclRefExpr] value
|
||||
# 34| getAccessor(2): [Accessor] _modify
|
||||
# 34| InterfaceType = (ViewController) -> () -> ()
|
||||
# 34| getSelfParam(): [ParamDecl] self
|
||||
# 34| Type = ViewController
|
||||
# 34| getBody(): [BraceStmt] { ... }
|
||||
# 34| getElement(0): [YieldStmt] yield ...
|
||||
#-----| getResult(0): [InOutExpr] &...
|
||||
#-----| getSubExpr(): [MemberRefExpr] .button
|
||||
#-----| getBase(): [DeclRefExpr] self
|
||||
# 36| getMember(2): [NamedFunction] setup()
|
||||
# 36| InterfaceType = (ViewController) -> () -> ()
|
||||
# 36| getSelfParam(): [ParamDecl] self
|
||||
# 36| Type = ViewController
|
||||
# 36| getBody(): [BraceStmt] { ... }
|
||||
# 37| getElement(0): [AssignExpr] ... = ...
|
||||
# 37| getDest(): [MemberRefExpr] .tapHandler
|
||||
# 37| getBase(): [MemberRefExpr] .button
|
||||
# 37| getBase(): [DeclRefExpr] self
|
||||
# 37| getSource(): [CaptureListExpr] { ... }
|
||||
# 37| getBindingDecl(0): [PatternBindingDecl] var ... = ...
|
||||
# 37| getInit(0): [DeclRefExpr] self
|
||||
# 37| getInit(0).getFullyConverted(): [InjectIntoOptionalExpr] (ViewController?) ...
|
||||
# 37| getPattern(0): [NamedPattern] self
|
||||
# 37| getClosureBody(): [ExplicitClosureExpr] { ... }
|
||||
# 37| getBody(): [BraceStmt] { ... }
|
||||
# 38| getElement(0): [GuardStmt] guard ... else { ... }
|
||||
# 38| getCondition(): [StmtCondition] StmtCondition
|
||||
# 38| getElement(0): [ConditionElement] let ...? = ...
|
||||
# 38| getPattern(): [OptionalSomePattern] let ...?
|
||||
# 38| getSubPattern(): [NamedPattern] self
|
||||
# 38| getSubPattern().getFullyUnresolved(): [BindingPattern] let ...
|
||||
# 38| getInitializer(): [DeclRefExpr] self
|
||||
# 38| getInitializer().getFullyConverted(): [LoadExpr] (ViewController?) ...
|
||||
# 38| getBody(): [BraceStmt] { ... }
|
||||
# 38| getElement(0): [ReturnStmt] return
|
||||
# 39| getElement(1): [CallExpr] call to dismiss()
|
||||
# 39| getFunction(): [MethodLookupExpr] .dismiss()
|
||||
# 39| getBase(): [DeclRefExpr] self
|
||||
# 39| getMethodRef(): [DeclRefExpr] dismiss()
|
||||
# 38| getCapture(0): [CapturedDecl] self
|
||||
# 37| getSource().getFullyConverted(): [InjectIntoOptionalExpr] ((() -> ())?) ...
|
||||
# 43| getMember(3): [NamedFunction] dismiss()
|
||||
# 43| InterfaceType = (ViewController) -> () -> ()
|
||||
# 43| getSelfParam(): [ParamDecl] self
|
||||
# 43| Type = ViewController
|
||||
# 43| getBody(): [BraceStmt] { ... }
|
||||
# 33| getMember(4): [Deinitializer] ViewController.deinit()
|
||||
# 33| InterfaceType = (ViewController) -> () -> ()
|
||||
# 33| getSelfParam(): [ParamDecl] self
|
||||
# 33| Type = ViewController
|
||||
# 33| getBody(): [BraceStmt] { ... }
|
||||
# 33| getMember(5): [Initializer] ViewController.init()
|
||||
# 33| InterfaceType = (ViewController.Type) -> () -> ViewController
|
||||
# 33| getSelfParam(): [ParamDecl] self
|
||||
# 33| Type = ViewController
|
||||
# 33| getBody(): [BraceStmt] { ... }
|
||||
# 33| getElement(0): [ReturnStmt] return
|
||||
# 37| [ConcreteVarDecl] self
|
||||
# 37| Type = ViewController?
|
||||
# 38| [ConcreteVarDecl] self
|
||||
# 38| Type = ViewController
|
||||
# 39| [Comment] // refers to `self.dismiss()`
|
||||
# 39|
|
||||
1
swift/ql/test/extractor-tests/updates/PrintAst.qlref
Normal file
1
swift/ql/test/extractor-tests/updates/PrintAst.qlref
Normal file
@@ -0,0 +1 @@
|
||||
library-tests/ast/PrintAst.ql
|
||||
44
swift/ql/test/extractor-tests/updates/v5.8.swift
Normal file
44
swift/ql/test/extractor-tests/updates/v5.8.swift
Normal file
@@ -0,0 +1,44 @@
|
||||
// https://github.com/apple/swift/blob/main/CHANGELOG.md#swift-58
|
||||
|
||||
@available(macOS 12, *)
|
||||
public struct Temperature {
|
||||
public var degreesCelsius: Double
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
extension Temperature {
|
||||
@available(macOS 12, *)
|
||||
@backDeployed(before: macOS 13)
|
||||
public var degreesFahrenheit: Double {
|
||||
return (degreesCelsius * 9 / 5) + 32
|
||||
}
|
||||
}
|
||||
|
||||
func collectionDowncast(_ arr: [Any]) {
|
||||
switch arr {
|
||||
case let ints as [Int]:
|
||||
0
|
||||
case is [Bool]:
|
||||
1
|
||||
case _:
|
||||
2
|
||||
}
|
||||
}
|
||||
|
||||
struct Button {
|
||||
var tapHandler: (() -> ())?
|
||||
}
|
||||
|
||||
class ViewController {
|
||||
var button: Button = Button()
|
||||
|
||||
func setup() {
|
||||
button.tapHandler = { [weak self] in
|
||||
guard let self else { return }
|
||||
dismiss() // refers to `self.dismiss()`
|
||||
}
|
||||
}
|
||||
|
||||
func dismiss() {}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
28
swift/third_party/BUILD.swift-llvm-support.bazel
vendored
28
swift/third_party/BUILD.swift-llvm-support.bazel
vendored
@@ -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"],
|
||||
)
|
||||
|
||||
@@ -46,3 +31,12 @@ pkg_files(
|
||||
strip_prefix = strip_prefix.from_pkg(),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "swift-resource-dir",
|
||||
srcs = glob([
|
||||
"toolchain/lib/swift/**/*",
|
||||
]),
|
||||
strip_prefix = "toolchain/lib/swift",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
8
swift/third_party/load.bzl
vendored
8
swift/third_party/load.bzl
vendored
@@ -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 = {
|
||||
|
||||
@@ -17,5 +17,5 @@ _arch_override = {
|
||||
for arch in ("linux", "darwin_x86_64", "darwin_arm64")
|
||||
}),
|
||||
)
|
||||
for name in ("swift-llvm-support", "swift-test-sdk")
|
||||
for name in ("swift-llvm-support", "swift-test-sdk", "swift-resource-dir")
|
||||
]
|
||||
|
||||
@@ -6,11 +6,11 @@ QLTEST_LOG="$CODEQL_EXTRACTOR_SWIFT_LOG_DIR"/qltest.log
|
||||
|
||||
EXTRACTOR="$CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor"
|
||||
SDK="$CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk"
|
||||
RESOURCE_DIR="$CODEQL_EXTRACTOR_SWIFT_ROOT/resource-dir/$CODEQL_PLATFORM"
|
||||
export CODEQL_EXTRACTOR_SWIFT_LOG_LEVELS=${CODEQL_EXTRACTOR_SWIFT_LOG_LEVELS:-out:text:no_logs,out:console:info}
|
||||
|
||||
for src in *.swift; do
|
||||
env=()
|
||||
opts=(-sdk "$SDK" -c -primary-file "$src")
|
||||
opts=(-sdk "$SDK" -resource-dir "$RESOURCE_DIR" -c -primary-file "$src")
|
||||
opts+=($(sed -n '1 s=//codeql-extractor-options:==p' $src))
|
||||
expected_status=$(sed -n 's=//codeql-extractor-expected-status:[[:space:]]*==p' $src)
|
||||
expected_status=${expected_status:-0}
|
||||
|
||||
@@ -60,7 +60,7 @@ def assert_extractor_executed_with(*flags):
|
||||
for actual, expected in itertools.zip_longest(execution, flags):
|
||||
if actual:
|
||||
actual = actual.strip()
|
||||
expected_prefix = f"-sdk {swift_root}/qltest/{platform}/sdk -c -primary-file "
|
||||
expected_prefix = f"-sdk {swift_root}/qltest/{platform}/sdk -resource-dir {swift_root}/resource-dir/{platform} -c -primary-file "
|
||||
assert actual.startswith(expected_prefix), f"correct sdk option not found in\n{actual}"
|
||||
actual = actual[len(expected_prefix):]
|
||||
assert actual, f"\nnot encountered: {expected}"
|
||||
|
||||
@@ -25,11 +25,29 @@ function RegisterExtractorPack(id)
|
||||
end
|
||||
end
|
||||
|
||||
-- removes unsupported -Xcc flag, e.g, calling strip_unsupported_xcc_arg('-foo', 2) against
|
||||
-- swift -Xcc -foo -Xcc -bar main.swift
|
||||
-- will only leave 'swift main.swift' removing both -Xcc -foo, and also -Xcc -bar
|
||||
-- removes unsupported CLI arg passed to clang via -Xcc together with the following how_many args
|
||||
function strip_unsupported_clang_arg(args, arg, how_many)
|
||||
local index = indexOf(args, arg)
|
||||
if index and index > 0 and args[index - 1] == '-Xcc' then
|
||||
index = index - 1 -- start from -Xcc
|
||||
how_many = 2 * (how_many + 1) -- need to remove initial -Xcc <arg> as well as following -Xcc prefixed flags
|
||||
while (how_many > 0)
|
||||
do
|
||||
table.remove(args, index)
|
||||
how_many = how_many - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function strip_unsupported_args(args)
|
||||
strip_unsupported_arg(args, '-emit-localized-strings', 0)
|
||||
strip_unsupported_arg(args, '-emit-localized-strings-path', 1)
|
||||
strip_unsupported_arg(args, '-stack-check', 0)
|
||||
strip_unsupported_arg(args, '-experimental-skip-non-inlinable-function-bodies-without-types', 0)
|
||||
strip_unsupported_clang_arg(args, '-ivfsstatcache', 1)
|
||||
end
|
||||
|
||||
-- xcodebuild does not always specify the -resource-dir in which case the compiler falls back
|
||||
|
||||
Reference in New Issue
Block a user