Skip to content

Commit 54ac367

Browse files
authored
Merge pull request github#9284 from MathiasVP/more-cfg-for-exprs
Swift: CFG for `TypeExpr`, `MemberRefExpr`, `DefaultArgumentExpr` and `ForceValueExpr`
2 parents 98ef223 + 3e1a6a7 commit 54ac367

File tree

2 files changed

+641
-110
lines changed

2 files changed

+641
-110
lines changed

swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ module Exprs {
908908
}
909909
}
910910

911+
private class TypeTree extends LeafTree instanceof TypeExpr { }
912+
911913
private class DynamicTypeTree extends StandardPostOrderTree instanceof DynamicTypeExpr {
912914
final override ControlFlowTree getChildElement(int i) {
913915
result = super.getBaseExpr().getFullyConverted() and i = 0
@@ -951,7 +953,13 @@ module Exprs {
951953
}
952954
}
953955

954-
private class DeclRefExprTree extends LeafTree, DeclRefExpr { }
956+
private class DeclRefExprTree extends LeafTree instanceof DeclRefExpr { }
957+
958+
private class MemberRefTree extends StandardPostOrderTree instanceof MemberRefExpr {
959+
final override AstNode getChildElement(int i) {
960+
result = super.getBaseExpr().getFullyConverted() and i = 0
961+
}
962+
}
955963

956964
private class ApplyExprTree extends StandardPostOrderTree instanceof ApplyExpr {
957965
ApplyExprTree() {
@@ -969,6 +977,15 @@ module Exprs {
969977
}
970978
}
971979

980+
private class DefaultArgumentTree extends LeafTree instanceof DefaultArgumentExpr { }
981+
982+
private class ForceValueTree extends StandardPostOrderTree instanceof ForceValueExpr {
983+
override AstNode getChildElement(int i) {
984+
i = 0 and
985+
result = super.getSubExpr().getFullyConverted()
986+
}
987+
}
988+
972989
private class LogicalAndTree extends PostOrderTree, LogicalAndExpr {
973990
final override predicate propagatesAbnormal(AstNode child) {
974991
child = this.getAnOperand().getFullyConverted()

0 commit comments

Comments
 (0)