Skip to content

Commit b1e85d1

Browse files
committed
Rust: Refactor BreakExprTree to use StandardPostOrderTree
1 parent 28f111b commit b1e85d1

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,15 @@ class BlockExprTree extends StandardPostOrderTree, BlockExpr {
147147
override predicate propagatesAbnormal(AstNode child) { child = this.getChildNode(_) }
148148
}
149149

150-
class BreakExprTree extends PostOrderTree, BreakExpr {
151-
override predicate propagatesAbnormal(AstNode child) { child = this.getExpr() }
152-
153-
override predicate first(AstNode node) {
154-
first(this.getExpr(), node)
155-
or
156-
not this.hasExpr() and node = this
157-
}
150+
class BreakExprTree extends StandardPostOrderTree, BreakExpr {
151+
override AstNode getChildNode(int i) { i = 0 and result = this.getExpr() }
158152

159153
override predicate last(AstNode last, Completion c) { none() }
160154

161155
override predicate succ(AstNode pred, AstNode succ, Completion c) {
162-
last(super.getExpr(), pred, c) and completionIsNormal(c) and succ = this
156+
super.succ(pred, succ, c)
163157
or
164-
pred = this and
165-
c.isValidFor(pred) and
166-
succ = this.getTarget()
158+
pred = this and c.isValidFor(pred) and succ = this.getTarget()
167159
}
168160
}
169161

0 commit comments

Comments
 (0)