Skip to content

Commit c821ec2

Browse files
committed
Rust: CFG edge for return in functions
1 parent e1f2fa8 commit c821ec2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,16 @@ module CfgImpl = Make<Location, CfgInput>;
6363

6464
import CfgImpl
6565

66-
class FunctionTree extends StandardPostOrderTree instanceof Function {
67-
override ControlFlowTree getChildNode(int i) { i = 0 and result = super.getBody() }
66+
class FunctionTree extends PostOrderTree instanceof Function {
67+
override predicate propagatesAbnormal(AstNode child) { child = super.getBody() }
68+
69+
override predicate first(AstNode node) { first(super.getBody(), node) }
70+
71+
override predicate succ(AstNode pred, AstNode succ, Completion c) {
72+
last(super.getBody(), pred, c) and
73+
(completionIsNormal(c) or c instanceof ReturnCompletion) and
74+
succ = this
75+
}
6876
}
6977

7078
class BlockExprTree extends StandardPostOrderTree instanceof BlockExpr {

0 commit comments

Comments
 (0)