Don't search for nonexistent brackets in InitializeVariables

Array brackets are not included in ShaderVariable::name, so they
don't need to be pruned from there either when using the name to
look up the variable.

BUG=angleproject:2267
TEST=angle_unittests --gtest_filter=*InitOutput*Array*

Change-Id: I2b80a88c1d67f7f0dde12880bcfb35fb6d861cd0
Reviewed-on: https://chromium-review.googlesource.com/909109
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/InitializeVariables.cpp b/src/compiler/translator/InitializeVariables.cpp
index a2f258e..97cf5a0 100644
--- a/src/compiler/translator/InitializeVariables.cpp
+++ b/src/compiler/translator/InitializeVariables.cpp
@@ -168,18 +168,15 @@
 {
     for (const auto &var : variables)
     {
-        TString name = TString(var.name.c_str());
-        size_t pos   = name.find_last_of('[');
-        if (pos != TString::npos)
-        {
-            name = name.substr(0, pos);
-        }
+        // Note that tempVariableName will reference a short-lived char array here - that's fine
+        // since we're only using it to find symbols.
+        ImmutableString tempVariableName(var.name.c_str(), var.name.length());
 
         TIntermTyped *initializedSymbol = nullptr;
         if (var.isBuiltIn())
         {
-            initializedSymbol = ReferenceBuiltInVariable(ImmutableString(name.c_str()),
-                                                         *symbolTable, shaderVersion);
+            initializedSymbol =
+                ReferenceBuiltInVariable(tempVariableName, *symbolTable, shaderVersion);
             if (initializedSymbol->getQualifier() == EvqFragData &&
                 !IsExtensionEnabled(extensionBehavior, TExtension::EXT_draw_buffers))
             {
@@ -195,8 +192,7 @@
         }
         else
         {
-            initializedSymbol =
-                ReferenceGlobalVariable(ImmutableString(name.c_str()), *symbolTable);
+            initializedSymbol = ReferenceGlobalVariable(tempVariableName, *symbolTable);
         }
         ASSERT(initializedSymbol != nullptr);