From 86239fc2ddc0824edefb558b6dce53b19dd007bd Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:24:00 +0100 Subject: [PATCH] fixed files form Closure #85 --- .../jscomp/UnreachableCodeElimination.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/projects/Closure/85/com/google/javascript/jscomp/UnreachableCodeElimination.java b/projects/Closure/85/com/google/javascript/jscomp/UnreachableCodeElimination.java index c2150b1..e6d4320 100644 --- a/projects/Closure/85/com/google/javascript/jscomp/UnreachableCodeElimination.java +++ b/projects/Closure/85/com/google/javascript/jscomp/UnreachableCodeElimination.java @@ -150,20 +150,7 @@ private Node tryRemoveUnconditionalBranching(Node n) { return n; } - if (n.getParent() == null) { - List> outEdges = gNode.getOutEdges(); - if (outEdges.size() == 1) { - return tryRemoveUnconditionalBranching(outEdges.get(0).getDestination().getValue()); - } - } switch (n.getType()) { - case Token.BLOCK: - if (n.hasChildren()) { - Node first = n.getFirstChild(); - return tryRemoveUnconditionalBranching(first); - } else { - return tryRemoveUnconditionalBranching(ControlFlowAnalysis.computeFollowNode(n)); - } case Token.RETURN: if (n.hasChildren()) { break; @@ -180,7 +167,7 @@ private Node tryRemoveUnconditionalBranching(Node n) { (n.getNext() == null || n.getNext().getType() == Token.FUNCTION)) { Preconditions.checkState(outEdges.get(0).getValue() == Branch.UNCOND); - Node fallThrough = tryRemoveUnconditionalBranching(computeFollowing(n)); + Node fallThrough = computeFollowing(n); Node nextCfgNode = outEdges.get(0).getDestination().getValue(); if (nextCfgNode == fallThrough) { removeDeadExprStatementSafely(n); @@ -193,6 +180,13 @@ private Node tryRemoveUnconditionalBranching(Node n) { private Node computeFollowing(Node n) { Node next = ControlFlowAnalysis.computeFollowNode(n); + while (next != null && next.getType() == Token.BLOCK) { + if (next.hasChildren()) { + next = next.getFirstChild(); + } else { + next = computeFollowing(next); + } + } return next; }