Fix lots of variable shadowing in ANGLE

BUG=angle:877

Change-Id: I15168ae32605b26aee08274464ffe68adb5a7e87
Reviewed-on: https://chromium-review.googlesource.com/242351
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Austin Kinross <aukinros@microsoft.com>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index d7d98b5..5eac0c5 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -423,25 +423,25 @@
     nameMap.clear();
 }
 
-bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool limitCallStackDepth)
+bool TCompiler::detectCallDepth(TIntermNode* inputRoot, TInfoSink& inputInfoSink, bool limitCallStackDepth)
 {
-    DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth);
-    root->traverse(&detect);
+    DetectCallDepth detect(inputInfoSink, limitCallStackDepth, maxCallStackDepth);
+    inputRoot->traverse(&detect);
     switch (detect.detectCallDepth())
     {
       case DetectCallDepth::kErrorNone:
         return true;
       case DetectCallDepth::kErrorMissingMain:
-        infoSink.info.prefix(EPrefixError);
-        infoSink.info << "Missing main()";
+        inputInfoSink.info.prefix(EPrefixError);
+        inputInfoSink.info << "Missing main()";
         return false;
       case DetectCallDepth::kErrorRecursion:
-        infoSink.info.prefix(EPrefixError);
-        infoSink.info << "Function recursion detected";
+        inputInfoSink.info.prefix(EPrefixError);
+        inputInfoSink.info << "Function recursion detected";
         return false;
       case DetectCallDepth::kErrorMaxDepthExceeded:
-        infoSink.info.prefix(EPrefixError);
-        infoSink.info << "Function call stack too deep";
+        inputInfoSink.info.prefix(EPrefixError);
+        inputInfoSink.info << "Function call stack too deep";
         return false;
       default:
         UNREACHABLE();
diff --git a/src/compiler/translator/DetectCallDepth.cpp b/src/compiler/translator/DetectCallDepth.cpp
index bfc1d58..0dc5d22 100644
--- a/src/compiler/translator/DetectCallDepth.cpp
+++ b/src/compiler/translator/DetectCallDepth.cpp
@@ -33,7 +33,7 @@
     ASSERT(visit == PreVisit);
     ASSERT(detectCallDepth);
 
-    int maxDepth = depth;
+    int retMaxDepth = depth;
     visit = InVisit;
     for (size_t i = 0; i < callees.size(); ++i) {
         switch (callees[i]->visit) {
@@ -52,7 +52,7 @@
                     detectCallDepth->getInfoSink().info << "<-" << callees[i]->getName();
                     return callDepth;
                 }
-                maxDepth = std::max(callDepth, maxDepth);
+                retMaxDepth = std::max(callDepth, retMaxDepth);
                 break;
             }
             default:
@@ -61,7 +61,7 @@
         }
     }
     visit = PostVisit;
-    return maxDepth;
+    return retMaxDepth;
 }
 
 void DetectCallDepth::FunctionNode::reset()
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index b98f5d5..8d8830c 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -651,11 +651,11 @@
         for (TIntermSequence::const_iterator iter = node->getSequence()->begin();
              iter != node->getSequence()->end(); ++iter)
         {
-            TIntermNode *node = *iter;
-            ASSERT(node != NULL);
-            node->traverse(this);
+            TIntermNode *curNode = *iter;
+            ASSERT(curNode != NULL);
+            curNode->traverse(this);
 
-            if (isSingleStatement(node))
+            if (isSingleStatement(curNode))
                 out << ";\n";
         }
         decrementDepth();
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index de9295b..e2959d7 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -1077,14 +1077,14 @@
 //
 // Return the function symbol if found, otherwise 0.
 //
-const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction* call, int shaderVersion, bool *builtIn)
+const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction* call, int inputShaderVersion, bool *builtIn)
 {
     // First find by unmangled name to check whether the function name has been
     // hidden by a variable name or struct typename.
     // If a function is found, check for one with a matching argument list.
-    const TSymbol* symbol = symbolTable.find(call->getName(), shaderVersion, builtIn);
+    const TSymbol* symbol = symbolTable.find(call->getName(), inputShaderVersion, builtIn);
     if (symbol == 0 || symbol->isFunction()) {
-        symbol = symbolTable.find(call->getMangledName(), shaderVersion, builtIn);
+        symbol = symbolTable.find(call->getMangledName(), inputShaderVersion, builtIn);
     }
 
     if (symbol == 0) {
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index ed4b7b4..23be57e 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -120,7 +120,7 @@
 
     bool containsSampler(TType& type);
     bool areAllChildConst(TIntermAggregate* aggrNode);
-    const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int shaderVersion, bool *builtIn = 0);
+    const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int inputShaderVersion, bool *builtIn = 0);
     bool executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType,
                             TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
 
diff --git a/src/compiler/translator/QualifierAlive.cpp b/src/compiler/translator/QualifierAlive.cpp
index 1f6fb75..3d950aa 100644
--- a/src/compiler/translator/QualifierAlive.cpp
+++ b/src/compiler/translator/QualifierAlive.cpp
@@ -49,7 +49,7 @@
         found = true;
 }
 
-bool TAliveTraverser::visitSelection(Visit preVisit, TIntermSelection* node)
+bool TAliveTraverser::visitSelection(Visit, TIntermSelection*)
 {
     if (wasFound())
         return false;
diff --git a/src/compiler/translator/ShaderVars.cpp b/src/compiler/translator/ShaderVars.cpp
index 3098a7f..187b73e 100644
--- a/src/compiler/translator/ShaderVars.cpp
+++ b/src/compiler/translator/ShaderVars.cpp
@@ -86,7 +86,6 @@
     // 2) the top variable is an array;
     // 3) otherwise.
     size_t pos = mappedFullName.find_first_of(".[");
-    std::string topName;
 
     if (pos == std::string::npos)
     {
diff --git a/src/compiler/translator/StructureHLSL.cpp b/src/compiler/translator/StructureHLSL.cpp
index 48929af..304949b 100644
--- a/src/compiler/translator/StructureHLSL.cpp
+++ b/src/compiler/translator/StructureHLSL.cpp
@@ -274,9 +274,9 @@
 
     for (unsigned int parameter = 0; parameter < ctorParameters.size(); parameter++)
     {
-        const TType &type = ctorParameters[parameter];
+        const TType &paramType = ctorParameters[parameter];
 
-        constructor += TypeString(type) + " x" + str(parameter) + ArrayString(type);
+        constructor += TypeString(paramType) + " x" + str(parameter) + ArrayString(paramType);
 
         if (parameter < ctorParameters.size() - 1)
         {
diff --git a/src/compiler/translator/TranslatorESSL.cpp b/src/compiler/translator/TranslatorESSL.cpp
index 3b50f7d..5f064f9 100644
--- a/src/compiler/translator/TranslatorESSL.cpp
+++ b/src/compiler/translator/TranslatorESSL.cpp
@@ -46,9 +46,9 @@
 
 void TranslatorESSL::writeExtensionBehavior() {
     TInfoSinkBase& sink = getInfoSink().obj;
-    const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
-    for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
-         iter != extensionBehavior.end(); ++iter) {
+    const TExtensionBehavior& extBehavior = getExtensionBehavior();
+    for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
+         iter != extBehavior.end(); ++iter) {
         if (iter->second != EBhUndefined) {
             if (getResources().NV_shader_framebuffer_fetch && iter->first == "GL_EXT_shader_framebuffer_fetch") {
                 sink << "#extension GL_NV_shader_framebuffer_fetch : "
diff --git a/src/compiler/translator/TranslatorGLSL.cpp b/src/compiler/translator/TranslatorGLSL.cpp
index 1c243b7..83c0a69 100644
--- a/src/compiler/translator/TranslatorGLSL.cpp
+++ b/src/compiler/translator/TranslatorGLSL.cpp
@@ -64,9 +64,9 @@
 
 void TranslatorGLSL::writeExtensionBehavior() {
     TInfoSinkBase& sink = getInfoSink().obj;
-    const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
-    for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
-         iter != extensionBehavior.end(); ++iter) {
+    const TExtensionBehavior& extBehavior = getExtensionBehavior();
+    for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
+         iter != extBehavior.end(); ++iter) {
         if (iter->second == EBhUndefined)
             continue;
 
diff --git a/src/compiler/translator/Types.cpp b/src/compiler/translator/Types.cpp
index d36936f..0fe6acc 100644
--- a/src/compiler/translator/Types.cpp
+++ b/src/compiler/translator/Types.cpp
@@ -178,11 +178,12 @@
 
     if (isArray())
     {
-        size_t arraySize = getArraySize();
-        if (arraySize > INT_MAX / totalSize)
+        // TODO: getArraySize() returns an int, not a size_t
+        size_t currentArraySize = getArraySize();
+        if (currentArraySize > INT_MAX / totalSize)
             totalSize = INT_MAX;
         else
-            totalSize *= arraySize;
+            totalSize *= currentArraySize;
     }
 
     return totalSize;