Commit bed35d76 by Olli Etuaho Committed by Commit Bot

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/836894Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 49ac74bd
...@@ -129,7 +129,7 @@ class PullGradient : public TIntermTraverser ...@@ -129,7 +129,7 @@ class PullGradient : public TIntermTraverser
} }
else if (node->getOp() == EOpCallBuiltInFunction) else if (node->getOp() == EOpCallBuiltInFunction)
{ {
if (mGradientBuiltinFunctions.find(*node->getFunction()->name()) != if (mGradientBuiltinFunctions.find(node->getFunction()->name()) !=
mGradientBuiltinFunctions.end()) mGradientBuiltinFunctions.end())
{ {
onGradient(); onGradient();
......
...@@ -128,7 +128,7 @@ bool ArrayReturnValueToOutParameterTraverser::visitFunctionPrototype(Visit visit ...@@ -128,7 +128,7 @@ bool ArrayReturnValueToOutParameterTraverser::visitFunctionPrototype(Visit visit
changedFunction.returnValueVariable = changedFunction.returnValueVariable =
new TVariable(mSymbolTable, mReturnValueVariableName, returnValueVariableType, new TVariable(mSymbolTable, mReturnValueVariableName, returnValueVariableType,
SymbolType::AngleInternal); SymbolType::AngleInternal);
changedFunction.func = new TFunction(mSymbolTable, node->getFunction()->name(), changedFunction.func = new TFunction(mSymbolTable, &node->getFunction()->name(),
StaticType::GetBasic<EbtVoid>(), StaticType::GetBasic<EbtVoid>(),
node->getFunction()->symbolType(), false); node->getFunction()->symbolType(), false);
mChangedFunctions[functionId.get()] = changedFunction; mChangedFunctions[functionId.get()] = changedFunction;
......
...@@ -108,12 +108,12 @@ class CallDAG::CallDAGCreator : public TIntermTraverser ...@@ -108,12 +108,12 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
if (it == mFunctions.end()) if (it == mFunctions.end())
{ {
mCurrentFunction = &mFunctions[node->getFunction()->uniqueId().get()]; mCurrentFunction = &mFunctions[node->getFunction()->uniqueId().get()];
mCurrentFunction->name = *node->getFunction()->name(); mCurrentFunction->name = node->getFunction()->name();
} }
else else
{ {
mCurrentFunction = &it->second; mCurrentFunction = &it->second;
ASSERT(mCurrentFunction->name == *node->getFunction()->name()); ASSERT(mCurrentFunction->name == node->getFunction()->name());
} }
mCurrentFunction->node = node; mCurrentFunction->node = node;
...@@ -135,7 +135,7 @@ class CallDAG::CallDAGCreator : public TIntermTraverser ...@@ -135,7 +135,7 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
// Function declaration, create an empty record. // Function declaration, create an empty record.
auto &record = mFunctions[node->getFunction()->uniqueId().get()]; auto &record = mFunctions[node->getFunction()->uniqueId().get()];
record.name = *node->getFunction()->name(); record.name = node->getFunction()->name();
// No need to traverse the parameters. // No need to traverse the parameters.
return false; return false;
......
...@@ -91,8 +91,7 @@ ShaderVariable *FindVariableInInterfaceBlock(const TString &name, ...@@ -91,8 +91,7 @@ ShaderVariable *FindVariableInInterfaceBlock(const TString &name,
std::vector<InterfaceBlock> *infoList) std::vector<InterfaceBlock> *infoList)
{ {
ASSERT(interfaceBlock); ASSERT(interfaceBlock);
ASSERT(interfaceBlock->name()); InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), infoList);
InterfaceBlock *namedBlock = FindVariable(*interfaceBlock->name(), infoList);
ASSERT(namedBlock); ASSERT(namedBlock);
// Set static use on the parent interface block here // Set static use on the parent interface block here
...@@ -576,7 +575,7 @@ void CollectVariablesTraverser::setCommonVariableProperties(const TType &type, ...@@ -576,7 +575,7 @@ void CollectVariablesTraverser::setCommonVariableProperties(const TType &type,
variableOut->type = GL_NONE; variableOut->type = GL_NONE;
if (structure->symbolType() != SymbolType::Empty) if (structure->symbolType() != SymbolType::Empty)
{ {
variableOut->structName = structure->name()->c_str(); variableOut->structName = structure->name().c_str();
} }
const TFieldList &fields = structure->fields(); const TFieldList &fields = structure->fields();
...@@ -586,7 +585,7 @@ void CollectVariablesTraverser::setCommonVariableProperties(const TType &type, ...@@ -586,7 +585,7 @@ void CollectVariablesTraverser::setCommonVariableProperties(const TType &type,
// Regardless of the variable type (uniform, in/out etc.) its fields are always plain // Regardless of the variable type (uniform, in/out etc.) its fields are always plain
// ShaderVariable objects. // ShaderVariable objects.
ShaderVariable fieldVariable; ShaderVariable fieldVariable;
setCommonVariableProperties(*field->type(), TName(&field->name()), &fieldVariable); setCommonVariableProperties(*field->type(), TName(field->name()), &fieldVariable);
variableOut->fields.push_back(fieldVariable); variableOut->fields.push_back(fieldVariable);
} }
} }
...@@ -665,7 +664,7 @@ void CollectVariablesTraverser::recordInterfaceBlock(const TString &instanceName ...@@ -665,7 +664,7 @@ void CollectVariablesTraverser::recordInterfaceBlock(const TString &instanceName
const TInterfaceBlock *blockType = interfaceBlockType.getInterfaceBlock(); const TInterfaceBlock *blockType = interfaceBlockType.getInterfaceBlock();
ASSERT(blockType); ASSERT(blockType);
interfaceBlock->name = blockType->name()->c_str(); interfaceBlock->name = blockType->name().c_str();
interfaceBlock->mappedName = getMappedName(TName(blockType->name())); interfaceBlock->mappedName = getMappedName(TName(blockType->name()));
interfaceBlock->instanceName = instanceName.c_str(); interfaceBlock->instanceName = instanceName.c_str();
ASSERT(!interfaceBlockType.isArrayOfArrays()); // Disallowed by GLSL ES 3.10 section 4.3.9 ASSERT(!interfaceBlockType.isArrayOfArrays()); // Disallowed by GLSL ES 3.10 section 4.3.9
...@@ -687,7 +686,7 @@ void CollectVariablesTraverser::recordInterfaceBlock(const TString &instanceName ...@@ -687,7 +686,7 @@ void CollectVariablesTraverser::recordInterfaceBlock(const TString &instanceName
const TType &fieldType = *field->type(); const TType &fieldType = *field->type();
InterfaceBlockField fieldVariable; InterfaceBlockField fieldVariable;
setCommonVariableProperties(fieldType, TName(&field->name()), &fieldVariable); setCommonVariableProperties(fieldType, TName(field->name()), &fieldVariable);
fieldVariable.isRowMajorLayout = fieldVariable.isRowMajorLayout =
(fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor); (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
interfaceBlock->fields.push_back(fieldVariable); interfaceBlock->fields.push_back(fieldVariable);
...@@ -835,7 +834,7 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode) ...@@ -835,7 +834,7 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode)
const TInterfaceBlock *interfaceBlock = blockNode->getType().getInterfaceBlock(); const TInterfaceBlock *interfaceBlock = blockNode->getType().getInterfaceBlock();
if (!namedBlock) if (!namedBlock)
{ {
namedBlock = findNamedInterfaceBlock(*interfaceBlock->name()); namedBlock = findNamedInterfaceBlock(interfaceBlock->name());
} }
ASSERT(namedBlock); ASSERT(namedBlock);
namedBlock->staticUse = true; namedBlock->staticUse = true;
......
...@@ -144,12 +144,13 @@ void SetUnionArrayFromMatrix(const angle::Matrix<float> &m, TConstantUnion *resu ...@@ -144,12 +144,13 @@ void SetUnionArrayFromMatrix(const angle::Matrix<float> &m, TConstantUnion *resu
} // namespace anonymous } // 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) 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 @@ bool TIntermAggregateBase::insertChildNodes(TIntermSequence::size_type position, ...@@ -281,12 +282,8 @@ bool TIntermAggregateBase::insertChildNodes(TIntermSequence::size_type position,
} }
TIntermSymbol::TIntermSymbol(const TVariable *variable) 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 const TSymbolUniqueId &TIntermSymbol::uniqueId() const
...@@ -461,7 +458,7 @@ void TIntermAggregate::setBuiltInFunctionPrecision() ...@@ -461,7 +458,7 @@ void TIntermAggregate::setBuiltInFunctionPrecision()
} }
// ESSL 3.0 spec section 8: textureSize always gets highp precision. // ESSL 3.0 spec section 8: textureSize always gets highp precision.
// All other functions that take a sampler are assumed to be texture functions. // 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); mType.setPrecision(EbpHigh);
else else
mType.setPrecision(precision); mType.setPrecision(precision);
...@@ -475,7 +472,7 @@ TString TIntermAggregate::getSymbolTableMangledName() const ...@@ -475,7 +472,7 @@ TString TIntermAggregate::getSymbolTableMangledName() const
case EOpCallInternalRawFunction: case EOpCallInternalRawFunction:
case EOpCallBuiltInFunction: case EOpCallBuiltInFunction:
case EOpCallFunctionInAST: case EOpCallFunctionInAST:
return TFunction::GetMangledNameFromCall(*mFunction->name(), mArguments); return TFunction::GetMangledNameFromCall(mFunction->name(), mArguments);
default: default:
TString opString = GetOperatorString(mOp); TString opString = GetOperatorString(mOp);
return TFunction::GetMangledNameFromCall(opString, mArguments); return TFunction::GetMangledNameFromCall(opString, mArguments);
...@@ -490,7 +487,7 @@ const char *TIntermAggregate::functionName() const ...@@ -490,7 +487,7 @@ const char *TIntermAggregate::functionName() const
case EOpCallInternalRawFunction: case EOpCallInternalRawFunction:
case EOpCallBuiltInFunction: case EOpCallBuiltInFunction:
case EOpCallFunctionInAST: case EOpCallFunctionInAST:
return mFunction->name()->c_str(); return mFunction->name().c_str();
default: default:
return GetOperatorString(mOp); return GetOperatorString(mOp);
} }
......
...@@ -66,7 +66,7 @@ class TName ...@@ -66,7 +66,7 @@ class TName
{ {
public: public:
POOL_ALLOCATOR_NEW_DELETE(); POOL_ALLOCATOR_NEW_DELETE();
explicit TName(const TString *name); explicit TName(const TString &name);
explicit TName(const TSymbol *symbol); explicit TName(const TSymbol *symbol);
TName() : mName(), mIsInternal(false) {} TName() : mName(), mIsInternal(false) {}
TName(const TName &) = default; TName(const TName &) = default;
......
...@@ -585,7 +585,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node) ...@@ -585,7 +585,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node)
TString fieldName = field->name(); TString fieldName = field->name();
if (structure->symbolType() == SymbolType::UserDefined || if (structure->symbolType() == SymbolType::UserDefined ||
structure->symbolType() == SymbolType::Empty) structure->symbolType() == SymbolType::Empty)
fieldName = hashName(TName(&fieldName)); fieldName = hashName(TName(fieldName));
out << fieldName; out << fieldName;
visitChildren = false; visitChildren = false;
...@@ -604,11 +604,11 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node) ...@@ -604,11 +604,11 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node)
ASSERT(interfaceBlock->symbolType() != SymbolType::Empty); ASSERT(interfaceBlock->symbolType() != SymbolType::Empty);
if (interfaceBlock->symbolType() == SymbolType::UserDefined) if (interfaceBlock->symbolType() == SymbolType::UserDefined)
{ {
fieldName = hashName(TName(&fieldName)); fieldName = hashName(TName(fieldName));
} }
else else
{ {
ASSERT(*interfaceBlock->name() == "gl_PerVertex"); ASSERT(interfaceBlock->name() == "gl_PerVertex");
} }
out << fieldName; out << fieldName;
...@@ -938,7 +938,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -938,7 +938,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
if (node->getOp() == EOpCallBuiltInFunction) if (node->getOp() == EOpCallBuiltInFunction)
{ {
out << translateTextureFunction(*node->getFunction()->name()); out << translateTextureFunction(node->getFunction()->name());
} }
else else
{ {
...@@ -1147,7 +1147,7 @@ TString TOutputGLSLBase::hashFunctionNameIfNeeded(const TFunction *func) ...@@ -1147,7 +1147,7 @@ TString TOutputGLSLBase::hashFunctionNameIfNeeded(const TFunction *func)
{ {
if (func->isMain()) if (func->isMain())
{ {
return *func->name(); return func->name();
} }
else else
{ {
...@@ -1170,14 +1170,20 @@ void TOutputGLSLBase::declareStruct(const TStructure *structure) ...@@ -1170,14 +1170,20 @@ void TOutputGLSLBase::declareStruct(const TStructure *structure)
{ {
TInfoSinkBase &out = objSink(); TInfoSinkBase &out = objSink();
out << "struct " << hashName(TName(structure->name())) << "{\n"; out << "struct ";
if (structure->symbolType() != SymbolType::Empty)
{
out << hashName(TName(structure->name())) << " ";
}
out << "{\n";
const TFieldList &fields = structure->fields(); const TFieldList &fields = structure->fields();
for (size_t i = 0; i < fields.size(); ++i) for (size_t i = 0; i < fields.size(); ++i)
{ {
const TField *field = fields[i]; const TField *field = fields[i];
if (writeVariablePrecision(field->type()->getPrecision())) if (writeVariablePrecision(field->type()->getPrecision()))
out << " "; out << " ";
out << getTypeName(*field->type()) << " " << hashName(TName(&field->name())); out << getTypeName(*field->type()) << " " << hashName(TName(field->name()));
if (field->type()->isArray()) if (field->type()->isArray())
out << ArrayString(*field->type()); out << ArrayString(*field->type());
out << ";\n"; out << ";\n";
...@@ -1257,7 +1263,7 @@ void TOutputGLSLBase::declareInterfaceBlock(const TInterfaceBlock *interfaceBloc ...@@ -1257,7 +1263,7 @@ void TOutputGLSLBase::declareInterfaceBlock(const TInterfaceBlock *interfaceBloc
if (writeVariablePrecision(field->type()->getPrecision())) if (writeVariablePrecision(field->type()->getPrecision()))
out << " "; out << " ";
out << getTypeName(*field->type()) << " " << hashName(TName(&field->name())); out << getTypeName(*field->type()) << " " << hashName(TName(field->name()));
if (field->type()->isArray()) if (field->type()->isArray())
out << ArrayString(*field->type()); out << ArrayString(*field->type());
out << ";\n"; out << ";\n";
......
...@@ -341,9 +341,8 @@ TString OutputHLSL::generateStructMapping(const std::vector<MappedStruct> &std14 ...@@ -341,9 +341,8 @@ TString OutputHLSL::generateStructMapping(const std::vector<MappedStruct> &std14
{ {
TInterfaceBlock *interfaceBlock = TInterfaceBlock *interfaceBlock =
mappedStruct.blockDeclarator->getType().getInterfaceBlock(); mappedStruct.blockDeclarator->getType().getInterfaceBlock();
const TString &interfaceBlockName = *interfaceBlock->name();
const TName &instanceName = mappedStruct.blockDeclarator->getName(); const TName &instanceName = mappedStruct.blockDeclarator->getName();
if (mReferencedUniformBlocks.count(interfaceBlockName) == 0) if (mReferencedUniformBlocks.count(interfaceBlock->name()) == 0)
{ {
continue; continue;
} }
...@@ -380,7 +379,7 @@ TString OutputHLSL::generateStructMapping(const std::vector<MappedStruct> &std14 ...@@ -380,7 +379,7 @@ TString OutputHLSL::generateStructMapping(const std::vector<MappedStruct> &std14
TType *structType = mappedStruct.field->type(); TType *structType = mappedStruct.field->type();
mappedStructs += mappedStructs +=
"static " + Decorate(*structType->getStruct()->name()) + " " + mappedName; "static " + Decorate(structType->getStruct()->name()) + " " + mappedName;
if (structType->isArray()) if (structType->isArray())
{ {
...@@ -889,7 +888,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node) ...@@ -889,7 +888,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
if (interfaceBlock) if (interfaceBlock)
{ {
mReferencedUniformBlocks[*interfaceBlock->name()] = node; mReferencedUniformBlocks[interfaceBlock->name()] = node;
} }
else else
{ {
...@@ -1237,7 +1236,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) ...@@ -1237,7 +1236,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
{ {
TInterfaceBlock *interfaceBlock = leftType.getInterfaceBlock(); TInterfaceBlock *interfaceBlock = leftType.getInterfaceBlock();
TIntermSymbol *instanceArraySymbol = node->getLeft()->getAsSymbolNode(); TIntermSymbol *instanceArraySymbol = node->getLeft()->getAsSymbolNode();
mReferencedUniformBlocks[*interfaceBlock->name()] = instanceArraySymbol; mReferencedUniformBlocks[interfaceBlock->name()] = instanceArraySymbol;
const int arrayIndex = node->getRight()->getAsConstantUnion()->getIConst(0); const int arrayIndex = node->getRight()->getAsConstantUnion()->getIConst(0);
out << mUniformHLSL->UniformBlockInstanceString( out << mUniformHLSL->UniformBlockInstanceString(
instanceArraySymbol->getSymbol(), arrayIndex); instanceArraySymbol->getSymbol(), arrayIndex);
...@@ -1925,16 +1924,16 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1925,16 +1924,16 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
} }
else if (node->getFunction()->isImageFunction()) else if (node->getFunction()->isImageFunction())
{ {
const TString *name = node->getFunction()->name(); const TString &name = node->getFunction()->name();
TType type = (*arguments)[0]->getAsTyped()->getType(); TType type = (*arguments)[0]->getAsTyped()->getType();
TString imageFunctionName = mImageFunctionHLSL->useImageFunction( TString imageFunctionName = mImageFunctionHLSL->useImageFunction(
*name, type.getBasicType(), type.getLayoutQualifier().imageInternalFormat, name, type.getBasicType(), type.getLayoutQualifier().imageInternalFormat,
type.getMemoryQualifier().readonly); type.getMemoryQualifier().readonly);
out << imageFunctionName << "("; out << imageFunctionName << "(";
} }
else else
{ {
const TString *name = node->getFunction()->name(); const TString &name = node->getFunction()->name();
TBasicType samplerType = (*arguments)[0]->getAsTyped()->getType().getBasicType(); TBasicType samplerType = (*arguments)[0]->getAsTyped()->getType().getBasicType();
int coords = 0; // textureSize(gsampler2DMS) doesn't have a second argument. int coords = 0; // textureSize(gsampler2DMS) doesn't have a second argument.
if (arguments->size() > 1) if (arguments->size() > 1)
...@@ -1942,7 +1941,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1942,7 +1941,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
coords = (*arguments)[1]->getAsTyped()->getNominalSize(); coords = (*arguments)[1]->getAsTyped()->getNominalSize();
} }
TString textureFunctionName = mTextureFunctionHLSL->useTextureFunction( TString textureFunctionName = mTextureFunctionHLSL->useTextureFunction(
*name, samplerType, coords, arguments->size(), lod0, mShaderType); name, samplerType, coords, arguments->size(), lod0, mShaderType);
out << textureFunctionName << "("; out << textureFunctionName << "(";
} }
......
...@@ -17,7 +17,7 @@ void OutputFunction(TInfoSinkBase &out, const char *str, const TFunction *func) ...@@ -17,7 +17,7 @@ void OutputFunction(TInfoSinkBase &out, const char *str, const TFunction *func)
{ {
const char *internal = const char *internal =
(func->symbolType() == SymbolType::AngleInternal) ? " (internal function)" : ""; (func->symbolType() == SymbolType::AngleInternal) ? " (internal function)" : "";
out << str << internal << ": " << *func->name() << " (symbol id " << func->uniqueId().get() out << str << internal << ": " << func->name() << " (symbol id " << func->uniqueId().get()
<< ")"; << ")";
} }
......
...@@ -3150,8 +3150,7 @@ TIntermFunctionPrototype *TParseContext::createPrototypeNodeFromFunction( ...@@ -3150,8 +3150,7 @@ TIntermFunctionPrototype *TParseContext::createPrototypeNodeFromFunction(
const TSourceLoc &location, const TSourceLoc &location,
bool insertParametersToSymbolTable) bool insertParametersToSymbolTable)
{ {
ASSERT(function.name()); checkIsNotReserved(location, function.name());
checkIsNotReserved(location, *function.name());
TIntermFunctionPrototype *prototype = new TIntermFunctionPrototype(&function); TIntermFunctionPrototype *prototype = new TIntermFunctionPrototype(&function);
prototype->setLine(location); prototype->setLine(location);
...@@ -3243,7 +3242,7 @@ TIntermFunctionDefinition *TParseContext::addFunctionDefinition( ...@@ -3243,7 +3242,7 @@ TIntermFunctionDefinition *TParseContext::addFunctionDefinition(
if (mCurrentFunctionType->getBasicType() != EbtVoid && !mFunctionReturnsValue) if (mCurrentFunctionType->getBasicType() != EbtVoid && !mFunctionReturnsValue)
{ {
error(location, "function does not return a value:", error(location, "function does not return a value:",
functionPrototype->getFunction()->name()->c_str()); functionPrototype->getFunction()->name().c_str());
} }
if (functionBody == nullptr) if (functionBody == nullptr)
...@@ -3265,13 +3264,12 @@ void TParseContext::parseFunctionDefinitionHeader(const TSourceLoc &location, ...@@ -3265,13 +3264,12 @@ void TParseContext::parseFunctionDefinitionHeader(const TSourceLoc &location,
{ {
ASSERT(function); ASSERT(function);
ASSERT(*function); ASSERT(*function);
ASSERT((*function)->name());
const TSymbol *builtIn = const TSymbol *builtIn =
symbolTable.findBuiltIn((*function)->getMangledName(), getShaderVersion()); symbolTable.findBuiltIn((*function)->getMangledName(), getShaderVersion());
if (builtIn) if (builtIn)
{ {
error(location, "built-in functions cannot be redefined", (*function)->name()->c_str()); error(location, "built-in functions cannot be redefined", (*function)->name().c_str());
} }
else else
{ {
...@@ -3293,7 +3291,7 @@ void TParseContext::parseFunctionDefinitionHeader(const TSourceLoc &location, ...@@ -3293,7 +3291,7 @@ void TParseContext::parseFunctionDefinitionHeader(const TSourceLoc &location,
if ((*function)->isDefined()) if ((*function)->isDefined())
{ {
error(location, "function already has a body", (*function)->name()->c_str()); error(location, "function already has a body", (*function)->name().c_str());
} }
(*function)->setDefined(); (*function)->setDefined();
...@@ -3320,8 +3318,6 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF ...@@ -3320,8 +3318,6 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF
TFunction *prevDec = TFunction *prevDec =
static_cast<TFunction *>(symbolTable.find(function->getMangledName(), getShaderVersion())); static_cast<TFunction *>(symbolTable.find(function->getMangledName(), getShaderVersion()));
ASSERT(function->name() != nullptr);
for (size_t i = 0u; i < function->getParamCount(); ++i) for (size_t i = 0u; i < function->getParamCount(); ++i)
{ {
auto &param = function->getParam(i); auto &param = function->getParam(i);
...@@ -3329,17 +3325,17 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF ...@@ -3329,17 +3325,17 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF
{ {
// ESSL 3.00.6 section 12.10. // ESSL 3.00.6 section 12.10.
error(location, "Function parameter type cannot be a structure definition", error(location, "Function parameter type cannot be a structure definition",
function->name()->c_str()); function->name().c_str());
} }
} }
if (getShaderVersion() >= 300 && symbolTable.hasUnmangledBuiltInForShaderVersion( if (getShaderVersion() >= 300 && symbolTable.hasUnmangledBuiltInForShaderVersion(
function->name()->c_str(), getShaderVersion())) function->name().c_str(), getShaderVersion()))
{ {
// With ESSL 3.00 and above, names of built-in functions cannot be redeclared as functions. // With ESSL 3.00 and above, names of built-in functions cannot be redeclared as functions.
// Therefore overloading or redefining builtin functions is an error. // Therefore overloading or redefining builtin functions is an error.
error(location, "Name of a built-in function cannot be redeclared as function", error(location, "Name of a built-in function cannot be redeclared as function",
function->name()->c_str()); function->name().c_str());
} }
else if (prevDec) else if (prevDec)
{ {
...@@ -3363,12 +3359,12 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF ...@@ -3363,12 +3359,12 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF
// //
// Check for previously declared variables using the same name. // Check for previously declared variables using the same name.
// //
TSymbol *prevSym = symbolTable.find(*function->name(), getShaderVersion()); TSymbol *prevSym = symbolTable.find(function->name(), getShaderVersion());
if (prevSym) if (prevSym)
{ {
if (!prevSym->isFunction()) if (!prevSym->isFunction())
{ {
error(location, "redefinition of a function", function->name()->c_str()); error(location, "redefinition of a function", function->name().c_str());
} }
} }
else else
...@@ -3382,7 +3378,7 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF ...@@ -3382,7 +3378,7 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF
symbolTable.getOuterLevel()->insert(function); symbolTable.getOuterLevel()->insert(function);
// Raise error message if main function takes any parameters or return anything other than void // Raise error message if main function takes any parameters or return anything other than void
if (*function->name() == "main") if (function->name() == "main")
{ {
if (function->getParamCount() > 0) if (function->getParamCount() > 0)
{ {
...@@ -3906,7 +3902,7 @@ void TParseContext::checkIsBelowStructNestingLimit(const TSourceLoc &line, const ...@@ -3906,7 +3902,7 @@ void TParseContext::checkIsBelowStructNestingLimit(const TSourceLoc &line, const
else else
{ {
reasonStream << "Reference of struct type " reasonStream << "Reference of struct type "
<< field.type()->getStruct()->name()->c_str(); << field.type()->getStruct()->name().c_str();
} }
reasonStream << " exceeds maximum allowed nesting level of " << kWebGLMaxStructNesting; reasonStream << " exceeds maximum allowed nesting level of " << kWebGLMaxStructNesting;
std::string reason = reasonStream.str(); std::string reason = reasonStream.str();
...@@ -5485,7 +5481,7 @@ TIntermBranch *TParseContext::addBranch(TOperator op, ...@@ -5485,7 +5481,7 @@ TIntermBranch *TParseContext::addBranch(TOperator op,
void TParseContext::checkTextureGather(TIntermAggregate *functionCall) void TParseContext::checkTextureGather(TIntermAggregate *functionCall)
{ {
ASSERT(functionCall->getOp() == EOpCallBuiltInFunction); ASSERT(functionCall->getOp() == EOpCallBuiltInFunction);
const TString &name = *functionCall->getFunction()->name(); const TString &name = functionCall->getFunction()->name();
bool isTextureGather = (name == "textureGather"); bool isTextureGather = (name == "textureGather");
bool isTextureGatherOffset = (name == "textureGatherOffset"); bool isTextureGatherOffset = (name == "textureGatherOffset");
if (isTextureGather || isTextureGatherOffset) if (isTextureGather || isTextureGatherOffset)
...@@ -5551,7 +5547,7 @@ void TParseContext::checkTextureGather(TIntermAggregate *functionCall) ...@@ -5551,7 +5547,7 @@ void TParseContext::checkTextureGather(TIntermAggregate *functionCall)
void TParseContext::checkTextureOffsetConst(TIntermAggregate *functionCall) void TParseContext::checkTextureOffsetConst(TIntermAggregate *functionCall)
{ {
ASSERT(functionCall->getOp() == EOpCallBuiltInFunction); ASSERT(functionCall->getOp() == EOpCallBuiltInFunction);
const TString &name = *functionCall->getFunction()->name(); const TString &name = functionCall->getFunction()->name();
TIntermNode *offset = nullptr; TIntermNode *offset = nullptr;
TIntermSequence *arguments = functionCall->getSequence(); TIntermSequence *arguments = functionCall->getSequence();
bool useTextureGatherOffsetConstraints = false; bool useTextureGatherOffsetConstraints = false;
...@@ -5628,8 +5624,8 @@ void TParseContext::checkTextureOffsetConst(TIntermAggregate *functionCall) ...@@ -5628,8 +5624,8 @@ void TParseContext::checkTextureOffsetConst(TIntermAggregate *functionCall)
void TParseContext::checkAtomicMemoryBuiltinFunctions(TIntermAggregate *functionCall) void TParseContext::checkAtomicMemoryBuiltinFunctions(TIntermAggregate *functionCall)
{ {
ASSERT(functionCall->getOp() == EOpCallBuiltInFunction); ASSERT(functionCall->getOp() == EOpCallBuiltInFunction);
const TString &name = *functionCall->getFunction()->name(); const TString &functionName = functionCall->getFunction()->name();
if (IsAtomicBuiltin(name)) if (IsAtomicBuiltin(functionName))
{ {
TIntermSequence *arguments = functionCall->getSequence(); TIntermSequence *arguments = functionCall->getSequence();
TIntermTyped *memNode = (*arguments)[0]->getAsTyped(); TIntermTyped *memNode = (*arguments)[0]->getAsTyped();
...@@ -5651,7 +5647,7 @@ void TParseContext::checkAtomicMemoryBuiltinFunctions(TIntermAggregate *function ...@@ -5651,7 +5647,7 @@ void TParseContext::checkAtomicMemoryBuiltinFunctions(TIntermAggregate *function
error(memNode->getLine(), error(memNode->getLine(),
"The value passed to the mem argument of an atomic memory function does not " "The value passed to the mem argument of an atomic memory function does not "
"correspond to a buffer or shared variable.", "correspond to a buffer or shared variable.",
functionCall->getFunction()->name()->c_str()); functionName.c_str());
} }
} }
...@@ -5659,7 +5655,7 @@ void TParseContext::checkAtomicMemoryBuiltinFunctions(TIntermAggregate *function ...@@ -5659,7 +5655,7 @@ void TParseContext::checkAtomicMemoryBuiltinFunctions(TIntermAggregate *function
void TParseContext::checkImageMemoryAccessForBuiltinFunctions(TIntermAggregate *functionCall) void TParseContext::checkImageMemoryAccessForBuiltinFunctions(TIntermAggregate *functionCall)
{ {
ASSERT(functionCall->getOp() == EOpCallBuiltInFunction); ASSERT(functionCall->getOp() == EOpCallBuiltInFunction);
const TString &name = *functionCall->getFunction()->name(); const TString &name = functionCall->getFunction()->name();
if (name.compare(0, 5, "image") == 0) if (name.compare(0, 5, "image") == 0)
{ {
...@@ -5775,7 +5771,7 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, ...@@ -5775,7 +5771,7 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall,
} }
} }
TIntermTyped *TParseContext::addMethod(const TString *name, TIntermTyped *TParseContext::addMethod(const TString &name,
TIntermSequence *arguments, TIntermSequence *arguments,
TIntermNode *thisNode, TIntermNode *thisNode,
const TSourceLoc &loc) const TSourceLoc &loc)
...@@ -5785,9 +5781,9 @@ TIntermTyped *TParseContext::addMethod(const TString *name, ...@@ -5785,9 +5781,9 @@ TIntermTyped *TParseContext::addMethod(const TString *name,
// a constructor. But such a TFunction can't reach here, since the lexer goes into FIELDS // a constructor. But such a TFunction can't reach here, since the lexer goes into FIELDS
// mode after a dot, which makes type identifiers to be parsed as FIELD_SELECTION instead. // mode after a dot, which makes type identifiers to be parsed as FIELD_SELECTION instead.
// So accessing fnCall->name() below is safe. // So accessing fnCall->name() below is safe.
if (*name != "length") if (name != "length")
{ {
error(loc, "invalid method", name->c_str()); error(loc, "invalid method", name.c_str());
} }
else if (!arguments->empty()) else if (!arguments->empty())
{ {
...@@ -5812,27 +5808,26 @@ TIntermTyped *TParseContext::addMethod(const TString *name, ...@@ -5812,27 +5808,26 @@ TIntermTyped *TParseContext::addMethod(const TString *name,
return CreateZeroNode(TType(EbtInt, EbpUndefined, EvqConst)); return CreateZeroNode(TType(EbtInt, EbpUndefined, EvqConst));
} }
TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString *name, TIntermTyped *TParseContext::addNonConstructorFunctionCall(const TString &name,
TIntermSequence *arguments, TIntermSequence *arguments,
const TSourceLoc &loc) const TSourceLoc &loc)
{ {
ASSERT(name);
// First find by unmangled name to check whether the function name has been // First find by unmangled name to check whether the function name has been
// hidden by a variable name or struct typename. // hidden by a variable name or struct typename.
// If a function is found, check for one with a matching argument list. // If a function is found, check for one with a matching argument list.
bool builtIn; bool builtIn;
const TSymbol *symbol = symbolTable.find(*name, mShaderVersion, &builtIn); const TSymbol *symbol = symbolTable.find(name, mShaderVersion, &builtIn);
if (symbol != nullptr && !symbol->isFunction()) if (symbol != nullptr && !symbol->isFunction())
{ {
error(loc, "function name expected", name->c_str()); error(loc, "function name expected", name.c_str());
} }
else else
{ {
symbol = symbolTable.find(TFunction::GetMangledNameFromCall(*name, *arguments), symbol = symbolTable.find(TFunction::GetMangledNameFromCall(name, *arguments),
mShaderVersion, &builtIn); mShaderVersion, &builtIn);
if (symbol == nullptr) if (symbol == nullptr)
{ {
error(loc, "no matching overloaded function found", name->c_str()); error(loc, "no matching overloaded function found", name.c_str());
} }
else else
{ {
......
...@@ -549,14 +549,14 @@ class TParseContext : angle::NonCopyable ...@@ -549,14 +549,14 @@ class TParseContext : angle::NonCopyable
const TSourceLoc &loc); const TSourceLoc &loc);
TIntermTyped *createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc); TIntermTyped *createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc);
TIntermTyped *addMethod(const TString *name, TIntermTyped *addMethod(const TString &name,
TIntermSequence *arguments, TIntermSequence *arguments,
TIntermNode *thisNode, TIntermNode *thisNode,
const TSourceLoc &loc); const TSourceLoc &loc);
TIntermTyped *addConstructor(TIntermSequence *arguments, TIntermTyped *addConstructor(TIntermSequence *arguments,
TType type, TType type,
const TSourceLoc &line); const TSourceLoc &line);
TIntermTyped *addNonConstructorFunctionCall(const TString *name, TIntermTyped *addNonConstructorFunctionCall(const TString &name,
TIntermSequence *arguments, TIntermSequence *arguments,
const TSourceLoc &loc); const TSourceLoc &loc);
......
...@@ -26,8 +26,6 @@ void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol) ...@@ -26,8 +26,6 @@ void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
return; return;
} }
ASSERT(userType->name() != nullptr);
int uniqueId = userType->uniqueId().get(); int uniqueId = userType->uniqueId().get();
ASSERT(mScopeDepth > 0); ASSERT(mScopeDepth > 0);
...@@ -53,14 +51,14 @@ void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol) ...@@ -53,14 +51,14 @@ void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
return; return;
// Map {name} to _webgl_struct_{uniqueId}_{name}. // Map {name} to _webgl_struct_{uniqueId}_{name}.
const char kPrefix[] = "_webgl_struct_"; const char kPrefix[] = "_webgl_struct_";
if (userType->name()->find(kPrefix) == 0) if (userType->name().find(kPrefix) == 0)
{ {
// The name has already been regenerated. // The name has already been regenerated.
return; return;
} }
std::string id = Str(uniqueId); std::string id = Str(uniqueId);
TString tmp = kPrefix + TString(id.c_str()); TString tmp = kPrefix + TString(id.c_str());
tmp += "_" + *userType->name(); tmp += "_" + userType->name();
userType->setName(tmp); userType->setName(tmp);
} }
......
...@@ -72,7 +72,8 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -72,7 +72,8 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
return true; return true;
} }
if (*node->getFunction()->name() != "texelFetchOffset") ASSERT(node->getFunction()->symbolType() == SymbolType::BuiltIn);
if (node->getFunction()->name() != "texelFetchOffset")
{ {
return true; return true;
} }
......
...@@ -38,22 +38,22 @@ TSymbol::TSymbol(TSymbolTable *symbolTable, ...@@ -38,22 +38,22 @@ TSymbol::TSymbol(TSymbolTable *symbolTable,
mSymbolType == SymbolType::NotResolved || mSymbolType == SymbolType::Empty); mSymbolType == SymbolType::NotResolved || mSymbolType == SymbolType::Empty);
} }
const TString *TSymbol::name() const const TString &TSymbol::name() const
{ {
if (mName != nullptr || mSymbolType == SymbolType::Empty) if (mName != nullptr)
{ {
return mName; return *mName;
} }
ASSERT(mSymbolType == SymbolType::AngleInternal); ASSERT(mSymbolType == SymbolType::AngleInternal);
TInfoSinkBase symbolNameOut; TInfoSinkBase symbolNameOut;
symbolNameOut << "s" << mUniqueId.get(); symbolNameOut << "s" << mUniqueId.get();
return NewPoolTString(symbolNameOut.c_str()); return *NewPoolTString(symbolNameOut.c_str());
} }
const TString &TSymbol::getMangledName() const const TString &TSymbol::getMangledName() const
{ {
ASSERT(mSymbolType != SymbolType::Empty); ASSERT(mSymbolType != SymbolType::Empty);
return *name(); return name();
} }
TVariable::TVariable(TSymbolTable *symbolTable, TVariable::TVariable(TSymbolTable *symbolTable,
...@@ -160,7 +160,7 @@ void TFunction::swapParameters(const TFunction &parametersSource) ...@@ -160,7 +160,7 @@ void TFunction::swapParameters(const TFunction &parametersSource)
const TString *TFunction::buildMangledName() const const TString *TFunction::buildMangledName() const
{ {
std::string newName = name()->c_str(); std::string newName = name().c_str();
newName += kFunctionMangledNameSeparator; newName += kFunctionMangledNameSeparator;
for (const auto &p : parameters) for (const auto &p : parameters)
...@@ -185,13 +185,13 @@ const TString &TFunction::GetMangledNameFromCall(const TString &functionName, ...@@ -185,13 +185,13 @@ const TString &TFunction::GetMangledNameFromCall(const TString &functionName,
bool TFunction::isMain() const bool TFunction::isMain() const
{ {
return symbolType() == SymbolType::UserDefined && *name() == "main"; return symbolType() == SymbolType::UserDefined && name() == "main";
} }
bool TFunction::isImageFunction() const bool TFunction::isImageFunction() const
{ {
return symbolType() == SymbolType::BuiltIn && return symbolType() == SymbolType::BuiltIn &&
(*name() == "imageSize" || *name() == "imageLoad" || *name() == "imageStore"); (name() == "imageSize" || name() == "imageLoad" || name() == "imageStore");
} }
} // namespace sh } // namespace sh
...@@ -43,11 +43,14 @@ class TSymbol : angle::NonCopyable ...@@ -43,11 +43,14 @@ class TSymbol : angle::NonCopyable
// don't delete name, it's from the pool // don't delete name, it's from the pool
} }
const TString *name() const; // Don't call name() or getMangledName() for empty symbols (symbolType == SymbolType::Empty).
const TString &name() const;
virtual const TString &getMangledName() const; virtual const TString &getMangledName() const;
virtual bool isFunction() const { return false; } virtual bool isFunction() const { return false; }
virtual bool isVariable() const { return false; } virtual bool isVariable() const { return false; }
virtual bool isStruct() const { return false; } virtual bool isStruct() const { return false; }
const TSymbolUniqueId &uniqueId() const { return mUniqueId; } const TSymbolUniqueId &uniqueId() const { return mUniqueId; }
SymbolType symbolType() const { return mSymbolType; } SymbolType symbolType() const { return mSymbolType; }
TExtension extension() const { return mExtension; } TExtension extension() const { return mExtension; }
......
...@@ -42,8 +42,7 @@ bool TSymbolTableLevel::insert(TSymbol *symbol) ...@@ -42,8 +42,7 @@ bool TSymbolTableLevel::insert(TSymbol *symbol)
bool TSymbolTableLevel::insertUnmangled(TFunction *function) bool TSymbolTableLevel::insertUnmangled(TFunction *function)
{ {
// returning true means symbol was added to the table // returning true means symbol was added to the table
ASSERT(function->name() != nullptr); tInsertResult result = level.insert(tLevelPair(function->name(), function));
tInsertResult result = level.insert(tLevelPair(*function->name(), function));
return result.second; return result.second;
} }
......
...@@ -475,16 +475,15 @@ const char *TType::buildMangledName() const ...@@ -475,16 +475,15 @@ const char *TType::buildMangledName() const
{ {
case EbtStruct: case EbtStruct:
mangledName += "struct-"; mangledName += "struct-";
if (mStructure->name() != nullptr) if (mStructure->symbolType() != SymbolType::Empty)
{ {
mangledName += *mStructure->name(); mangledName += mStructure->name();
} }
mangledName += mStructure->mangledFieldList(); mangledName += mStructure->mangledFieldList();
break; break;
case EbtInterfaceBlock: case EbtInterfaceBlock:
mangledName += "iblock-"; mangledName += "iblock-";
ASSERT(mInterfaceBlock->name() != nullptr); mangledName += mInterfaceBlock->name();
mangledName += *mInterfaceBlock->name();
mangledName += mInterfaceBlock->mangledFieldList(); mangledName += mInterfaceBlock->mangledFieldList();
break; break;
default: default:
......
...@@ -61,8 +61,7 @@ static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockSt ...@@ -61,8 +61,7 @@ static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockSt
static TString InterfaceBlockStructName(const TInterfaceBlock &interfaceBlock) static TString InterfaceBlockStructName(const TInterfaceBlock &interfaceBlock)
{ {
ASSERT(interfaceBlock.name() != nullptr); return DecoratePrivate(interfaceBlock.name()) + "_type";
return DecoratePrivate(*interfaceBlock.name()) + "_type";
} }
void OutputSamplerIndexArrayInitializer(TInfoSinkBase &out, void OutputSamplerIndexArrayInitializer(TInfoSinkBase &out,
...@@ -480,8 +479,7 @@ TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInte ...@@ -480,8 +479,7 @@ TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInte
} }
unsigned int activeRegister = mUniformBlockRegister; unsigned int activeRegister = mUniformBlockRegister;
ASSERT(interfaceBlock.name() != nullptr); mUniformBlockRegisterMap[interfaceBlock.name().c_str()] = activeRegister;
mUniformBlockRegisterMap[interfaceBlock.name()->c_str()] = activeRegister;
if (instanceName != "" && nodeType.isArray()) if (instanceName != "" && nodeType.isArray())
{ {
...@@ -512,8 +510,7 @@ TString UniformHLSL::uniformBlockString(const TInterfaceBlock &interfaceBlock, ...@@ -512,8 +510,7 @@ TString UniformHLSL::uniformBlockString(const TInterfaceBlock &interfaceBlock,
{ {
const TString &arrayIndexString = const TString &arrayIndexString =
(arrayIndex != GL_INVALID_INDEX ? Decorate(str(arrayIndex)) : ""); (arrayIndex != GL_INVALID_INDEX ? Decorate(str(arrayIndex)) : "");
ASSERT(interfaceBlock.name() != nullptr); const TString &blockName = interfaceBlock.name() + arrayIndexString;
const TString &blockName = *interfaceBlock.name() + arrayIndexString;
TString hlsl; TString hlsl;
hlsl += "cbuffer " + blockName + " : register(b" + str(registerIndex) + hlsl += "cbuffer " + blockName + " : register(b" + str(registerIndex) +
......
...@@ -735,15 +735,15 @@ TString DecorateFunctionIfNeeded(const TFunction *func) ...@@ -735,15 +735,15 @@ TString DecorateFunctionIfNeeded(const TFunction *func)
if (func->symbolType() == SymbolType::AngleInternal) if (func->symbolType() == SymbolType::AngleInternal)
{ {
// The name should not have a prefix reserved for user-defined variables or functions. // The name should not have a prefix reserved for user-defined variables or functions.
ASSERT(func->name()->compare(0, 2, "f_") != 0); ASSERT(func->name().compare(0, 2, "f_") != 0);
ASSERT(func->name()->compare(0, 1, "_") != 0); ASSERT(func->name().compare(0, 1, "_") != 0);
return *func->name(); return func->name();
} }
ASSERT(func->name()->compare(0, 3, "gl_") != 0); ASSERT(func->name().compare(0, 3, "gl_") != 0);
// Add an additional f prefix to functions so that they're always disambiguated from variables. // Add an additional f prefix to functions so that they're always disambiguated from variables.
// This is necessary in the corner case where a variable declaration hides a function that it // This is necessary in the corner case where a variable declaration hides a function that it
// uses in its initializer. // uses in its initializer.
return "f_" + (*func->name()); return "f_" + func->name();
} }
TString TypeString(const TType &type) TString TypeString(const TType &type)
...@@ -855,10 +855,10 @@ TString StructNameString(const TStructure &structure) ...@@ -855,10 +855,10 @@ TString StructNameString(const TStructure &structure)
// translation so that we can link between shader stages. // translation so that we can link between shader stages.
if (structure.atGlobalScope()) if (structure.atGlobalScope())
{ {
return Decorate(*structure.name()); return Decorate(structure.name());
} }
return "ss" + str(structure.uniqueId().get()) + "_" + *structure.name(); return "ss" + str(structure.uniqueId().get()) + "_" + structure.name();
} }
TString QualifiedStructNameString(const TStructure &structure, TString QualifiedStructNameString(const TStructure &structure,
......
...@@ -167,8 +167,8 @@ class FindStructByName final : public TIntermTraverser ...@@ -167,8 +167,8 @@ class FindStructByName final : public TIntermTraverser
TStructure *structure = symbol->getTypePointer()->getStruct(); TStructure *structure = symbol->getTypePointer()->getStruct();
if (structure != nullptr && structure->name() != nullptr && if (structure != nullptr && structure->symbolType() != SymbolType::Empty &&
*structure->name() == mStructName) structure->name() == mStructName)
{ {
mStructure = structure; mStructure = structure;
} }
......
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