Rust: Replace getBlockChildNode with uses of getStmtOrExpr.

This commit is contained in:
Geoffrey White
2025-09-26 14:32:05 +01:00
parent 27b6f12b3c
commit 4570d7e46e

View File

@@ -266,15 +266,8 @@ module ExprTrees {
}
}
private AstNode getBlockChildNode(BlockExpr b, int i) {
result = b.getStmtList().getStatement(i)
or
i = b.getStmtList().getNumberOfStatements() and
result = b.getStmtList().getTailExpr()
}
class AsyncBlockExprTree extends StandardTree, PreOrderTree, PostOrderTree, AsyncBlockExpr {
override AstNode getChildNode(int i) { result = getBlockChildNode(this, i) }
override AstNode getChildNode(int i) { result = this.getStmtList().getStmtOrExpr(i) }
override predicate propagatesAbnormal(AstNode child) { none() }
}
@@ -282,7 +275,7 @@ module ExprTrees {
class BlockExprTree extends StandardPostOrderTree, BlockExpr {
BlockExprTree() { not this.isAsync() }
override AstNode getChildNode(int i) { result = getBlockChildNode(this, i) }
override AstNode getChildNode(int i) { result = this.getStmtList().getStmtOrExpr(i) }
override predicate propagatesAbnormal(AstNode child) { child = this.getChildNode(_) }
}