Start using typed parse node ids in the check stage (#3547)

Goal is to increase type safety, though more work needs to be done (see
added TODOs).

Note that, after this change, check handlers corresponding to deleted
parse node kinds will no longer compile.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
josh11b
2023-12-29 01:28:09 +00:00
committed by GitHub
co-authored by Chandler Carruth
parent a602be89e2
commit 48c986f52d
33 changed files with 368 additions and 277 deletions
+10 -7
View File
@@ -174,14 +174,15 @@ static auto BuildFunctionDecl(Context& context, Parse::NodeId parse_node,
return {function_decl.function_id, function_decl_id};
}
auto HandleFunctionDecl(Context& context, Parse::NodeId parse_node) -> bool {
auto HandleFunctionDecl(Context& context, Parse::FunctionDeclId parse_node)
-> bool {
BuildFunctionDecl(context, parse_node, /*is_definition=*/false);
context.decl_name_stack().PopScope();
return true;
}
auto HandleFunctionDefinition(Context& context, Parse::NodeId parse_node)
-> bool {
auto HandleFunctionDefinition(Context& context,
Parse::FunctionDefinitionId parse_node) -> bool {
SemIR::FunctionId function_id =
context.node_stack().Pop<Parse::NodeKind::FunctionDefinitionStart>();
@@ -205,7 +206,8 @@ auto HandleFunctionDefinition(Context& context, Parse::NodeId parse_node)
return true;
}
auto HandleFunctionDefinitionStart(Context& context, Parse::NodeId parse_node)
auto HandleFunctionDefinitionStart(Context& context,
Parse::FunctionDefinitionStartId parse_node)
-> bool {
// Process the declaration portion of the function.
auto [function_id, decl_id] =
@@ -271,8 +273,8 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::NodeId parse_node)
return true;
}
auto HandleFunctionIntroducer(Context& context, Parse::NodeId parse_node)
-> bool {
auto HandleFunctionIntroducer(Context& context,
Parse::FunctionIntroducerId parse_node) -> bool {
// Create an instruction block to hold the instructions created as part of the
// function signature, such as parameter and return types.
context.inst_block_stack().Push();
@@ -284,7 +286,8 @@ auto HandleFunctionIntroducer(Context& context, Parse::NodeId parse_node)
return true;
}
auto HandleReturnType(Context& context, Parse::NodeId parse_node) -> bool {
auto HandleReturnType(Context& context, Parse::ReturnTypeId parse_node)
-> bool {
// Propagate the type expression.
auto [type_parse_node, type_inst_id] =
context.node_stack().PopExprWithParseNode();