Revert "Make TType store a const char * for mangled name."

This reverts commit dc7bffd06b526bbffd3d1c1ddbd6c763a2cc7287.

Reason for revert: Causes a memory leak, detected by ASAN bot:

https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/494713

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x847aa2 in operator new(unsigned long) /b/build/slave/linux_upload_clang/build/src/third_party/llvm/compiler-rt/lib/asan/asan_new_delete.cc:92:3
    #1 0x193a833 in sh::TType::buildMangledName() const third_party/angle/src/compiler/translator/Types.cpp:545:21
    #2 0x193d2e8 in getMangledName third_party/angle/src/compiler/translator/Types.cpp:751:24
    #3 0x193d2e8 in sh::TType::realize() third_party/angle/src/compiler/translator/Types.cpp:759
    #4 0x1834474 in sh::TCache::getType(sh::TBasicType, sh::TPrecision, sh::TQualifier, unsigned char, unsigned char) third_party/angle/src/compiler/translator/Cache.cpp:89:11
    #5 0x1859ac7 in getType third_party/angle/src/compiler/translator/Cache.h:36:16
    #6 0x1859ac7 in sh::InsertBuiltInFunctions(unsigned int, ShShaderSpec, ShBuiltInResources const&, sh::TSymbolTable&) third_party/angle/src/compiler/translator/Initialize.cpp:28

Bug: angleproject:1432

Original change's description:
> Make TType store a const char * for mangled name.
> 
> We would only ever use the c_str value from the mangled name. This
> makes it easier to make constexpr TTypes.
> 
> Bug: angleproject:1432
> Change-Id: I147b3a85f9b8b2453e2d7f4a713d767b22036cc9
> Reviewed-on: https://chromium-review.googlesource.com/776277
> Commit-Queue: Jamie Madill <jmadill@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

TBR=jmadill@chromium.org,kainino@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: angleproject:1432
Change-Id: Ib112a2ce9871a4f4afc53101ac1a3ddd166008cf
Reviewed-on: https://chromium-review.googlesource.com/780420
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index 6c38461..b26acc8 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -66,7 +66,7 @@
 
     for (const auto &p : parameters)
     {
-        newName += p.type->getMangledName();
+        newName += p.type->getMangledName().c_str();
     }
     return NewPoolTString(newName.c_str());
 }
@@ -79,7 +79,7 @@
 
     for (TIntermNode *argument : arguments)
     {
-        newName += argument->getAsTyped()->getType().getMangledName();
+        newName += argument->getAsTyped()->getType().getMangledName().c_str();
     }
     return *NewPoolTString(newName.c_str());
 }
diff --git a/src/compiler/translator/Types.cpp b/src/compiler/translator/Types.cpp
index be585b2..a5b7978 100644
--- a/src/compiler/translator/Types.cpp
+++ b/src/compiler/translator/Types.cpp
@@ -125,8 +125,7 @@
       secondarySize(0),
       mInterfaceBlock(nullptr),
       mStructure(nullptr),
-      mIsStructSpecifier(false),
-      mMangledName(nullptr)
+      mIsStructSpecifier(false)
 {
 }
 
@@ -141,8 +140,7 @@
       secondarySize(ss),
       mInterfaceBlock(0),
       mStructure(0),
-      mIsStructSpecifier(false),
-      mMangledName(nullptr)
+      mIsStructSpecifier(false)
 {
 }
 
@@ -157,8 +155,7 @@
       secondarySize(ss),
       mInterfaceBlock(0),
       mStructure(0),
-      mIsStructSpecifier(false),
-      mMangledName(nullptr)
+      mIsStructSpecifier(false)
 {
 }
 
@@ -173,8 +170,7 @@
       secondarySize(p.getSecondarySize()),
       mInterfaceBlock(nullptr),
       mStructure(nullptr),
-      mIsStructSpecifier(false),
-      mMangledName(nullptr)
+      mIsStructSpecifier(false)
 {
     ASSERT(primarySize <= 4);
     ASSERT(secondarySize <= 4);
@@ -200,8 +196,7 @@
       secondarySize(1),
       mInterfaceBlock(nullptr),
       mStructure(userDef),
-      mIsStructSpecifier(false),
-      mMangledName(nullptr)
+      mIsStructSpecifier(false)
 {
 }
 
@@ -218,8 +213,7 @@
       secondarySize(1),
       mInterfaceBlock(interfaceBlockIn),
       mStructure(0),
-      mIsStructSpecifier(false),
-      mMangledName(nullptr)
+      mIsStructSpecifier(false)
 {
 }
 
@@ -381,7 +375,7 @@
 //
 // Recursively generate mangled names.
 //
-const char *TType::buildMangledName() const
+TString TType::buildMangledName() const
 {
     TString mangledName;
     if (isMatrix())
@@ -538,12 +532,7 @@
         mangledName += buf;
         mangledName += ']';
     }
-
-    mangledName += ';';
-
-    // We allocate with the pool allocator, so it's fine that the TString goes out of scope.
-    TString *temp = new TString(mangledName);
-    return temp->c_str();
+    return mangledName;
 }
 
 size_t TType::getObjectSize() const
@@ -744,11 +733,12 @@
     }
 }
 
-const char *TType::getMangledName() const
+const TString &TType::getMangledName() const
 {
-    if (mMangledName == nullptr)
+    if (mMangledName.empty())
     {
         mMangledName = buildMangledName();
+        mMangledName += ';';
     }
 
     return mMangledName;
@@ -761,7 +751,7 @@
 
 void TType::invalidateMangledName()
 {
-    mMangledName = nullptr;
+    mMangledName = "";
 }
 
 // TStructure implementation.
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index fe9f25c..266b39a 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -279,7 +279,7 @@
     const TStructure *getStruct() const { return mStructure; }
     void setStruct(TStructure *s);
 
-    const char *getMangledName() const;
+    const TString &getMangledName() const;
 
     bool sameNonArrayType(const TType &right) const;
 
@@ -368,7 +368,7 @@
 
   private:
     void invalidateMangledName();
-    const char *buildMangledName() const;
+    TString buildMangledName() const;
 
     TBasicType type;
     TPrecision precision;
@@ -393,7 +393,7 @@
     TStructure *mStructure;
     bool mIsStructSpecifier;
 
-    mutable const char *mMangledName;
+    mutable TString mMangledName;
 };
 
 // TTypeSpecifierNonArray stores all of the necessary fields for type_specifier_nonarray from the