Split IdentifierId and StringLiteralId from StringId (#3352)

Following up on discussion yesterday regarding this split.

Note, I'm expecting #3341 to do IdentifierId -> NameId in SemIR. It
might be worth adding NameId creation directly to StringStore if you're
content with this setup though.
This commit is contained in:
Jon Ross-Perkins
2023-11-02 18:44:32 +00:00
committed by GitHub
parent 7edfd8e02a
commit 3401eed8d8
30 changed files with 226 additions and 125 deletions
+7 -7
View File
@@ -101,7 +101,7 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
{.name_id = name_context.state ==
DeclarationNameStack::NameContext::State::Unresolved
? name_context.unresolved_name_id
: StringId::Invalid,
: IdentifierId::Invalid,
.implicit_param_refs_id = implicit_param_refs_id,
.param_refs_id = param_refs_id,
.return_type_id = return_type_id,
@@ -174,7 +174,7 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::Node parse_node)
"Previous definition was here.");
context.emitter()
.Build(parse_node, FunctionRedefinition,
context.strings().Get(function.name_id))
context.identifiers().Get(function.name_id))
.Note(context.insts().Get(function.definition_id).parse_node(),
FunctionPreviousDefinition)
.Emit();
@@ -212,9 +212,9 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::Node parse_node)
// TODO: This will shadow a local variable named `r#self`, but should
// not. See #2984 and the corresponding code in
// HandleSelfTypeNameExpression.
context.AddNameToLookup(self_param->parse_node,
context.strings().Add(SemIR::SelfParameter::Name),
param_id);
context.AddNameToLookup(
self_param->parse_node,
context.identifiers().Add(SemIR::SelfParameter::Name), param_id);
} else {
CARBON_FATAL() << "Unexpected kind of parameter in function definition "
<< param;
@@ -244,8 +244,8 @@ auto HandleReturnType(Context& context, Parse::Node parse_node) -> bool {
auto type_id = ExpressionAsType(context, type_parse_node, type_inst_id);
// TODO: Use a dedicated instruction rather than VarStorage here.
context.AddInstAndPush(
parse_node,
SemIR::VarStorage{parse_node, type_id, context.strings().Add("return")});
parse_node, SemIR::VarStorage{parse_node, type_id,
context.identifiers().Add("return")});
return true;
}