compiler: Work around a HLSL compiler aliasing opt bug.

BUG=angleproject:1448

Change-Id: I7d5bcbd100069152cea0cb03bc4fa6af1044460b
Reviewed-on: https://chromium-review.googlesource.com/376020
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/translator/util.cpp b/src/compiler/translator/util.cpp
index 9b59ccc..d6339a8 100644
--- a/src/compiler/translator/util.cpp
+++ b/src/compiler/translator/util.cpp
@@ -278,9 +278,9 @@
     }
 }
 
-TType ConvertShaderVariableTypeToTType(sh::GLenum type)
+TType GetShaderVariableBasicType(const sh::ShaderVariable &var)
 {
-    switch (type)
+    switch (var.type)
     {
         case GL_FLOAT:
             return TType(EbtFloat);
@@ -330,6 +330,35 @@
     }
 }
 
+TType GetShaderVariableType(const sh::ShaderVariable &var)
+{
+    TType type;
+    if (var.isStruct())
+    {
+        TFieldList *fields = new TFieldList;
+        TSourceLoc loc;
+        for (const auto &field : var.fields)
+        {
+            TType *fieldType = new TType(GetShaderVariableType(field));
+            fields->push_back(new TField(fieldType, new TString(field.name.c_str()), loc));
+        }
+        TStructure *structure = new TStructure(new TString(var.structName.c_str()), fields);
+
+        type.setBasicType(EbtStruct);
+        type.setStruct(structure);
+    }
+    else
+    {
+        type = GetShaderVariableBasicType(var);
+    }
+
+    if (var.isArray())
+    {
+        type.setArraySize(var.elementCount());
+    }
+    return type;
+}
+
 TOperator TypeToConstructorOperator(const TType &type)
 {
     switch (type.getBasicType())