Remove RemoveAllTreeNodes, since it was a no-op

IntermNode operator delete() or any of the IntermNode destructors don't
do anything, since all the AST memory is allocated on the PoolAllocator.
Because of this, RemoveAllTreeNodes was simply a no-op, and redundant
with the PoolAllocator deallocation procedure, and could confuse people
reading the code to think that IntermNodes should be deleted
individually, when in fact this is not the case.

BUG=angle:831

Change-Id: Ie1ccaa51986aabf267280d92a8e76ca9f97a19e5
Reviewed-on: https://chromium-review.googlesource.com/230730
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 9b273e8..ecb8c25 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -311,8 +311,8 @@
             translate(root);
     }
 
-    // Cleanup memory.
-    intermediate.remove(parseContext.treeRoot);
+    // Cleanup. The IntermNode tree doesn't need to be deleted here, since the
+    // memory will be freed in a big chunk by the PoolAllocator.
     SetGlobalParseContext(NULL);
     return success;
 }
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 068b1e7..34009ff 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -157,26 +157,6 @@
     return false;
 }
 
-void TIntermLoop::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
-{
-    if (mInit)
-    {
-        nodeQueue->push(mInit);
-    }
-    if (mCond)
-    {
-        nodeQueue->push(mCond);
-    }
-    if (mExpr)
-    {
-        nodeQueue->push(mExpr);
-    }
-    if (mBody)
-    {
-        nodeQueue->push(mBody);
-    }
-}
-
 bool TIntermBranch::replaceChildNode(
     TIntermNode *original, TIntermNode *replacement)
 {
@@ -184,14 +164,6 @@
     return false;
 }
 
-void TIntermBranch::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
-{
-    if (mExpression)
-    {
-        nodeQueue->push(mExpression);
-    }
-}
-
 bool TIntermBinary::replaceChildNode(
     TIntermNode *original, TIntermNode *replacement)
 {
@@ -200,18 +172,6 @@
     return false;
 }
 
-void TIntermBinary::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
-{
-    if (mLeft)
-    {
-        nodeQueue->push(mLeft);
-    }
-    if (mRight)
-    {
-        nodeQueue->push(mRight);
-    }
-}
-
 bool TIntermUnary::replaceChildNode(
     TIntermNode *original, TIntermNode *replacement)
 {
@@ -219,14 +179,6 @@
     return false;
 }
 
-void TIntermUnary::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
-{
-    if (mOperand)
-    {
-        nodeQueue->push(mOperand);
-    }
-}
-
 bool TIntermAggregate::replaceChildNode(
     TIntermNode *original, TIntermNode *replacement)
 {
@@ -237,14 +189,6 @@
     return false;
 }
 
-void TIntermAggregate::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
-{
-    for (size_t childIndex = 0; childIndex < mSequence.size(); childIndex++)
-    {
-        nodeQueue->push(mSequence[childIndex]);
-    }
-}
-
 void TIntermAggregate::setPrecisionFromChildren()
 {
     if (getBasicType() == EbtBool)
@@ -300,22 +244,6 @@
     return false;
 }
 
-void TIntermSelection::enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const
-{
-    if (mCondition)
-    {
-        nodeQueue->push(mCondition);
-    }
-    if (mTrueBlock)
-    {
-        nodeQueue->push(mTrueBlock);
-    }
-    if (mFalseBlock)
-    {
-        nodeQueue->push(mFalseBlock);
-    }
-}
-
 //
 // Say whether or not an operation node changes the value of a variable.
 //
diff --git a/src/compiler/translator/IntermNode.h b/src/compiler/translator/IntermNode.h
index cd3784c..9b3e489 100644
--- a/src/compiler/translator/IntermNode.h
+++ b/src/compiler/translator/IntermNode.h
@@ -238,10 +238,6 @@
     virtual bool replaceChildNode(
         TIntermNode *original, TIntermNode *replacement) = 0;
 
-    // For traversing a tree in no particular order, but using
-    // heap memory.
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const = 0;
-
   protected:
     TSourceLoc mLine;
 };
@@ -332,8 +328,6 @@
     void setUnrollFlag(bool flag) { mUnrollFlag = flag; }
     bool getUnrollFlag() const { return mUnrollFlag; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
-
   protected:
     TLoopType mType;
     TIntermNode *mInit;  // for-loop initialization
@@ -361,8 +355,6 @@
     TOperator getFlowOp() { return mFlowOp; }
     TIntermTyped* getExpression() { return mExpression; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
-
 protected:
     TOperator mFlowOp;
     TIntermTyped *mExpression;  // non-zero except for "return exp;" statements
@@ -395,8 +387,6 @@
     virtual TIntermSymbol *getAsSymbolNode() { return this; }
     virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
-
   protected:
     int mId;
     TString mSymbol;
@@ -420,7 +410,6 @@
 
     virtual TIntermRaw *getAsRawNode() { return this; }
     virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
 
   protected:
     TString mRawText;
@@ -460,8 +449,6 @@
 
     TIntermTyped *fold(TOperator, TIntermTyped *, TInfoSink &);
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
-
   protected:
     ConstantUnion *mUnionArrayPointer;
 };
@@ -520,8 +507,6 @@
     void setAddIndexClamp() { mAddIndexClamp = true; }
     bool getAddIndexClamp() { return mAddIndexClamp; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
-
   protected:
     TIntermTyped* mLeft;
     TIntermTyped* mRight;
@@ -562,8 +547,6 @@
     void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
     bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
-
   protected:
     TIntermTyped *mOperand;
 
@@ -614,8 +597,6 @@
     void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
     bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
-
     void setPrecisionFromChildren();
     void setBuiltInFunctionPrecision();
 
@@ -665,8 +646,6 @@
     TIntermNode *getFalseBlock() const { return mFalseBlock; }
     TIntermSelection *getAsSelectionNode() { return this; }
 
-    virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
-
 protected:
     TIntermTyped *mCondition;
     TIntermNode *mTrueBlock;
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index e558683..47b3b05 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -13,7 +13,6 @@
 #include <algorithm>
 
 #include "compiler/translator/Intermediate.h"
-#include "compiler/translator/RemoveTree.h"
 #include "compiler/translator/SymbolTable.h"
 
 ////////////////////////////////////////////////////////////////////////////
@@ -510,12 +509,3 @@
 
     return true;
 }
-
-//
-// This deletes the tree.
-//
-void TIntermediate::remove(TIntermNode *root)
-{
-    if (root)
-        RemoveAllTreeNodes(root);
-}
diff --git a/src/compiler/translator/Intermediate.h b/src/compiler/translator/Intermediate.h
index 8ef3d07..c7250b8 100644
--- a/src/compiler/translator/Intermediate.h
+++ b/src/compiler/translator/Intermediate.h
@@ -55,7 +55,6 @@
     TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &);
     TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &);
     bool postProcess(TIntermNode *);
-    void remove(TIntermNode *);
     void outputTree(TIntermNode *);
 
   private:
diff --git a/src/compiler/translator/RemoveTree.cpp b/src/compiler/translator/RemoveTree.cpp
deleted file mode 100644
index 0cf6910..0000000
--- a/src/compiler/translator/RemoveTree.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/IntermNode.h"
-#include "compiler/translator/RemoveTree.h"
-
-//
-// Code to delete the intermediate tree.
-//
-void RemoveAllTreeNodes(TIntermNode* root)
-{
-    std::queue<TIntermNode*> nodeQueue;
-
-    nodeQueue.push(root);
-
-    while (!nodeQueue.empty())
-    {
-        TIntermNode *node = nodeQueue.front();
-        nodeQueue.pop();
-
-        node->enqueueChildren(&nodeQueue);
-
-        delete node;
-    }
-}
-
diff --git a/src/compiler/translator/RemoveTree.h b/src/compiler/translator/RemoveTree.h
deleted file mode 100644
index 81bc900..0000000
--- a/src/compiler/translator/RemoveTree.h
+++ /dev/null
@@ -1,12 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_REMOVETREE_H_
-#define COMPILER_TRANSLATOR_REMOVETREE_H_
-
-void RemoveAllTreeNodes(TIntermNode*);
-
-#endif // COMPILER_TRANSLATOR_REMOVETREE_H_