Skip to content

Commit

Permalink
Fix change tracking in DAE
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152846140
  • Loading branch information
concavelenz authored and brad4d committed Apr 12, 2017
1 parent b4aafc1 commit 8239099
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Expand Up @@ -254,7 +254,7 @@ private void tryRemoveAssignment(NodeTraversal t, Node n, Node exprRoot,
n.isAssign()) { n.isAssign()) {
n.removeChild(rhs); n.removeChild(rhs);
n.replaceWith(rhs); n.replaceWith(rhs);
compiler.reportCodeChange(); compiler.reportChangeToEnclosingScope(rhs);
return; return;
} }


Expand Down Expand Up @@ -307,7 +307,7 @@ private void tryRemoveAssignment(NodeTraversal t, Node n, Node exprRoot,
throw new IllegalStateException("Unknown statement"); throw new IllegalStateException("Unknown statement");
} }


compiler.reportCodeChange(); compiler.reportChangeToEnclosingScope(parent);
return; return;
} else { } else {
for (Node c = n.getFirstChild(); c != null;) { for (Node c = n.getFirstChild(); c != null;) {
Expand Down
Expand Up @@ -28,11 +28,6 @@ public DeadAssignmentsEliminationTest() {
super("var extern;"); super("var extern;");
} }


@Override
public void setUp() {
validateAstChangeMarking(false);
}

@Override @Override
public CompilerPass getProcessor(final Compiler compiler) { public CompilerPass getProcessor(final Compiler compiler) {
return new CompilerPass() { return new CompilerPass() {
Expand Down Expand Up @@ -164,7 +159,11 @@ public void testErrorHandling() {
"var x; try{1;throw 1;x} finally{x=2}; x"); "var x; try{1;throw 1;x} finally{x=2}; x");
} }


public void testDeadVarDeclarations() { public void testDeadVarDeclarations1() {
inFunction("var x=1; x=2; x", "var x; 1; x=2; x");
}

public void testDeadVarDeclarations2() {
inFunction("var x=1;"); inFunction("var x=1;");
inFunction("var x=1; x=2; x", "var x; 1; x=2; x"); inFunction("var x=1; x=2; x", "var x; 1; x=2; x");
inFunction("var x=1, y=10; x=2; x", "var x, y; 1; 10; x=2; x"); inFunction("var x=1, y=10; x=2; x", "var x, y; 1; 10; x=2; x");
Expand Down Expand Up @@ -461,6 +460,9 @@ public void testIssue297h() {
"};"); "};");
} }


public void testInExpression0() {
inFunction("var a; return a=(a=(a=a));", "var a; return a;");
}


public void testInExpression1() { public void testInExpression1() {
inFunction("var a; return a=(a=(a=3));", "var a; return 3;"); inFunction("var a; return a=(a=(a=3));", "var a; return 3;");
Expand Down

0 comments on commit 8239099

Please sign in to comment.