Merge pull request #9546 from github/alexdenisov/extract-OtherConstructorDeclRefExpr

Swift: extract OtherConstructorDeclRefExpr
This commit is contained in:
AlexDenisov
2022-06-14 13:11:18 +02:00
committed by GitHub
8 changed files with 24 additions and 8 deletions

View File

@@ -471,6 +471,7 @@ OptionalEvaluationExpr:
sub_expr: Expr
OtherConstructorDeclRefExpr:
constructor_decl: ConstructorDecl
_extends: Expr
OverloadSetRefExpr:

View File

@@ -518,13 +518,21 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
auto label = dispatcher_.assignNewLabel(expr);
assert(expr->getBase() && "KeyPathApplicationExpr has getBase()");
assert(expr->getKeyPath() && "KeyPathApplicationExpr has getKeyPath()");
auto baseLabel = dispatcher_.fetchLabel(expr->getBase());
auto keyPathLabel = dispatcher_.fetchLabel(expr->getKeyPath());
dispatcher_.emit(KeyPathApplicationExprsTrap{label, baseLabel, keyPathLabel});
}
void visitOtherConstructorDeclRefExpr(swift::OtherConstructorDeclRefExpr* expr) {
auto label = dispatcher_.assignNewLabel(expr);
assert(expr->getDecl() && "OtherConstructorDeclRefExpr has getDecl()");
auto ctorLabel = dispatcher_.fetchLabel(expr->getDecl());
dispatcher_.emit(OtherConstructorDeclRefExprsTrap{label, ctorLabel});
}
private:
TrapLabel<ArgumentTag> emitArgument(const swift::Argument& arg) {
auto argLabel = dispatcher_.createLabel<ArgumentTag>();

View File

@@ -1292,6 +1292,10 @@ module Exprs {
DeclRefExprLValueTree() { isLValue(ast) }
}
class OtherConstructorDeclRefTree extends AstLeafTree {
override OtherConstructorDeclRefExpr ast;
}
abstract class DeclRefExprRValueTree extends AstControlFlowTree {
override DeclRefExpr ast;

View File

@@ -1,6 +1,14 @@
// generated by codegen/codegen.py
import codeql.swift.elements.decl.ConstructorDecl
import codeql.swift.elements.expr.Expr
class OtherConstructorDeclRefExprBase extends @other_constructor_decl_ref_expr, Expr {
override string getAPrimaryQlClass() { result = "OtherConstructorDeclRefExpr" }
ConstructorDecl getConstructorDecl() {
exists(ConstructorDecl x |
other_constructor_decl_ref_exprs(this, x) and
result = x.resolve()
)
}
}

View File

@@ -975,7 +975,8 @@ optional_evaluation_exprs(
);
other_constructor_decl_ref_exprs(
unique int id: @other_constructor_decl_ref_expr
unique int id: @other_constructor_decl_ref_expr,
int constructor_decl: @constructor_decl ref
);
@overload_set_ref_expr =

View File

@@ -162,7 +162,6 @@
| 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 | TBD (OtherConstructorDeclRefExpr) |
| expressions.swift:79:11:79:11 | call to ... |
| expressions.swift:79:19:79:19 | 22 |
| expressions.swift:83:15:83:15 | Derived.Type |

View File

@@ -4944,7 +4944,6 @@ cfg.swift:
# 378| init
#-----| -> call to ...
#-----| -> TBD (OtherConstructorDeclRefExpr)
# 379| super
#-----| -> call to ...
@@ -4961,9 +4960,6 @@ cfg.swift:
# 379| call to ...
#-----| -> super
# 379| TBD (OtherConstructorDeclRefExpr)
#-----| -> super
# 379| 0
#-----| -> call to ...

View File

@@ -566,7 +566,6 @@
| expressions.swift:78:3:80:3 | init | ConstructorDecl | expressions.swift:78:10:80:3 | { ... } | BraceStmt |
| expressions.swift:78:10:80:3 | { ... } | BraceStmt | expressions.swift:79:5:79:21 | self = ... | RebindSelfInConstructorExpr |
| expressions.swift:78:10:80:3 | { ... } | BraceStmt | expressions.swift:80:3:80:3 | return | ReturnStmt |
| expressions.swift:79:5:79:11 | call to ... | DotSyntaxCallExpr | expressions.swift:79:11:79:11 | TBD (OtherConstructorDeclRefExpr) | OtherConstructorDeclRefExpr |
| expressions.swift:79:5:79:11 | call to ... | DotSyntaxCallExpr | expressions.swift:79:11:79:11 | call to ... | OtherConstructorDeclRefExpr |
| expressions.swift:79:5:79:21 | call to ... | CallExpr | expressions.swift:79:5:79:11 | call to ... | DotSyntaxCallExpr |
| expressions.swift:79:5:79:21 | self = ... | RebindSelfInConstructorExpr | expressions.swift:78:3:78:3 | self | ParamDecl |