fix cfg and dataflow for logical compound assignments

This commit is contained in:
Erik Krogh Kristensen
2021-08-10 12:17:59 +02:00
parent d658ef1dcd
commit 01a202fa10
4 changed files with 33 additions and 6 deletions

View File

@@ -1659,7 +1659,7 @@ public class CFGExtractor {
@Override
public Void visit(AssignmentExpression nd, SuccessorInfo i) {
// `a &&= b` expands to `a || (a = b);`
// `a &&= b` expands to `a && (a = b);`
// The CFG is a conditional assignment, so we go through the assignment `nd` last.
if ("&&=".equals(nd.getOperator()) || "||=".equals(nd.getOperator()) || "??=".equals(nd.getOperator())) {
if ("&&=".equals(nd.getOperator())) {
@@ -1673,7 +1673,7 @@ public class CFGExtractor {
visitWithSuccessors(nd.getLeft(), union(First.of(nd.getRight()), i.getAllSuccessors()));
}
visitWithSuccessors(nd.getRight(), First.of(nd)); // from right to assignment.
visitWithSuccessors(nd.getRight(), nd); // from right to assignment.
writeSuccessors(nd, i.getGuardedSuccessors(nd));
} else {