Merge pull request #9639 from github/redsun82/swift-extraction

Swift: some expression extractions
This commit is contained in:
Paolo Tranquilli
2022-06-22 17:19:20 +02:00
committed by GitHub
39 changed files with 522 additions and 378 deletions

View File

@@ -385,6 +385,7 @@ EnumIsCaseExpr:
ErrorExpr:
_extends: Expr
_tags: [ no_qltest ] # unexpected emission
ExplicitCastExpr:
_extends: Expr
@@ -445,7 +446,7 @@ LookupExpr:
_extends: Expr
_children:
base_expr: Expr
member: Decl
member: Decl?
MakeTemporarilyEscapableExpr:
_extends: Expr
@@ -459,6 +460,7 @@ ObjCSelectorExpr:
_children:
sub_expr: Expr
method: AbstractFunctionDecl
_tags: [ no_qltest ] # to be tested in integration tests
OneWayExpr:
_extends: Expr
@@ -498,6 +500,9 @@ RebindSelfInConstructorExpr:
SequenceExpr:
_extends: Expr
_children:
elements: Expr*
_tags: [ no_qltest ] # we should really never extract these, as these should be resolved to trees of operations
SuperRefExpr:
_extends: Expr
@@ -528,18 +533,27 @@ TypeExpr:
UnresolvedDeclRefExpr:
_extends: Expr
name: string?
_tags: [ no_qltest ] # we should really never extract these
UnresolvedDotExpr:
_extends: Expr
_children:
base: Expr
name: string
UnresolvedMemberExpr:
_extends: Expr
name: string
_tags: [ no_qltest ] # we should really never extract these
UnresolvedPatternExpr:
_extends: Expr
_tags: [ no_qltest ] # we should really never extract these
UnresolvedSpecializeExpr:
_extends: Expr
_tags: [ no_qltest ] # we should really never extract these
VarargExpansionExpr:
_extends: Expr
@@ -807,9 +821,11 @@ ArrayToPointerExpr:
BridgeFromObjCExpr:
_extends: ImplicitConversionExpr
_tags: [ no_qltest ] # to be tested in integration tests
BridgeToObjCExpr:
_extends: ImplicitConversionExpr
_tags: [ no_qltest ] # to be tested in integration tests
ClassMetatypeToObjectExpr:
_extends: ImplicitConversionExpr
@@ -819,6 +835,7 @@ CollectionUpcastConversionExpr:
ConditionalBridgeFromObjCExpr:
_extends: ImplicitConversionExpr
_tags: [ no_qltest ] # to be tested in integration tests
CovariantFunctionConversionExpr:
_extends: ImplicitConversionExpr

View File

@@ -64,6 +64,7 @@ class SwiftDispatcher {
// visitor (see `visit(T *)` methods below).
template <typename E>
TrapLabelOf<E> fetchLabel(E* e) {
assert(e && "trying to fetch a label on nullptr, maybe fetchOptionalLabel is to be used?");
// this is required so we avoid any recursive loop: a `fetchLabel` during the visit of `e` might
// end up calling `fetchLabel` on `e` itself, so we want the visit of `e` to call `fetchLabel`
// only after having called `assignNewLabel` on `e`.

View File

@@ -271,19 +271,16 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
emitImplicitConversionExpr(expr, label);
}
void visitTypeExpr(swift::TypeExpr* expr) {
auto label = dispatcher_.assignNewLabel(expr);
dispatcher_.emit(TypeExprsTrap{label});
if (auto repr = expr->getTypeRepr()) {
auto typeLabel = dispatcher_.fetchLabel(repr);
dispatcher_.emit(TypeExprTypeReprsTrap{label, typeLabel});
}
codeql::TypeExpr translateTypeExpr(const swift::TypeExpr& expr) {
TypeExpr entry{dispatcher_.assignNewLabel(expr)};
entry.type_repr = dispatcher_.fetchOptionalLabel(expr.getTypeRepr());
return entry;
}
void visitParenExpr(swift::ParenExpr* expr) {
auto label = dispatcher_.assignNewLabel(expr);
dispatcher_.emit(ParenExprsTrap{label});
emitIdentityExpr(expr, label);
codeql::ParenExpr translateParenExpr(const swift::ParenExpr& expr) {
ParenExpr entry{dispatcher_.assignNewLabel(expr)};
fillIdentityExpr(expr, entry);
return entry;
}
void visitLoadExpr(swift::LoadExpr* expr) {
@@ -531,6 +528,62 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
dispatcher_.emit(OtherConstructorDeclRefExprsTrap{label, ctorLabel});
}
codeql::UnresolvedDeclRefExpr translateUnresolvedDeclRefExpr(
const swift::UnresolvedDeclRefExpr& expr) {
codeql::UnresolvedDeclRefExpr entry{dispatcher_.assignNewLabel(expr)};
if (expr.hasName()) {
llvm::SmallVector<char> scratch;
entry.name = expr.getName().getString(scratch).str();
}
return entry;
}
codeql::UnresolvedDotExpr translateUnresolvedDotExpr(const swift::UnresolvedDotExpr& expr) {
codeql::UnresolvedDotExpr entry{dispatcher_.assignNewLabel(expr)};
assert(expr.getBase() && "Expect UnresolvedDotExpr to have a base");
entry.base = dispatcher_.fetchLabel(expr.getBase());
llvm::SmallVector<char> scratch;
entry.name = expr.getName().getString(scratch).str();
return entry;
}
codeql::UnresolvedMemberExpr translateUnresolvedMemberExpr(
const swift::UnresolvedMemberExpr& expr) {
UnresolvedMemberExpr entry{dispatcher_.assignNewLabel(expr)};
llvm::SmallVector<char> scratch;
entry.name = expr.getName().getString(scratch).str();
return entry;
}
codeql::SequenceExpr translateSequenceExpr(const swift::SequenceExpr& expr) {
SequenceExpr entry{dispatcher_.assignNewLabel(expr)};
entry.elements = dispatcher_.fetchRepeatedLabels(expr.getElements());
return entry;
}
codeql::BridgeToObjCExpr translateBridgeToObjCExpr(const swift::BridgeToObjCExpr& expr) {
BridgeToObjCExpr entry{dispatcher_.assignNewLabel(expr)};
entry.sub_expr = dispatcher_.fetchLabel(expr.getSubExpr());
return entry;
}
codeql::BridgeFromObjCExpr translateBridgeFromObjCExpr(const swift::BridgeFromObjCExpr& expr) {
BridgeFromObjCExpr entry{dispatcher_.assignNewLabel(expr)};
entry.sub_expr = dispatcher_.fetchLabel(expr.getSubExpr());
return entry;
}
codeql::DotSelfExpr translateDotSelfExpr(const swift::DotSelfExpr& expr) {
DotSelfExpr entry{dispatcher_.assignNewLabel(expr)};
fillIdentityExpr(expr, entry);
return entry;
}
codeql::ErrorExpr translateErrorExpr(const swift::ErrorExpr& expr) {
ErrorExpr entry{dispatcher_.assignNewLabel(expr)};
return entry;
}
private:
void fillAbstractClosureExpr(const swift::AbstractClosureExpr& expr,
codeql::AbstractClosureExpr& entry) {
@@ -560,9 +613,9 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
dispatcher_.emit(ExplicitCastExprsTrap{label, dispatcher_.fetchLabel(expr->getSubExpr())});
}
void emitIdentityExpr(swift::IdentityExpr* expr, TrapLabel<IdentityExprTag> label) {
assert(expr->getSubExpr() && "IdentityExpr has getSubExpr()");
dispatcher_.emit(IdentityExprsTrap{label, dispatcher_.fetchLabel(expr->getSubExpr())});
void fillIdentityExpr(const swift::IdentityExpr& expr, codeql::IdentityExpr& entry) {
assert(expr.getSubExpr() && "IdentityExpr has getSubExpr()");
entry.sub_expr = dispatcher_.fetchLabel(expr.getSubExpr());
}
void emitAnyTryExpr(swift::AnyTryExpr* expr, TrapLabel<AnyTryExprTag> label) {
@@ -590,9 +643,11 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
void emitLookupExpr(const swift::LookupExpr* expr, TrapLabel<LookupExprTag> label) {
assert(expr->getBase() && "LookupExpr has getBase()");
auto baseLabel = dispatcher_.fetchLabel(expr->getBase());
assert(expr->hasDecl() && "LookupExpr has decl");
auto declLabel = dispatcher_.fetchLabel(expr->getDecl().getDecl());
dispatcher_.emit(LookupExprsTrap{label, baseLabel, declLabel});
dispatcher_.emit(LookupExprsTrap{label, baseLabel});
if (expr->hasDecl()) {
auto declLabel = dispatcher_.fetchLabel(expr->getDecl().getDecl());
dispatcher_.emit(LookupExprMembersTrap{label, declLabel});
}
}
/*

View File

@@ -1,4 +1,5 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.expr.UnresolvedDotExpr
class UnresolvedDotExpr extends UnresolvedDotExprBase { }
class UnresolvedDotExpr extends UnresolvedDotExprBase {
override string toString() { result = "... ." + getName() }
}

View File

@@ -102,7 +102,7 @@ Element getAnImmediateChild(Element e) {
or
lazy_initializer_exprs(e, x)
or
lookup_exprs(e, x, _)
lookup_exprs(e, x)
or
make_temporarily_escapable_exprs(e, x, _, _)
or
@@ -128,6 +128,8 @@ Element getAnImmediateChild(Element e) {
or
self_apply_exprs(e, x)
or
sequence_expr_elements(e, _, x)
or
subscript_expr_arguments(e, _, x)
or
tap_expr_sub_exprs(e, x)
@@ -140,6 +142,8 @@ Element getAnImmediateChild(Element e) {
or
type_expr_type_reprs(e, x)
or
unresolved_dot_exprs(e, x, _)
or
vararg_expansion_exprs(e, x)
or
binding_patterns(e, x)

View File

@@ -5,15 +5,17 @@ import codeql.swift.elements.expr.Expr
class LookupExprBase extends @lookup_expr, Expr {
Expr getBaseExpr() {
exists(Expr x |
lookup_exprs(this, x, _) and
lookup_exprs(this, x) and
result = x.resolve()
)
}
Decl getMember() {
exists(Decl x |
lookup_exprs(this, _, x) and
lookup_expr_members(this, x) and
result = x.resolve()
)
}
predicate hasMember() { exists(getMember()) }
}

View File

@@ -3,4 +3,15 @@ import codeql.swift.elements.expr.Expr
class SequenceExprBase extends @sequence_expr, Expr {
override string getAPrimaryQlClass() { result = "SequenceExpr" }
Expr getElement(int index) {
exists(Expr x |
sequence_expr_elements(this, index, x) and
result = x.resolve()
)
}
Expr getAnElement() { result = getElement(_) }
int getNumberOfElements() { result = count(getAnElement()) }
}

View File

@@ -3,4 +3,8 @@ import codeql.swift.elements.expr.Expr
class UnresolvedDeclRefExprBase extends @unresolved_decl_ref_expr, Expr {
override string getAPrimaryQlClass() { result = "UnresolvedDeclRefExpr" }
string getName() { unresolved_decl_ref_expr_names(this, result) }
predicate hasName() { exists(getName()) }
}

View File

@@ -3,4 +3,13 @@ import codeql.swift.elements.expr.Expr
class UnresolvedDotExprBase extends @unresolved_dot_expr, Expr {
override string getAPrimaryQlClass() { result = "UnresolvedDotExpr" }
Expr getBase() {
exists(Expr x |
unresolved_dot_exprs(this, x, _) and
result = x.resolve()
)
}
string getName() { unresolved_dot_exprs(this, _, result) }
}

View File

@@ -3,4 +3,6 @@ import codeql.swift.elements.expr.Expr
class UnresolvedMemberExprBase extends @unresolved_member_expr, Expr {
override string getAPrimaryQlClass() { result = "UnresolvedMemberExpr" }
string getName() { unresolved_member_exprs(this, result) }
}

View File

@@ -955,7 +955,12 @@ lazy_initializer_exprs(
#keyset[id]
lookup_exprs(
int id: @lookup_expr ref,
int base_expr: @expr ref,
int base_expr: @expr ref
);
#keyset[id]
lookup_expr_members(
int id: @lookup_expr ref,
int member: @decl ref
);
@@ -1016,6 +1021,13 @@ sequence_exprs(
unique int id: @sequence_expr
);
#keyset[id, index]
sequence_expr_elements(
int id: @sequence_expr ref,
int index: int ref,
int element: @expr ref
);
super_ref_exprs(
unique int id: @super_ref_expr,
int self: @var_decl ref
@@ -1064,12 +1076,21 @@ unresolved_decl_ref_exprs(
unique int id: @unresolved_decl_ref_expr
);
#keyset[id]
unresolved_decl_ref_expr_names(
int id: @unresolved_decl_ref_expr ref,
string name: string ref
);
unresolved_dot_exprs(
unique int id: @unresolved_dot_expr
unique int id: @unresolved_dot_expr,
int base: @expr ref,
string name: string ref
);
unresolved_member_exprs(
unique int id: @unresolved_member_expr
unique int id: @unresolved_member_expr,
string name: string ref
);
unresolved_pattern_exprs(

View File

@@ -1,244 +1,246 @@
| expressions.swift:1:9:1:9 | 15 |
| expressions.swift:2:9:2:9 | 15.15 |
| expressions.swift:3:10:3:10 | true |
| expressions.swift:4:10:4:10 | false |
| expressions.swift:5:9:5:9 | #... |
| expressions.swift:6:9:6:9 | hello world |
| expressions.swift:7:10:7:10 | "..." |
| expressions.swift:7:10:7:10 | OpaqueValueExpr |
| expressions.swift:7:10:7:10 | TapExpr |
| expressions.swift:7:10:7:10 | hello |
| expressions.swift:7:11:7:10 | call to ... |
| expressions.swift:7:11:7:11 | $interpolation |
| expressions.swift:7:11:7:11 | &... |
| expressions.swift:7:11:7:11 | call to appendLiteral(_:) |
| expressions.swift:7:18:7:18 | $interpolation |
| expressions.swift:7:18:7:18 | &... |
| expressions.swift:7:18:7:18 | appendInterpolation(_:) |
| expressions.swift:7:18:7:18 | call to appendInterpolation(_:) |
| expressions.swift:7:18:7:20 | call to ... |
| expressions.swift:7:19:7:19 | a |
| expressions.swift:7:21:7:21 | |
| expressions.swift:7:21:7:21 | $interpolation |
| expressions.swift:7:21:7:21 | &... |
| expressions.swift:7:21:7:21 | call to ... |
| expressions.swift:7:21:7:21 | call to appendLiteral(_:) |
| expressions.swift:8:15:8:15 | nil |
| expressions.swift:15:9:15:9 | x |
| expressions.swift:15:9:15:14 | ... call to !=(_:_:) ... |
| expressions.swift:15:11:15:11 | !=(_:_:) |
| expressions.swift:15:11:15:11 | Int.Type |
| expressions.swift:15:11:15:11 | call to !=(_:_:) |
| expressions.swift:15:14:15:14 | 0 |
| expressions.swift:16:11:16:11 | AnError.Type |
| expressions.swift:16:11:16:19 | (Error) ... |
| expressions.swift:16:11:16:19 | call to ... |
| expressions.swift:16:19:16:19 | failed |
| expressions.swift:20:1:20:16 | try! ... |
| expressions.swift:20:6:20:6 | failure(_:) |
| expressions.swift:20:6:20:16 | call to failure(_:) |
| expressions.swift:20:14:20:14 | 11 |
| expressions.swift:21:1:21:16 | try? ... |
| expressions.swift:21:6:21:6 | failure(_:) |
| expressions.swift:21:6:21:16 | (()?) ... |
| expressions.swift:21:6:21:16 | call to failure(_:) |
| expressions.swift:21:14:21:14 | 11 |
| expressions.swift:27:13:27:13 | Klass.Type |
| expressions.swift:27:13:27:13 | call to init |
| expressions.swift:27:13:27:13 | init |
| expressions.swift:27:13:27:19 | call to ... |
| expressions.swift:29:9:29:19 | [...] |
| expressions.swift:29:10:29:10 | 1 |
| expressions.swift:29:10:29:16 | (...) |
| expressions.swift:29:16:29:16 | 2 |
| expressions.swift:30:1:30:1 | _ |
| expressions.swift:30:1:30:5 | ... = ... |
| expressions.swift:30:5:30:5 | 15 |
| expressions.swift:31:1:31:1 | _ |
| expressions.swift:31:1:31:11 | ... = ... |
| expressions.swift:31:5:31:5 | 15 |
| expressions.swift:31:5:31:11 | ... is ... |
| expressions.swift:32:1:32:1 | _ |
| expressions.swift:32:1:32:11 | ... = ... |
| expressions.swift:32:5:32:5 | 15 |
| expressions.swift:32:5:32:11 | (Double) ... |
| expressions.swift:33:1:33:1 | _ |
| expressions.swift:33:1:33:12 | ... = ... |
| expressions.swift:33:5:33:5 | 15 |
| expressions.swift:33:5:33:12 | (Double?) ... |
| expressions.swift:34:1:34:1 | _ |
| expressions.swift:34:1:34:12 | ... = ... |
| expressions.swift:34:5:34:5 | 15 |
| expressions.swift:34:5:34:12 | (Double) ... |
| expressions.swift:35:1:35:1 | print(_:separator:terminator:) |
| expressions.swift:35:1:35:13 | call to print(_:separator:terminator:) |
| expressions.swift:35:6:35:6 | default separator |
| expressions.swift:35:6:35:6 | default terminator |
| expressions.swift:35:7:35:7 | d |
| expressions.swift:35:7:35:12 | (Any) ... |
| expressions.swift:35:7:35:12 | ...[...] |
| expressions.swift:35:7:35:12 | [...] |
| expressions.swift:35:7:35:12 | [...] |
| expressions.swift:35:9:35:9 | 1 |
| expressions.swift:38:3:38:3 | closure |
| expressions.swift:38:3:38:15 | call to ... |
| expressions.swift:38:11:38:11 | 5 |
| expressions.swift:38:14:38:14 | 7 |
| expressions.swift:41:1:41:1 | closured(closure:) |
| expressions.swift:41:1:43:1 | call to closured(closure:) |
| expressions.swift:41:10:43:1 | { ... } |
| expressions.swift:42:12:42:12 | x |
| expressions.swift:42:12:42:16 | ... call to +(_:_:) ... |
| expressions.swift:42:14:42:14 | +(_:_:) |
| expressions.swift:42:14:42:14 | Int.Type |
| expressions.swift:42:14:42:14 | call to +(_:_:) |
| expressions.swift:42:16:42:16 | y |
| expressions.swift:44:1:44:1 | closured(closure:) |
| expressions.swift:44:1:46:1 | call to closured(closure:) |
| expressions.swift:44:10:46:1 | { ... } |
| expressions.swift:45:12:45:12 | x |
| expressions.swift:45:12:45:16 | ... call to +(_:_:) ... |
| expressions.swift:45:14:45:14 | +(_:_:) |
| expressions.swift:45:14:45:14 | Int.Type |
| expressions.swift:45:14:45:14 | call to +(_:_:) |
| expressions.swift:45:16:45:16 | y |
| expressions.swift:47:1:47:1 | closured(closure:) |
| expressions.swift:47:1:47:27 | call to closured(closure:) |
| expressions.swift:47:10:47:27 | { ... } |
| expressions.swift:47:19:47:19 | $0 |
| expressions.swift:47:19:47:24 | ... call to +(_:_:) ... |
| expressions.swift:47:22:47:22 | +(_:_:) |
| expressions.swift:47:22:47:22 | Int.Type |
| expressions.swift:47:22:47:22 | call to +(_:_:) |
| expressions.swift:47:24:47:24 | $1 |
| expressions.swift:48:1:48:1 | closured(closure:) |
| expressions.swift:48:1:48:20 | call to closured(closure:) |
| expressions.swift:48:10:48:20 | { ... } |
| expressions.swift:48:12:48:12 | $0 |
| expressions.swift:48:12:48:17 | ... call to +(_:_:) ... |
| expressions.swift:48:15:48:15 | +(_:_:) |
| expressions.swift:48:15:48:15 | Int.Type |
| expressions.swift:48:15:48:15 | call to +(_:_:) |
| expressions.swift:48:17:48:17 | $1 |
| expressions.swift:54:1:54:1 | _ |
| expressions.swift:54:1:54:8 | ... = ... |
| expressions.swift:54:5:54:8 | #keyPath(...) |
| expressions.swift:54:6:54:8 | UnresolvedDotExpr |
| expressions.swift:58:16:58:16 | 1234 |
| expressions.swift:59:1:59:1 | unsafeFunction(pointer:) |
| expressions.swift:59:1:59:34 | call to unsafeFunction(pointer:) |
| expressions.swift:59:25:59:26 | &... |
| expressions.swift:59:25:59:26 | (UnsafePointer<Int>) ... |
| expressions.swift:59:26:59:26 | myNumber |
| expressions.swift:60:1:60:1 | withUnsafePointer(to:_:) |
| expressions.swift:60:1:60:63 | call to withUnsafePointer(to:_:) |
| expressions.swift:60:23:60:23 | (Int) ... |
| expressions.swift:60:23:60:23 | myNumber |
| expressions.swift:60:33:60:63 | ((UnsafePointer<Int>) throws -> ()) ... |
| expressions.swift:60:33:60:63 | { ... } |
| expressions.swift:60:35:60:35 | unsafeFunction(pointer:) |
| expressions.swift:60:35:60:61 | call to unsafeFunction(pointer:) |
| expressions.swift:60:59:60:59 | $0 |
| expressions.swift:64:8:64:8 | x |
| expressions.swift:64:8:64:12 | ... call to <(_:_:) ... |
| expressions.swift:64:10:64:10 | <(_:_:) |
| expressions.swift:64:10:64:10 | Int.Type |
| expressions.swift:64:10:64:10 | call to <(_:_:) |
| expressions.swift:64:12:64:12 | 0 |
| expressions.swift:73:5:73:5 | .xx |
| expressions.swift:73:5:73:5 | self |
| expressions.swift:73:5:73:10 | ... = ... |
| expressions.swift:73:10:73:10 | x |
| expressions.swift:77:7:77:7 | #... |
| expressions.swift:77:7:77:7 | #... |
| expressions.swift:77:7:77:7 | #... |
| expressions.swift:77:7:77:7 | #... |
| expressions.swift:77:7:77:7 | _unimplementedInitializer(className:initName:file:line:column:) |
| expressions.swift:77:7:77:7 | call to _unimplementedInitializer(className:initName:file:line:column:) |
| expressions.swift:77:7:77:7 | expressions.Derived |
| expressions.swift:79:5:79:5 | super |
| expressions.swift:79:5:79:11 | call to ... |
| expressions.swift:79:5:79:21 | call to ... |
| expressions.swift:79:5:79:21 | self = ... |
| expressions.swift:79:11:79:11 | init |
| expressions.swift:79:19:79:19 | 22 |
| expressions.swift:83:15:83:15 | Derived.Type |
| expressions.swift:83:15:83:15 | call to init |
| expressions.swift:83:15:83:15 | init |
| expressions.swift:83:15:83:23 | call to ... |
| expressions.swift:84:1:84:1 | _ |
| expressions.swift:84:1:84:13 | ... = ... |
| expressions.swift:84:5:84:5 | (Base) ... |
| expressions.swift:84:5:84:5 | derived |
| expressions.swift:84:5:84:13 | .xx |
| expressions.swift:87:1:87:1 | opt |
| expressions.swift:87:1:87:4 | ...! |
| expressions.swift:88:1:88:1 | d |
| expressions.swift:88:1:88:6 | ...[...] |
| expressions.swift:88:1:88:7 | ...! |
| expressions.swift:88:3:88:3 | a |
| expressions.swift:92:14:92:14 | Unmanaged<ToPtr>.Type |
| expressions.swift:92:14:92:24 | call to passRetained(_:) |
| expressions.swift:92:14:92:44 | call to ... |
| expressions.swift:92:14:92:46 | call to toOpaque() |
| expressions.swift:92:14:92:55 | call to ... |
| expressions.swift:92:24:92:24 | passRetained(_:) |
| expressions.swift:92:37:92:37 | ToPtr.Type |
| expressions.swift:92:37:92:37 | call to init |
| expressions.swift:92:37:92:37 | init |
| expressions.swift:92:37:92:43 | call to ... |
| expressions.swift:92:46:92:46 | toOpaque() |
| expressions.swift:93:1:93:16 | Unmanaged<ToPtr>.Type |
| expressions.swift:93:1:93:18 | call to fromOpaque(_:) |
| expressions.swift:93:1:93:35 | call to ... |
| expressions.swift:93:18:93:18 | fromOpaque(_:) |
| expressions.swift:93:29:93:29 | (UnsafeRawPointer) ... |
| expressions.swift:93:29:93:29 | opaque |
| expressions.swift:99:14:99:14 | 0 |
| expressions.swift:106:12:106:12 | 0 |
| expressions.swift:112:14:112:14 | 0 |
| expressions.swift:120:14:120:14 | 0 |
| expressions.swift:126:12:126:12 | 0 |
| expressions.swift:131:3:131:3 | hp |
| expressions.swift:131:3:131:6 | .settableField |
| expressions.swift:131:3:131:22 | ... = ... |
| expressions.swift:131:22:131:22 | 42 |
| expressions.swift:132:11:132:11 | hp |
| expressions.swift:132:11:132:14 | (Int) ... |
| expressions.swift:132:11:132:14 | .settableField |
| expressions.swift:133:11:133:11 | (HasProperty) ... |
| expressions.swift:133:11:133:11 | hp |
| expressions.swift:133:11:133:14 | .readOnlyField1 |
| expressions.swift:134:11:134:11 | (HasProperty) ... |
| expressions.swift:134:11:134:11 | hp |
| expressions.swift:134:11:134:14 | .readOnlyField2 |
| expressions.swift:135:3:135:3 | hp |
| expressions.swift:135:3:135:6 | .normalField |
| expressions.swift:135:3:135:20 | ... = ... |
| expressions.swift:135:20:135:20 | 99 |
| expressions.swift:136:11:136:11 | hp |
| expressions.swift:136:11:136:14 | (Int) ... |
| expressions.swift:136:11:136:14 | .normalField |
| expressions.swift:137:3:137:3 | &... |
| expressions.swift:137:3:137:3 | hp |
| expressions.swift:137:3:137:7 | ...[...] |
| expressions.swift:137:3:137:11 | ... = ... |
| expressions.swift:137:6:137:6 | 1 |
| expressions.swift:137:11:137:11 | 2 |
| expressions.swift:138:10:138:10 | (HasProperty) ... |
| expressions.swift:138:10:138:10 | hp |
| expressions.swift:138:10:138:17 | ...[...] |
| expressions.swift:138:13:138:13 | 3 |
| expressions.swift:138:16:138:16 | 4 |
| expressions.swift:152:26:152:26 | a |
| expressions.swift:152:26:152:47 | \\...[...] |
| expressions.swift:152:37:152:37 | keyPathInt |
| expressions.swift:153:24:153:24 | a |
| expressions.swift:153:24:153:43 | \\...[...] |
| expressions.swift:153:35:153:35 | keyPathB |
| expressions.swift:154:22:154:22 | a |
| expressions.swift:154:22:154:41 | \\...[...] |
| expressions.swift:154:22:154:56 | \\...[...] |
| expressions.swift:154:33:154:33 | keyPathB |
| expressions.swift:154:52:154:55 | #keyPath(...) |
| expressions.swift:154:53:154:55 | UnresolvedDotExpr |
| expressions.swift:1:9:1:9 | 15 | IntegerLiteralExpr |
| expressions.swift:2:9:2:9 | 15.15 | FloatLiteralExpr |
| expressions.swift:3:10:3:10 | true | BooleanLiteralExpr |
| expressions.swift:4:10:4:10 | false | BooleanLiteralExpr |
| expressions.swift:5:9:5:9 | #... | MagicIdentifierLiteralExpr |
| expressions.swift:6:9:6:9 | hello world | StringLiteralExpr |
| expressions.swift:7:10:7:10 | "..." | InterpolatedStringLiteralExpr |
| expressions.swift:7:10:7:10 | OpaqueValueExpr | OpaqueValueExpr |
| expressions.swift:7:10:7:10 | TapExpr | TapExpr |
| expressions.swift:7:10:7:10 | hello | StringLiteralExpr |
| expressions.swift:7:11:7:10 | call to ... | CallExpr |
| expressions.swift:7:11:7:11 | $interpolation | DeclRefExpr |
| expressions.swift:7:11:7:11 | &... | InOutExpr |
| expressions.swift:7:11:7:11 | call to appendLiteral(_:) | DotSyntaxCallExpr |
| expressions.swift:7:18:7:18 | $interpolation | DeclRefExpr |
| expressions.swift:7:18:7:18 | &... | InOutExpr |
| expressions.swift:7:18:7:18 | appendInterpolation(_:) | DeclRefExpr |
| expressions.swift:7:18:7:18 | call to appendInterpolation(_:) | DotSyntaxCallExpr |
| expressions.swift:7:18:7:20 | call to ... | CallExpr |
| expressions.swift:7:19:7:19 | a | DeclRefExpr |
| expressions.swift:7:21:7:21 | | StringLiteralExpr |
| expressions.swift:7:21:7:21 | $interpolation | DeclRefExpr |
| expressions.swift:7:21:7:21 | &... | InOutExpr |
| expressions.swift:7:21:7:21 | call to ... | CallExpr |
| expressions.swift:7:21:7:21 | call to appendLiteral(_:) | DotSyntaxCallExpr |
| expressions.swift:8:15:8:15 | nil | NilLiteralExpr |
| expressions.swift:15:9:15:9 | x | DeclRefExpr |
| expressions.swift:15:9:15:14 | ... call to !=(_:_:) ... | BinaryExpr |
| expressions.swift:15:11:15:11 | !=(_:_:) | DeclRefExpr |
| expressions.swift:15:11:15:11 | Int.Type | TypeExpr |
| expressions.swift:15:11:15:11 | call to !=(_:_:) | DotSyntaxCallExpr |
| expressions.swift:15:14:15:14 | 0 | IntegerLiteralExpr |
| expressions.swift:16:11:16:11 | AnError.Type | TypeExpr |
| expressions.swift:16:11:16:19 | (Error) ... | ErasureExpr |
| expressions.swift:16:11:16:19 | call to ... | DotSyntaxCallExpr |
| expressions.swift:16:19:16:19 | failed | DeclRefExpr |
| expressions.swift:20:1:20:16 | try! ... | ForceTryExpr |
| expressions.swift:20:6:20:6 | failure(_:) | DeclRefExpr |
| expressions.swift:20:6:20:16 | call to failure(_:) | CallExpr |
| expressions.swift:20:14:20:14 | 11 | IntegerLiteralExpr |
| expressions.swift:21:1:21:16 | try? ... | OptionalTryExpr |
| expressions.swift:21:6:21:6 | failure(_:) | DeclRefExpr |
| expressions.swift:21:6:21:16 | (()?) ... | InjectIntoOptionalExpr |
| expressions.swift:21:6:21:16 | call to failure(_:) | CallExpr |
| expressions.swift:21:14:21:14 | 11 | IntegerLiteralExpr |
| expressions.swift:27:13:27:13 | Klass.Type | TypeExpr |
| expressions.swift:27:13:27:13 | call to init | ConstructorRefCallExpr |
| expressions.swift:27:13:27:13 | init | DeclRefExpr |
| expressions.swift:27:13:27:19 | call to ... | CallExpr |
| expressions.swift:29:9:29:19 | [...] | DictionaryExpr |
| expressions.swift:29:10:29:10 | 1 | StringLiteralExpr |
| expressions.swift:29:10:29:16 | (...) | TupleExpr |
| expressions.swift:29:16:29:16 | 2 | StringLiteralExpr |
| expressions.swift:30:1:30:1 | _ | DiscardAssignmentExpr |
| expressions.swift:30:1:30:5 | ... = ... | AssignExpr |
| expressions.swift:30:5:30:5 | 15 | IntegerLiteralExpr |
| expressions.swift:31:1:31:1 | _ | DiscardAssignmentExpr |
| expressions.swift:31:1:31:11 | ... = ... | AssignExpr |
| expressions.swift:31:5:31:5 | 15 | IntegerLiteralExpr |
| expressions.swift:31:5:31:11 | ... is ... | IsExpr |
| expressions.swift:32:1:32:1 | _ | DiscardAssignmentExpr |
| expressions.swift:32:1:32:11 | ... = ... | AssignExpr |
| expressions.swift:32:5:32:5 | 15 | IntegerLiteralExpr |
| expressions.swift:32:5:32:11 | (Double) ... | CoerceExpr |
| expressions.swift:33:1:33:1 | _ | DiscardAssignmentExpr |
| expressions.swift:33:1:33:12 | ... = ... | AssignExpr |
| expressions.swift:33:5:33:5 | 15 | IntegerLiteralExpr |
| expressions.swift:33:5:33:12 | (Double?) ... | ConditionalCheckedCastExpr |
| expressions.swift:34:1:34:1 | _ | DiscardAssignmentExpr |
| expressions.swift:34:1:34:12 | ... = ... | AssignExpr |
| expressions.swift:34:5:34:5 | 15 | IntegerLiteralExpr |
| expressions.swift:34:5:34:12 | (Double) ... | ForcedCheckedCastExpr |
| expressions.swift:35:1:35:1 | print(_:separator:terminator:) | DeclRefExpr |
| expressions.swift:35:1:35:13 | call to print(_:separator:terminator:) | CallExpr |
| expressions.swift:35:6:35:6 | default separator | DefaultArgumentExpr |
| expressions.swift:35:6:35:6 | default terminator | DefaultArgumentExpr |
| expressions.swift:35:7:35:7 | d | DeclRefExpr |
| expressions.swift:35:7:35:12 | (Any) ... | ErasureExpr |
| expressions.swift:35:7:35:12 | ...[...] | SubscriptExpr |
| expressions.swift:35:7:35:12 | [...] | ArrayExpr |
| expressions.swift:35:7:35:12 | [...] | VarargExpansionExpr |
| expressions.swift:35:9:35:9 | 1 | StringLiteralExpr |
| expressions.swift:38:3:38:3 | closure | DeclRefExpr |
| expressions.swift:38:3:38:15 | call to ... | CallExpr |
| expressions.swift:38:11:38:11 | 5 | IntegerLiteralExpr |
| expressions.swift:38:14:38:14 | 7 | IntegerLiteralExpr |
| expressions.swift:41:1:41:1 | closured(closure:) | DeclRefExpr |
| expressions.swift:41:1:43:1 | call to closured(closure:) | CallExpr |
| expressions.swift:41:10:43:1 | { ... } | ClosureExpr |
| expressions.swift:42:12:42:12 | x | DeclRefExpr |
| expressions.swift:42:12:42:16 | ... call to +(_:_:) ... | BinaryExpr |
| expressions.swift:42:14:42:14 | +(_:_:) | DeclRefExpr |
| expressions.swift:42:14:42:14 | Int.Type | TypeExpr |
| expressions.swift:42:14:42:14 | call to +(_:_:) | DotSyntaxCallExpr |
| expressions.swift:42:16:42:16 | y | DeclRefExpr |
| expressions.swift:44:1:44:1 | closured(closure:) | DeclRefExpr |
| expressions.swift:44:1:46:1 | call to closured(closure:) | CallExpr |
| expressions.swift:44:10:46:1 | { ... } | ClosureExpr |
| expressions.swift:45:12:45:12 | x | DeclRefExpr |
| expressions.swift:45:12:45:16 | ... call to +(_:_:) ... | BinaryExpr |
| expressions.swift:45:14:45:14 | +(_:_:) | DeclRefExpr |
| expressions.swift:45:14:45:14 | Int.Type | TypeExpr |
| expressions.swift:45:14:45:14 | call to +(_:_:) | DotSyntaxCallExpr |
| expressions.swift:45:16:45:16 | y | DeclRefExpr |
| expressions.swift:47:1:47:1 | closured(closure:) | DeclRefExpr |
| expressions.swift:47:1:47:27 | call to closured(closure:) | CallExpr |
| expressions.swift:47:10:47:27 | { ... } | ClosureExpr |
| expressions.swift:47:19:47:19 | $0 | DeclRefExpr |
| expressions.swift:47:19:47:24 | ... call to +(_:_:) ... | BinaryExpr |
| expressions.swift:47:22:47:22 | +(_:_:) | DeclRefExpr |
| expressions.swift:47:22:47:22 | Int.Type | TypeExpr |
| expressions.swift:47:22:47:22 | call to +(_:_:) | DotSyntaxCallExpr |
| expressions.swift:47:24:47:24 | $1 | DeclRefExpr |
| expressions.swift:48:1:48:1 | closured(closure:) | DeclRefExpr |
| expressions.swift:48:1:48:20 | call to closured(closure:) | CallExpr |
| expressions.swift:48:10:48:20 | { ... } | ClosureExpr |
| expressions.swift:48:12:48:12 | $0 | DeclRefExpr |
| expressions.swift:48:12:48:17 | ... call to +(_:_:) ... | BinaryExpr |
| expressions.swift:48:15:48:15 | +(_:_:) | DeclRefExpr |
| expressions.swift:48:15:48:15 | Int.Type | TypeExpr |
| expressions.swift:48:15:48:15 | call to +(_:_:) | DotSyntaxCallExpr |
| expressions.swift:48:17:48:17 | $1 | DeclRefExpr |
| expressions.swift:54:1:54:1 | _ | DiscardAssignmentExpr |
| expressions.swift:54:1:54:8 | ... = ... | AssignExpr |
| expressions.swift:54:5:54:8 | #keyPath(...) | KeyPathExpr |
| expressions.swift:54:6:54:6 | (no string representation) | TypeExpr |
| expressions.swift:54:6:54:8 | ... .x | UnresolvedDotExpr |
| expressions.swift:58:16:58:16 | 1234 | IntegerLiteralExpr |
| expressions.swift:59:1:59:1 | unsafeFunction(pointer:) | DeclRefExpr |
| expressions.swift:59:1:59:34 | call to unsafeFunction(pointer:) | CallExpr |
| expressions.swift:59:25:59:26 | &... | InOutExpr |
| expressions.swift:59:25:59:26 | (UnsafePointer<Int>) ... | InOutToPointerExpr |
| expressions.swift:59:26:59:26 | myNumber | DeclRefExpr |
| expressions.swift:60:1:60:1 | withUnsafePointer(to:_:) | DeclRefExpr |
| expressions.swift:60:1:60:63 | call to withUnsafePointer(to:_:) | CallExpr |
| expressions.swift:60:23:60:23 | (Int) ... | LoadExpr |
| expressions.swift:60:23:60:23 | myNumber | DeclRefExpr |
| expressions.swift:60:33:60:63 | ((UnsafePointer<Int>) throws -> ()) ... | FunctionConversionExpr |
| expressions.swift:60:33:60:63 | { ... } | ClosureExpr |
| expressions.swift:60:35:60:35 | unsafeFunction(pointer:) | DeclRefExpr |
| expressions.swift:60:35:60:61 | call to unsafeFunction(pointer:) | CallExpr |
| expressions.swift:60:59:60:59 | $0 | DeclRefExpr |
| expressions.swift:64:8:64:8 | x | DeclRefExpr |
| expressions.swift:64:8:64:12 | ... call to <(_:_:) ... | BinaryExpr |
| expressions.swift:64:10:64:10 | <(_:_:) | DeclRefExpr |
| expressions.swift:64:10:64:10 | Int.Type | TypeExpr |
| expressions.swift:64:10:64:10 | call to <(_:_:) | DotSyntaxCallExpr |
| expressions.swift:64:12:64:12 | 0 | IntegerLiteralExpr |
| expressions.swift:73:5:73:5 | .xx | MemberRefExpr |
| expressions.swift:73:5:73:5 | self | DeclRefExpr |
| expressions.swift:73:5:73:10 | ... = ... | AssignExpr |
| expressions.swift:73:10:73:10 | x | DeclRefExpr |
| expressions.swift:77:7:77:7 | #... | MagicIdentifierLiteralExpr |
| expressions.swift:77:7:77:7 | #... | MagicIdentifierLiteralExpr |
| expressions.swift:77:7:77:7 | #... | MagicIdentifierLiteralExpr |
| expressions.swift:77:7:77:7 | #... | MagicIdentifierLiteralExpr |
| expressions.swift:77:7:77:7 | _unimplementedInitializer(className:initName:file:line:column:) | DeclRefExpr |
| expressions.swift:77:7:77:7 | call to _unimplementedInitializer(className:initName:file:line:column:) | CallExpr |
| expressions.swift:77:7:77:7 | expressions.Derived | StringLiteralExpr |
| expressions.swift:79:5:79:5 | super | SuperRefExpr |
| expressions.swift:79:5:79:11 | call to ... | DotSyntaxCallExpr |
| expressions.swift:79:5:79:21 | call to ... | CallExpr |
| expressions.swift:79:5:79:21 | self = ... | RebindSelfInConstructorExpr |
| expressions.swift:79:11:79:11 | init | OtherConstructorDeclRefExpr |
| expressions.swift:79:19:79:19 | 22 | IntegerLiteralExpr |
| expressions.swift:83:15:83:15 | Derived.Type | TypeExpr |
| expressions.swift:83:15:83:15 | call to init | ConstructorRefCallExpr |
| expressions.swift:83:15:83:15 | init | DeclRefExpr |
| expressions.swift:83:15:83:23 | call to ... | CallExpr |
| expressions.swift:84:1:84:1 | _ | DiscardAssignmentExpr |
| expressions.swift:84:1:84:13 | ... = ... | AssignExpr |
| expressions.swift:84:5:84:5 | (Base) ... | DerivedToBaseExpr |
| expressions.swift:84:5:84:5 | derived | DeclRefExpr |
| expressions.swift:84:5:84:13 | .xx | MemberRefExpr |
| expressions.swift:87:1:87:1 | opt | DeclRefExpr |
| expressions.swift:87:1:87:4 | ...! | ForceValueExpr |
| expressions.swift:88:1:88:1 | d | DeclRefExpr |
| expressions.swift:88:1:88:6 | ...[...] | SubscriptExpr |
| expressions.swift:88:1:88:7 | ...! | ForceValueExpr |
| expressions.swift:88:3:88:3 | a | StringLiteralExpr |
| expressions.swift:92:14:92:14 | Unmanaged<ToPtr>.Type | TypeExpr |
| expressions.swift:92:14:92:24 | call to passRetained(_:) | DotSyntaxCallExpr |
| expressions.swift:92:14:92:44 | call to ... | CallExpr |
| expressions.swift:92:14:92:46 | call to toOpaque() | DotSyntaxCallExpr |
| expressions.swift:92:14:92:55 | call to ... | CallExpr |
| expressions.swift:92:24:92:24 | passRetained(_:) | DeclRefExpr |
| expressions.swift:92:37:92:37 | ToPtr.Type | TypeExpr |
| expressions.swift:92:37:92:37 | call to init | ConstructorRefCallExpr |
| expressions.swift:92:37:92:37 | init | DeclRefExpr |
| expressions.swift:92:37:92:43 | call to ... | CallExpr |
| expressions.swift:92:46:92:46 | toOpaque() | DeclRefExpr |
| expressions.swift:93:1:93:16 | Unmanaged<ToPtr>.Type | TypeExpr |
| expressions.swift:93:1:93:18 | call to fromOpaque(_:) | DotSyntaxCallExpr |
| expressions.swift:93:1:93:35 | call to ... | CallExpr |
| expressions.swift:93:18:93:18 | fromOpaque(_:) | DeclRefExpr |
| expressions.swift:93:29:93:29 | (UnsafeRawPointer) ... | PointerToPointerExpr |
| expressions.swift:93:29:93:29 | opaque | DeclRefExpr |
| expressions.swift:99:14:99:14 | 0 | IntegerLiteralExpr |
| expressions.swift:106:12:106:12 | 0 | IntegerLiteralExpr |
| expressions.swift:112:14:112:14 | 0 | IntegerLiteralExpr |
| expressions.swift:120:14:120:14 | 0 | IntegerLiteralExpr |
| expressions.swift:126:12:126:12 | 0 | IntegerLiteralExpr |
| expressions.swift:131:3:131:3 | hp | DeclRefExpr |
| expressions.swift:131:3:131:6 | .settableField | MemberRefExpr |
| expressions.swift:131:3:131:22 | ... = ... | AssignExpr |
| expressions.swift:131:22:131:22 | 42 | IntegerLiteralExpr |
| expressions.swift:132:11:132:11 | hp | DeclRefExpr |
| expressions.swift:132:11:132:14 | (Int) ... | LoadExpr |
| expressions.swift:132:11:132:14 | .settableField | MemberRefExpr |
| expressions.swift:133:11:133:11 | (HasProperty) ... | LoadExpr |
| expressions.swift:133:11:133:11 | hp | DeclRefExpr |
| expressions.swift:133:11:133:14 | .readOnlyField1 | MemberRefExpr |
| expressions.swift:134:11:134:11 | (HasProperty) ... | LoadExpr |
| expressions.swift:134:11:134:11 | hp | DeclRefExpr |
| expressions.swift:134:11:134:14 | .readOnlyField2 | MemberRefExpr |
| expressions.swift:135:3:135:3 | hp | DeclRefExpr |
| expressions.swift:135:3:135:6 | .normalField | MemberRefExpr |
| expressions.swift:135:3:135:20 | ... = ... | AssignExpr |
| expressions.swift:135:20:135:20 | 99 | IntegerLiteralExpr |
| expressions.swift:136:11:136:11 | hp | DeclRefExpr |
| expressions.swift:136:11:136:14 | (Int) ... | LoadExpr |
| expressions.swift:136:11:136:14 | .normalField | MemberRefExpr |
| expressions.swift:137:3:137:3 | &... | InOutExpr |
| expressions.swift:137:3:137:3 | hp | DeclRefExpr |
| expressions.swift:137:3:137:7 | ...[...] | SubscriptExpr |
| expressions.swift:137:3:137:11 | ... = ... | AssignExpr |
| expressions.swift:137:6:137:6 | 1 | IntegerLiteralExpr |
| expressions.swift:137:11:137:11 | 2 | IntegerLiteralExpr |
| expressions.swift:138:10:138:10 | (HasProperty) ... | LoadExpr |
| expressions.swift:138:10:138:10 | hp | DeclRefExpr |
| expressions.swift:138:10:138:17 | ...[...] | SubscriptExpr |
| expressions.swift:138:13:138:13 | 3 | IntegerLiteralExpr |
| expressions.swift:138:16:138:16 | 4 | IntegerLiteralExpr |
| expressions.swift:152:26:152:26 | a | DeclRefExpr |
| expressions.swift:152:26:152:47 | \\...[...] | KeyPathApplicationExpr |
| expressions.swift:152:37:152:37 | keyPathInt | DeclRefExpr |
| expressions.swift:153:24:153:24 | a | DeclRefExpr |
| expressions.swift:153:24:153:43 | \\...[...] | KeyPathApplicationExpr |
| expressions.swift:153:35:153:35 | keyPathB | DeclRefExpr |
| expressions.swift:154:22:154:22 | a | DeclRefExpr |
| expressions.swift:154:22:154:41 | \\...[...] | KeyPathApplicationExpr |
| expressions.swift:154:22:154:56 | \\...[...] | KeyPathApplicationExpr |
| expressions.swift:154:33:154:33 | keyPathB | DeclRefExpr |
| expressions.swift:154:52:154:55 | #keyPath(...) | KeyPathExpr |
| expressions.swift:154:53:154:53 | (no string representation) | TypeExpr |
| expressions.swift:154:53:154:55 | ... .x | UnresolvedDotExpr |

View File

@@ -2,4 +2,4 @@ import swift
from Expr expr
where expr.getLocation().getFile().getName().matches("%swift/ql/test%")
select expr
select expr, expr.getPrimaryQlClasses()

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,2 @@
@interface MyClass : NSObject
@property int foo @end

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,2 @@
| dotself.swift:4:9:4:14 | .self | getSubExpr: | dotself.swift:4:9:4:9 | self |
| dotself.swift:4:9:4:21 | .self | getSubExpr: | dotself.swift:4:9:4:19 | .x |

View File

@@ -0,0 +1,10 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from DotSelfExpr x, Expr getSubExpr
where
toBeTested(x) and
not x.isUnknown() and
getSubExpr = x.getSubExpr()
select x, "getSubExpr:", getSubExpr

View File

@@ -0,0 +1,2 @@
| dotself.swift:4:9:4:14 | .self | A |
| dotself.swift:4:9:4:21 | .self | @lvalue Int |

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from DotSelfExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,6 @@
class A {
var x: Int
init() {
self.self.x.self = 42
}
}

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -0,0 +1,3 @@
| unresolved_dot_expr.swift:5:6:5:8 | ... .x | getBase: | unresolved_dot_expr.swift:5:6:5:6 | (no string representation) | getName: | x |
| unresolved_dot_expr.swift:11:6:11:8 | ... .a | getBase: | unresolved_dot_expr.swift:11:6:11:6 | (no string representation) | getName: | a |
| unresolved_dot_expr.swift:11:6:11:10 | ... .x | getBase: | unresolved_dot_expr.swift:11:6:11:8 | ... .a | getName: | x |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from UnresolvedDotExpr x, Expr getBase, string getName
where
toBeTested(x) and
not x.isUnknown() and
getBase = x.getBase() and
getName = x.getName()
select x, "getBase:", getBase, "getName:", getName

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from UnresolvedDotExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()

View File

@@ -0,0 +1,11 @@
struct A {
var x: Int = 42
}
_ = \A.x
struct B {
var a: A
}
_ = \B.a.x

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -1,4 +0,0 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -936,11 +936,14 @@ cfg.swift:
#-----| -> n2
# 112| n2
#-----| match -> .self
#-----| match -> c
# 112| n2
#-----| -> n3
# 112| c
#-----| -> .self
# 112| .self
#-----| -> getter for .myInt
@@ -977,6 +980,9 @@ cfg.swift:
# 114| n4
#-----| -> n5
# 114| c
#-----| -> .self
# 114| .self
#-----| -> call to getMyInt()
@@ -987,7 +993,7 @@ cfg.swift:
#-----| -> var ... = ...
# 114| getMyInt()
#-----| -> .self
#-----| -> c
# 116| var ... = ...
#-----| -> n5
@@ -1008,11 +1014,14 @@ cfg.swift:
#-----| -> n6
# 117| n6
#-----| match -> .self
#-----| match -> param
# 117| n6
#-----| -> n7
# 117| param
#-----| -> .self
# 117| .self
#-----| -> getter for .myInt
@@ -1049,6 +1058,9 @@ cfg.swift:
# 119| n8
#-----| -> n9
# 119| param
#-----| -> .self
# 119| .self
#-----| -> call to getMyInt()
@@ -1059,7 +1071,7 @@ cfg.swift:
#-----| -> var ... = ...
# 119| getMyInt()
#-----| -> .self
#-----| -> param
# 121| var ... = ...
#-----| -> n9
@@ -1083,11 +1095,14 @@ cfg.swift:
#-----| -> n10
# 122| n10
#-----| match -> .self
#-----| match -> inoutParam
# 122| n10
#-----| -> n11
# 122| inoutParam
#-----| -> .self
# 122| (C) ...
#-----| -> getter for .myInt
@@ -1130,6 +1145,9 @@ cfg.swift:
# 124| n12
#-----| -> n13
# 124| inoutParam
#-----| -> .self
# 124| (C) ...
#-----| -> call to getMyInt()
@@ -1143,7 +1161,7 @@ cfg.swift:
#-----| -> var ... = ...
# 124| getMyInt()
#-----| -> .self
#-----| -> inoutParam
# 126| var ... = ...
#-----| -> n13
@@ -1167,11 +1185,17 @@ cfg.swift:
#-----| -> n14
# 127| n14
#-----| match -> .self
#-----| match -> opt
# 127| n14
#-----| -> n15
# 127| opt
#-----| -> ...!
# 127| ...!
#-----| -> .self
# 127| .self
#-----| -> getter for .myInt
@@ -1211,6 +1235,12 @@ cfg.swift:
# 129| n16
#-----| -> n17
# 129| opt
#-----| -> ...!
# 129| ...!
#-----| -> .self
# 129| .self
#-----| -> call to getMyInt()
@@ -1221,7 +1251,7 @@ cfg.swift:
#-----| -> var ... = ...
# 129| getMyInt()
#-----| -> .self
#-----| -> opt
# 131| var ... = ...
#-----| -> n17
@@ -1251,11 +1281,17 @@ cfg.swift:
#-----| -> n18
# 132| n18
#-----| match -> .self
#-----| match -> opt
# 132| n18
#-----| -> n19
# 132| opt
#-----| -> ...?
# 132| ...?
#-----| -> .self
# 132| .self
#-----| -> getter for .myInt
@@ -1307,6 +1343,12 @@ cfg.swift:
# 134| n20
#-----| -> exit testMemberRef(param:inoutParam:opt:) (normal)
# 134| opt
#-----| -> ...?
# 134| ...?
#-----| -> .self
# 134| .self
#-----| -> call to getMyInt()
@@ -1323,7 +1365,7 @@ cfg.swift:
#-----| -> (Int?) ...
# 134| getMyInt()
#-----| -> .self
#-----| -> opt
# 137| enter patterns(x:)
#-----| -> patterns(x:)
@@ -5259,17 +5301,6 @@ cfg.swift:
# 419| #keyPath(...)
#-----| -> var ... = ...
# 419| enter #keyPath(...)
#-----| -> UnresolvedDotExpr
# 419| exit #keyPath(...)
# 419| exit #keyPath(...) (normal)
#-----| -> exit #keyPath(...)
# 419| UnresolvedDotExpr
#-----| -> exit #keyPath(...) (normal)
# 420| var ... = ...
#-----| -> kpGet_bs_0_x
@@ -5282,17 +5313,6 @@ cfg.swift:
# 420| #keyPath(...)
#-----| -> var ... = ...
# 420| enter #keyPath(...)
#-----| -> UnresolvedDotExpr
# 420| exit #keyPath(...)
# 420| exit #keyPath(...) (normal)
#-----| -> exit #keyPath(...)
# 420| UnresolvedDotExpr
#-----| -> exit #keyPath(...) (normal)
# 421| var ... = ...
#-----| -> kpGet_mayB_force_x
@@ -5305,17 +5325,6 @@ cfg.swift:
# 421| #keyPath(...)
#-----| -> var ... = ...
# 421| enter #keyPath(...)
#-----| -> UnresolvedDotExpr
# 421| exit #keyPath(...)
# 421| exit #keyPath(...) (normal)
#-----| -> exit #keyPath(...)
# 421| UnresolvedDotExpr
#-----| -> exit #keyPath(...) (normal)
# 422| var ... = ...
#-----| -> kpGet_mayB_x
@@ -5328,20 +5337,6 @@ cfg.swift:
# 422| #keyPath(...)
#-----| -> var ... = ...
# 422| enter #keyPath(...)
#-----| -> UnresolvedDotExpr
# 422| exit #keyPath(...)
# 422| exit #keyPath(...) (normal)
#-----| -> exit #keyPath(...)
# 422| OptionalEvaluationExpr
#-----| -> exit #keyPath(...) (normal)
# 422| UnresolvedDotExpr
#-----| -> OptionalEvaluationExpr
# 424| var ... = ...
#-----| -> apply_kpGet_b_x

View File

@@ -513,7 +513,9 @@
| expressions.swift:54:1:54:8 | ... = ... | AssignExpr | expressions.swift:54:5:54:8 | #keyPath(...) | KeyPathExpr |
| expressions.swift:54:1:54:8 | { ... } | BraceStmt | expressions.swift:54:1:54:8 | ... = ... | AssignExpr |
| expressions.swift:54:1:54:8 | { ... } | TopLevelCodeDecl | expressions.swift:54:1:54:8 | { ... } | BraceStmt |
| expressions.swift:54:5:54:8 | #keyPath(...) | KeyPathExpr | expressions.swift:54:6:54:8 | UnresolvedDotExpr | UnresolvedDotExpr |
| expressions.swift:54:5:54:8 | #keyPath(...) | KeyPathExpr | expressions.swift:54:6:54:8 | ... .x | UnresolvedDotExpr |
| expressions.swift:54:6:54:6 | (no string representation) | TypeExpr | expressions.swift:54:6:54:6 | SimpleIdentTypeRepr | SimpleIdentTypeRepr |
| expressions.swift:54:6:54:8 | ... .x | UnresolvedDotExpr | expressions.swift:54:6:54:6 | (no string representation) | TypeExpr |
| expressions.swift:56:1:57:1 | unsafeFunction(pointer:) | ConcreteFuncDecl | expressions.swift:56:21:56:47 | pointer | ParamDecl |
| expressions.swift:56:1:57:1 | unsafeFunction(pointer:) | ConcreteFuncDecl | expressions.swift:56:50:57:1 | { ... } | BraceStmt |
| expressions.swift:58:1:58:16 | var ... = ... | PatternBindingDecl | expressions.swift:58:5:58:5 | myNumber | NamedPattern |
@@ -812,7 +814,9 @@
| expressions.swift:154:22:154:41 | \\...[...] | KeyPathApplicationExpr | expressions.swift:154:33:154:33 | keyPathB | DeclRefExpr |
| expressions.swift:154:22:154:56 | \\...[...] | KeyPathApplicationExpr | expressions.swift:154:22:154:41 | \\...[...] | KeyPathApplicationExpr |
| expressions.swift:154:22:154:56 | \\...[...] | KeyPathApplicationExpr | expressions.swift:154:52:154:55 | #keyPath(...) | KeyPathExpr |
| expressions.swift:154:52:154:55 | #keyPath(...) | KeyPathExpr | expressions.swift:154:53:154:55 | UnresolvedDotExpr | UnresolvedDotExpr |
| expressions.swift:154:52:154:55 | #keyPath(...) | KeyPathExpr | expressions.swift:154:53:154:55 | ... .x | UnresolvedDotExpr |
| expressions.swift:154:53:154:53 | (no string representation) | TypeExpr | expressions.swift:154:53:154:53 | SimpleIdentTypeRepr | SimpleIdentTypeRepr |
| expressions.swift:154:53:154:55 | ... .x | UnresolvedDotExpr | expressions.swift:154:53:154:53 | (no string representation) | TypeExpr |
| patterns.swift:1:1:7:1 | basic_patterns() | ConcreteFuncDecl | patterns.swift:1:23:7:1 | { ... } | BraceStmt |
| patterns.swift:1:23:7:1 | { ... } | BraceStmt | patterns.swift:2:5:2:18 | var ... = ... | PatternBindingDecl |
| patterns.swift:1:23:7:1 | { ... } | BraceStmt | patterns.swift:2:9:2:9 | an_int | ConcreteVarDecl |
@@ -881,6 +885,9 @@
| patterns.swift:16:5:16:17 | case ... | CaseStmt | patterns.swift:16:17:16:17 | { ... } | BraceStmt |
| patterns.swift:16:10:16:14 | SequenceExpr | CaseLabelItem | patterns.swift:16:10:16:14 | SequenceExpr | ExprPattern |
| patterns.swift:16:10:16:14 | SequenceExpr | ExprPattern | patterns.swift:16:10:16:14 | SequenceExpr | SequenceExpr |
| patterns.swift:16:10:16:14 | SequenceExpr | SequenceExpr | patterns.swift:16:10:16:10 | 1 | IntegerLiteralExpr |
| patterns.swift:16:10:16:14 | SequenceExpr | SequenceExpr | patterns.swift:16:12:16:12 | OverloadedDeclRefExpr | OverloadedDeclRefExpr |
| patterns.swift:16:10:16:14 | SequenceExpr | SequenceExpr | patterns.swift:16:14:16:14 | 2 | IntegerLiteralExpr |
| patterns.swift:16:17:16:17 | { ... } | BraceStmt | patterns.swift:16:17:16:17 | expr | StringLiteralExpr |
| patterns.swift:17:5:17:13 | case ... | CaseStmt | patterns.swift:17:10:17:10 | _ | CaseLabelItem |
| patterns.swift:17:5:17:13 | case ... | CaseStmt | patterns.swift:17:13:17:13 | { ... } | BraceStmt |