Commit b12531c9 by Olli Etuaho

Invalidate mangled name of TType if the type is changed

Sometimes, the mangled name of a type is already generated when the type is still being changed. For example, this could happen when the type of A[i] is generated by copying the type of A (already mangled) and calling clearArrayness() on the copy. Make sure that the mangled name gets updated if the type is changed by clearing the mangled name when something affecting it is changed. BUG=angleproject:1170 BUG=538692 TEST=angle_unittests Change-Id: I9dfacea653f56536e1573a6dbf60ff21da7cc5ab Reviewed-on: https://chromium-review.googlesource.com/303846Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent f0aa8429
...@@ -275,7 +275,11 @@ class TType ...@@ -275,7 +275,11 @@ class TType
} }
void setBasicType(TBasicType t) void setBasicType(TBasicType t)
{ {
if (type != t)
{
type = t; type = t;
invalidateMangledName();
}
} }
TPrecision getPrecision() const TPrecision getPrecision() const
...@@ -330,11 +334,19 @@ class TType ...@@ -330,11 +334,19 @@ class TType
} }
void setPrimarySize(unsigned char ps) void setPrimarySize(unsigned char ps)
{ {
if (primarySize != ps)
{
primarySize = ps; primarySize = ps;
invalidateMangledName();
}
} }
void setSecondarySize(unsigned char ss) void setSecondarySize(unsigned char ss)
{ {
if (secondarySize != ss)
{
secondarySize = ss; secondarySize = ss;
invalidateMangledName();
}
} }
// Full size of single instance of type // Full size of single instance of type
...@@ -362,13 +374,21 @@ class TType ...@@ -362,13 +374,21 @@ class TType
} }
void setArraySize(int s) void setArraySize(int s)
{ {
if (!array || arraySize != s)
{
array = true; array = true;
arraySize = s; arraySize = s;
invalidateMangledName();
}
} }
void clearArrayness() void clearArrayness()
{ {
if (array)
{
array = false; array = false;
arraySize = 0; arraySize = 0;
invalidateMangledName();
}
} }
TInterfaceBlock *getInterfaceBlock() const TInterfaceBlock *getInterfaceBlock() const
...@@ -377,7 +397,11 @@ class TType ...@@ -377,7 +397,11 @@ class TType
} }
void setInterfaceBlock(TInterfaceBlock *interfaceBlockIn) void setInterfaceBlock(TInterfaceBlock *interfaceBlockIn)
{ {
if (interfaceBlock != interfaceBlockIn)
{
interfaceBlock = interfaceBlockIn; interfaceBlock = interfaceBlockIn;
invalidateMangledName();
}
} }
bool isInterfaceBlock() const bool isInterfaceBlock() const
{ {
...@@ -403,7 +427,11 @@ class TType ...@@ -403,7 +427,11 @@ class TType
} }
void setStruct(TStructure *s) void setStruct(TStructure *s)
{ {
if (structure != s)
{
structure = s; structure = s;
invalidateMangledName();
}
} }
const TString &getMangledName() const const TString &getMangledName() const
...@@ -507,7 +535,8 @@ class TType ...@@ -507,7 +535,8 @@ class TType
getMangledName(); getMangledName();
} }
protected: private:
void invalidateMangledName() { mangled = ""; }
TString buildMangledName() const; TString buildMangledName() const;
size_t getStructSize() const; size_t getStructSize() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment