From b1e85d1ad8de352176fa1813a6a39bbca0035ce9 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Fri, 18 Oct 2024 13:30:36 +0200 Subject: [PATCH] Rust: Refactor `BreakExprTree` to use `StandardPostOrderTree` --- .../internal/ControlFlowGraphImpl.qll | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll index cbf636bd9f00..11ac25133bef 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll @@ -147,23 +147,15 @@ class BlockExprTree extends StandardPostOrderTree, BlockExpr { override predicate propagatesAbnormal(AstNode child) { child = this.getChildNode(_) } } -class BreakExprTree extends PostOrderTree, BreakExpr { - override predicate propagatesAbnormal(AstNode child) { child = this.getExpr() } - - override predicate first(AstNode node) { - first(this.getExpr(), node) - or - not this.hasExpr() and node = this - } +class BreakExprTree extends StandardPostOrderTree, BreakExpr { + override AstNode getChildNode(int i) { i = 0 and result = this.getExpr() } override predicate last(AstNode last, Completion c) { none() } override predicate succ(AstNode pred, AstNode succ, Completion c) { - last(super.getExpr(), pred, c) and completionIsNormal(c) and succ = this + super.succ(pred, succ, c) or - pred = this and - c.isValidFor(pred) and - succ = this.getTarget() + pred = this and c.isValidFor(pred) and succ = this.getTarget() } }