Skip to content

Commit cb91dc1

Browse files
committed
C#: Rank StandardStmt::getChildElement()
1 parent f0f5d44 commit cb91dc1

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

csharp/ql/src/semmle/code/csharp/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ module Statements {
940940
not this instanceof JumpStmt
941941
}
942942

943-
final override ControlFlowTree getChildElement(int i) {
943+
private ControlFlowTree getChildElement0(int i) {
944944
not this instanceof GeneralCatchClause and
945945
not this instanceof FixedStmt and
946946
not this instanceof UsingBlockStmt and
@@ -959,25 +959,24 @@ module Statements {
959959
or
960960
this =
961961
any(UsingBlockStmt us |
962-
if exists(us.getExpr())
963-
then (
964-
result = us.getExpr() and
965-
i = 0
966-
or
967-
result = us.getBody() and
968-
i = 1
969-
) else (
970-
result = us.getVariableDeclExpr(i)
971-
or
972-
result = us.getBody() and
973-
i = max(int j | exists(us.getVariableDeclExpr(j))) + 1
974-
)
962+
result = us.getExpr() and
963+
i = 0
964+
or
965+
result = us.getVariableDeclExpr(i)
966+
or
967+
result = us.getBody() and
968+
i = max([1, count(us.getVariableDeclExpr(_))])
975969
)
976970
or
977971
result = this.(DefaultCase).getStmt() and
978972
i = 0
979973
}
980974

975+
final override ControlFlowTree getChildElement(int i) {
976+
result =
977+
rank[i + 1](ControlFlowElement cfe, int j | cfe = this.getChildElement0(j) | cfe order by j)
978+
}
979+
981980
final override predicate last(ControlFlowElement last, Completion c) {
982981
last(this.getLastChild(), last, c)
983982
or

0 commit comments

Comments
 (0)