Fix asserts related to writing nameless parameters in HLSL

We rely on TSymbol::name() to generate names also for nameless
parameters. Fix asserts to reflect this.

BUG=chromium:823041
TEST=angle_unittests

Change-Id: Ie9b8253a150e79965bf85d8a7f36643ada6c54cc
Reviewed-on: https://chromium-review.googlesource.com/968242
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/Symbol.cpp b/src/compiler/translator/Symbol.cpp
index 5f1bcd8..cb3331c 100644
--- a/src/compiler/translator/Symbol.cpp
+++ b/src/compiler/translator/Symbol.cpp
@@ -46,11 +46,13 @@
 
 ImmutableString TSymbol::name() const
 {
-    if (mName != "")
+    if (!mName.empty())
     {
         return mName;
     }
-    ASSERT(mSymbolType == SymbolType::AngleInternal);
+    // This can be called for nameless function parameters in HLSL.
+    ASSERT(mSymbolType == SymbolType::AngleInternal ||
+           (mSymbolType == SymbolType::Empty && isVariable()));
     int uniqueId = mUniqueId.get();
     ImmutableStringBuilder symbolNameOut(sizeof(uniqueId) * 2u + 1u);
     symbolNameOut << 's';
diff --git a/src/compiler/translator/Symbol.h b/src/compiler/translator/Symbol.h
index 2824ed0..a13d300 100644
--- a/src/compiler/translator/Symbol.h
+++ b/src/compiler/translator/Symbol.h
@@ -42,8 +42,10 @@
     // either statically allocated or pool allocated.
     ~TSymbol() = default;
 
-    // Don't call name() or getMangledName() for empty symbols (symbolType == SymbolType::Empty).
+    // Calling name() for empty symbols (symbolType == SymbolType::Empty) generates a similar name
+    // as for internal variables.
     ImmutableString name() const;
+    // Don't call getMangledName() for empty symbols (symbolType == SymbolType::Empty).
     virtual ImmutableString getMangledName() const;
 
     virtual bool isFunction() const { return false; }
diff --git a/src/compiler/translator/UtilsHLSL.cpp b/src/compiler/translator/UtilsHLSL.cpp
index f7c5509..573dc6c 100644
--- a/src/compiler/translator/UtilsHLSL.cpp
+++ b/src/compiler/translator/UtilsHLSL.cpp
@@ -829,8 +829,10 @@
 
 TString DecorateVariableIfNeeded(const TVariable &variable)
 {
-    if (variable.symbolType() == SymbolType::AngleInternal)
+    if (variable.symbolType() == SymbolType::AngleInternal ||
+        variable.symbolType() == SymbolType::Empty)
     {
+        // Besides handling internal variables, we generate names for nameless parameters here.
         const ImmutableString &name = variable.name();
         // The name should not have a prefix reserved for user-defined variables or functions.
         ASSERT(!name.beginsWith("f_"));