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/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 18127bf..dc6139c 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -144,12 +144,13 @@
 
 }  // namespace anonymous
 
-TName::TName(const TString *name) : mName(name ? (*name) : ""), mIsInternal(false)
+TName::TName(const TString &name) : mName(name), mIsInternal(false)
 {
 }
 
 TName::TName(const TSymbol *symbol)
-    : mName(*symbol->name()), mIsInternal(symbol->symbolType() == SymbolType::AngleInternal)
+    : mName(symbol->symbolType() == SymbolType::Empty ? "" : symbol->name()),
+      mIsInternal(symbol->symbolType() == SymbolType::AngleInternal)
 {
 }
 
@@ -281,12 +282,8 @@
 }
 
 TIntermSymbol::TIntermSymbol(const TVariable *variable)
-    : TIntermTyped(variable->getType()), mVariable(variable), mSymbol(variable->name())
+    : TIntermTyped(variable->getType()), mVariable(variable), mSymbol(variable)
 {
-    if (variable->symbolType() == SymbolType::AngleInternal)
-    {
-        mSymbol.setInternal(true);
-    }
 }
 
 const TSymbolUniqueId &TIntermSymbol::uniqueId() const
@@ -461,7 +458,7 @@
     }
     // ESSL 3.0 spec section 8: textureSize always gets highp precision.
     // All other functions that take a sampler are assumed to be texture functions.
-    if (mFunction->name()->find("textureSize") == 0)
+    if (mFunction->name().find("textureSize") == 0)
         mType.setPrecision(EbpHigh);
     else
         mType.setPrecision(precision);
@@ -475,7 +472,7 @@
         case EOpCallInternalRawFunction:
         case EOpCallBuiltInFunction:
         case EOpCallFunctionInAST:
-            return TFunction::GetMangledNameFromCall(*mFunction->name(), mArguments);
+            return TFunction::GetMangledNameFromCall(mFunction->name(), mArguments);
         default:
             TString opString = GetOperatorString(mOp);
             return TFunction::GetMangledNameFromCall(opString, mArguments);
@@ -490,7 +487,7 @@
         case EOpCallInternalRawFunction:
         case EOpCallBuiltInFunction:
         case EOpCallFunctionInAST:
-            return mFunction->name()->c_str();
+            return mFunction->name().c_str();
         default:
             return GetOperatorString(mOp);
     }