Don't query names of empty symbols

This makes it possible to return a reference from TSymbol::name()
instead of a pointer. This is safer since it completely avoids the
possibility of a nullptr dereference. An assert is making sure that
the function is not being called for empty symbols.

BUG=angleproject:2267
TEST=angle_unittests

Change-Id: I44279f65989dbb828322843fc0216ba84d91dedf
Reviewed-on: https://chromium-review.googlesource.com/836894
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index db5519e..bd2169d 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -585,7 +585,7 @@
                 TString fieldName = field->name();
                 if (structure->symbolType() == SymbolType::UserDefined ||
                     structure->symbolType() == SymbolType::Empty)
-                    fieldName = hashName(TName(&fieldName));
+                    fieldName = hashName(TName(fieldName));
 
                 out << fieldName;
                 visitChildren = false;
@@ -604,11 +604,11 @@
                 ASSERT(interfaceBlock->symbolType() != SymbolType::Empty);
                 if (interfaceBlock->symbolType() == SymbolType::UserDefined)
                 {
-                    fieldName = hashName(TName(&fieldName));
+                    fieldName = hashName(TName(fieldName));
                 }
                 else
                 {
-                    ASSERT(*interfaceBlock->name() == "gl_PerVertex");
+                    ASSERT(interfaceBlock->name() == "gl_PerVertex");
                 }
 
                 out << fieldName;
@@ -938,7 +938,7 @@
             {
                 if (node->getOp() == EOpCallBuiltInFunction)
                 {
-                    out << translateTextureFunction(*node->getFunction()->name());
+                    out << translateTextureFunction(node->getFunction()->name());
                 }
                 else
                 {
@@ -1147,7 +1147,7 @@
 {
     if (func->isMain())
     {
-        return *func->name();
+        return func->name();
     }
     else
     {
@@ -1170,14 +1170,20 @@
 {
     TInfoSinkBase &out = objSink();
 
-    out << "struct " << hashName(TName(structure->name())) << "{\n";
+    out << "struct ";
+
+    if (structure->symbolType() != SymbolType::Empty)
+    {
+        out << hashName(TName(structure->name())) << " ";
+    }
+    out << "{\n";
     const TFieldList &fields = structure->fields();
     for (size_t i = 0; i < fields.size(); ++i)
     {
         const TField *field = fields[i];
         if (writeVariablePrecision(field->type()->getPrecision()))
             out << " ";
-        out << getTypeName(*field->type()) << " " << hashName(TName(&field->name()));
+        out << getTypeName(*field->type()) << " " << hashName(TName(field->name()));
         if (field->type()->isArray())
             out << ArrayString(*field->type());
         out << ";\n";
@@ -1257,7 +1263,7 @@
 
         if (writeVariablePrecision(field->type()->getPrecision()))
             out << " ";
-        out << getTypeName(*field->type()) << " " << hashName(TName(&field->name()));
+        out << getTypeName(*field->type()) << " " << hashName(TName(field->name()));
         if (field->type()->isArray())
             out << ArrayString(*field->type());
         out << ";\n";