Commit b779b12c by Jamie Madill Committed by Commit Bot

Add kEmptyImmutableString.

We can use this instead of ImmutableString(""). Bug: angleproject:2665 Change-Id: I8b3d5d3075838b9f2caa1627071202e48a5fdc83 Reviewed-on: https://chromium-review.googlesource.com/1108085 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent 0bb940a8
......@@ -81,7 +81,7 @@ ImmutableString HashName(const TSymbol *symbol, ShHashFunction64 hashFunction, N
{
if (symbol->symbolType() == SymbolType::Empty)
{
return ImmutableString("");
return kEmptyImmutableString;
}
if (symbol->symbolType() == SymbolType::AngleInternal ||
symbol->symbolType() == SymbolType::BuiltIn)
......
......@@ -138,6 +138,7 @@ class ImmutableString
size_t mLength;
};
constexpr ImmutableString kEmptyImmutableString("");
} // namespace sh
std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str);
......
......@@ -1679,7 +1679,7 @@ ImmutableString OutputHLSL::samplerNamePrefixFromStruct(TIntermTyped *node)
}
default:
UNREACHABLE();
return ImmutableString("");
return kEmptyImmutableString;
}
}
......
......@@ -2448,7 +2448,7 @@ TIntermDeclaration *TParseContext::parseSingleDeclaration(
if (type->getBasicType() == EbtStruct)
{
TVariable *emptyVariable =
new TVariable(&symbolTable, ImmutableString(""), type, SymbolType::Empty);
new TVariable(&symbolTable, kEmptyImmutableString, type, SymbolType::Empty);
symbol = new TIntermSymbol(emptyVariable);
}
else if (IsAtomicCounter(publicType.getBasicType()))
......
......@@ -184,7 +184,7 @@ void TFunction::addParameter(const TVariable *p)
mParametersVector->push_back(p);
mParameters = mParametersVector->data();
mParamCount = mParametersVector->size();
mMangledName = ImmutableString("");
mMangledName = kEmptyImmutableString;
}
void TFunction::shareParameters(const TFunction &parametersSource)
......
......@@ -162,7 +162,7 @@ class RewriteStructSamplers final : public TIntermTraverser
new TStructure(mSymbolTable, structure->name(), newFieldList, structure->symbolType());
TType *newStructType = new TType(newStruct, true);
TVariable *newStructVar =
new TVariable(mSymbolTable, ImmutableString(""), newStructType, SymbolType::Empty);
new TVariable(mSymbolTable, kEmptyImmutableString, newStructType, SymbolType::Empty);
TIntermSymbol *newStructRef = new TIntermSymbol(newStructVar);
TIntermDeclaration *structDecl = new TIntermDeclaration;
......@@ -329,13 +329,13 @@ class NameEmbeddedUniformStructsTraverser : public TIntermTraverser
const TStructure *oldStructure)
{
// struct <structName> { ... };
TStructure *structure = new TStructure(mSymbolTable, ImmutableString(""),
TStructure *structure = new TStructure(mSymbolTable, kEmptyImmutableString,
&oldStructure->fields(), SymbolType::AngleInternal);
TType *namedType = new TType(structure, true);
namedType->setQualifier(EvqGlobal);
TVariable *structVariable =
new TVariable(mSymbolTable, ImmutableString(""), namedType, SymbolType::Empty);
new TVariable(mSymbolTable, kEmptyImmutableString, namedType, SymbolType::Empty);
TIntermSymbol *structDeclarator = new TIntermSymbol(structVariable);
TIntermDeclaration *structDeclaration = new TIntermDeclaration;
structDeclaration->appendDeclarator(structDeclarator);
......
......@@ -607,7 +607,7 @@ declaration
}
| type_qualifier enter_struct struct_declaration_list RIGHT_BRACE SEMICOLON {
ES3_OR_NEWER(ImmutableString($2.string), @1, "interface blocks");
$$ = context->addInterfaceBlock(*$1, @2, ImmutableString($2.string), $3, ImmutableString(""), @$, NULL, @$);
$$ = context->addInterfaceBlock(*$1, @2, ImmutableString($2.string), $3, kEmptyImmutableString, @$, NULL, @$);
}
| type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON {
ES3_OR_NEWER(ImmutableString($2.string), @1, "interface blocks");
......@@ -740,7 +740,7 @@ init_declarator_list
single_declaration
: fully_specified_type {
$$.type = $1;
$$.intermDeclaration = context->parseSingleDeclaration($$.type, @1, ImmutableString(""));
$$.intermDeclaration = context->parseSingleDeclaration($$.type, @1, kEmptyImmutableString);
}
| fully_specified_type identifier {
$$.type = $1;
......@@ -1200,8 +1200,8 @@ struct_specifier
: STRUCT identifier LEFT_BRACE { context->enterStructDeclaration(@2, ImmutableString($2.string)); } struct_declaration_list RIGHT_BRACE {
$$ = context->addStructure(@1, @2, ImmutableString($2.string), $5);
}
| STRUCT LEFT_BRACE { context->enterStructDeclaration(@2, ImmutableString("")); } struct_declaration_list RIGHT_BRACE {
$$ = context->addStructure(@1, @$, ImmutableString(""), $4);
| STRUCT LEFT_BRACE { context->enterStructDeclaration(@2, kEmptyImmutableString); } struct_declaration_list RIGHT_BRACE {
$$ = context->addStructure(@1, @$, kEmptyImmutableString, $4);
}
;
......
......@@ -3196,7 +3196,7 @@ yyreduce:
{
ES3_OR_NEWER(ImmutableString((yyvsp[-3].lex).string), (yylsp[-4]), "interface blocks");
(yyval.interm.intermNode) = context->addInterfaceBlock(*(yyvsp[-4].interm.typeQualifierBuilder), (yylsp[-3]), ImmutableString((yyvsp[-3].lex).string), (yyvsp[-2].interm.fieldList), ImmutableString(""), (yyloc), NULL, (yyloc));
(yyval.interm.intermNode) = context->addInterfaceBlock(*(yyvsp[-4].interm.typeQualifierBuilder), (yylsp[-3]), ImmutableString((yyvsp[-3].lex).string), (yyvsp[-2].interm.fieldList), kEmptyImmutableString, (yyloc), NULL, (yyloc));
}
break;
......@@ -3414,7 +3414,7 @@ yyreduce:
{
(yyval.interm).type = (yyvsp[0].interm.type);
(yyval.interm).intermDeclaration = context->parseSingleDeclaration((yyval.interm).type, (yylsp[0]), ImmutableString(""));
(yyval.interm).intermDeclaration = context->parseSingleDeclaration((yyval.interm).type, (yylsp[0]), kEmptyImmutableString);
}
break;
......@@ -4398,14 +4398,14 @@ yyreduce:
case 229:
{ context->enterStructDeclaration((yylsp[0]), ImmutableString("")); }
{ context->enterStructDeclaration((yylsp[0]), kEmptyImmutableString); }
break;
case 230:
{
(yyval.interm.typeSpecifierNonArray) = context->addStructure((yylsp[-4]), (yyloc), ImmutableString(""), (yyvsp[-1].interm.fieldList));
(yyval.interm.typeSpecifierNonArray) = context->addStructure((yylsp[-4]), (yyloc), kEmptyImmutableString, (yyvsp[-1].interm.fieldList));
}
break;
......
......@@ -115,7 +115,7 @@ bool PruneNoOpsTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
type->setQualifier(EvqTemporary);
}
TVariable *variable =
new TVariable(mSymbolTable, ImmutableString(""), type, SymbolType::Empty);
new TVariable(mSymbolTable, kEmptyImmutableString, type, SymbolType::Empty);
queueReplacementWithParent(node, declaratorSymbol, new TIntermSymbol(variable),
OriginalNode::IS_DROPPED);
}
......
......@@ -207,7 +207,7 @@ void RemoveUnreferencedVariablesTraverser::removeVariableDeclaration(TIntermDecl
return;
}
TVariable *emptyVariable =
new TVariable(mSymbolTable, ImmutableString(""), new TType(declarator->getType()),
new TVariable(mSymbolTable, kEmptyImmutableString, new TType(declarator->getType()),
SymbolType::Empty);
queueReplacementWithParent(node, declarator, new TIntermSymbol(emptyVariable),
OriginalNode::IS_DROPPED);
......
......@@ -150,7 +150,7 @@ TVariable *CreateTempVariable(TSymbolTable *symbolTable, const TType *type)
ASSERT(symbolTable != nullptr);
// TODO(oetuaho): Might be useful to sanitize layout qualifier etc. on the type of the created
// variable. This might need to be done in other places as well.
return new TVariable(symbolTable, ImmutableString(""), type, SymbolType::AngleInternal);
return new TVariable(symbolTable, kEmptyImmutableString, type, SymbolType::AngleInternal);
}
TVariable *CreateTempVariable(TSymbolTable *symbolTable, const TType *type, TQualifier qualifier)
......
......@@ -69,8 +69,9 @@ void WrapMainAndAppend(TIntermBlock *root,
TSymbolTable *symbolTable)
{
// Replace main() with main0() with the same body.
TFunction *oldMain = new TFunction(symbolTable, ImmutableString(""), SymbolType::AngleInternal,
StaticType::GetBasic<EbtVoid>(), false);
TFunction *oldMain =
new TFunction(symbolTable, kEmptyImmutableString, SymbolType::AngleInternal,
StaticType::GetBasic<EbtVoid>(), false);
TIntermFunctionDefinition *oldMainDefinition =
CreateInternalFunctionDefinitionNode(*oldMain, main->getBody());
......
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