Restrict assigment flow to normal assignments only

This commit is contained in:
Arthur Baars
2021-02-03 15:16:14 +01:00
parent 8368a39f00
commit f8cca01e6f
2 changed files with 6 additions and 1 deletions

View File

@@ -193,6 +193,11 @@ module ExprNodes {
final ExprCfgNode getRhs() { e.hasCfgChild(e.getRhs(), this, result) }
}
/** A control-flow node that wraps an `AssignExpr` AST expression. */
class AssignExprCfgNode extends AssignmentCfgNode {
AssignExprCfgNode() { this.getExpr() instanceof AssignExpr }
}
private class BinaryOperationExprChildMapping extends ExprChildMapping, BinaryOperation {
override predicate relevantChild(Expr e) { e = this.getAnOperand() }
}

View File

@@ -123,7 +123,7 @@ private module Cached {
predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
exists(Ssa::Definition def | LocalFlow::localSsaFlowStep(def, nodeFrom, nodeTo))
or
nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::AssignmentCfgNode).getRhs()
nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::AssignExprCfgNode).getRhs()
}
cached