mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:31:15 +01:00
Rename parse_node -> node_id (#3760)
This was previously discussed at https://discord.com/channels/655572317891461132/655578254970716160/1209975051588210729. I'm initiating this mainly because we typically use "id" suffixes to indicate an `IdBase` being passed around and the non-id suffix of `parse_node` suggests at it carrying more data than it actually does. There used to be more reason for avoiding `node_id` because `SemIR::InstId` used to be named `NodeId`, but that's no longer necessary. As a consequence, I'd like to rename `parse_node` to more precisely reflect its type. In full, this is doing: ``` parse_node_kind -> node_kind parse_node -> node_id ParseNodeCategory -> NodeCategory ParseNodeKind -> NodeKind ParseNode -> NodeId ``` This is primarily in check and sem_ir, but with some `parse_node_kind` references in parse too. Pluralization is consistent with name forms on both sides, so that wasn't part of my replacements.
This commit is contained in:
+13
-14
@@ -100,22 +100,22 @@ auto RegisterReturnedVar(Context& context, SemIR::InstId bind_id) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto BuildReturnWithNoExpr(Context& context,
|
||||
Parse::ReturnStatementId parse_node) -> void {
|
||||
auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id)
|
||||
-> void {
|
||||
const auto& function = GetCurrentFunction(context);
|
||||
|
||||
if (function.return_type_id.is_valid()) {
|
||||
CARBON_DIAGNOSTIC(ReturnStatementMissingExpr, Error,
|
||||
"Missing return value.");
|
||||
auto diag = context.emitter().Build(parse_node, ReturnStatementMissingExpr);
|
||||
auto diag = context.emitter().Build(node_id, ReturnStatementMissingExpr);
|
||||
NoteReturnType(diag, function);
|
||||
diag.Emit();
|
||||
}
|
||||
|
||||
context.AddInst({parse_node, SemIR::Return{}});
|
||||
context.AddInst({node_id, SemIR::Return{}});
|
||||
}
|
||||
|
||||
auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId parse_node,
|
||||
auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id,
|
||||
SemIR::InstId expr_id) -> void {
|
||||
const auto& function = GetCurrentFunction(context);
|
||||
auto returned_var_id = GetCurrentReturnedVar(context);
|
||||
@@ -124,8 +124,7 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId parse_node,
|
||||
CARBON_DIAGNOSTIC(
|
||||
ReturnStatementDisallowExpr, Error,
|
||||
"No return expression should be provided in this context.");
|
||||
auto diag =
|
||||
context.emitter().Build(parse_node, ReturnStatementDisallowExpr);
|
||||
auto diag = context.emitter().Build(node_id, ReturnStatementDisallowExpr);
|
||||
NoteNoReturnTypeProvided(diag, function);
|
||||
diag.Emit();
|
||||
expr_id = SemIR::InstId::BuiltinError;
|
||||
@@ -133,21 +132,21 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId parse_node,
|
||||
CARBON_DIAGNOSTIC(
|
||||
ReturnExprWithReturnedVar, Error,
|
||||
"Can only `return var;` in the scope of a `returned var`.");
|
||||
auto diag = context.emitter().Build(parse_node, ReturnExprWithReturnedVar);
|
||||
auto diag = context.emitter().Build(node_id, ReturnExprWithReturnedVar);
|
||||
NoteReturnedVar(diag, returned_var_id);
|
||||
diag.Emit();
|
||||
expr_id = SemIR::InstId::BuiltinError;
|
||||
} else if (function.return_slot_id.is_valid()) {
|
||||
expr_id = Initialize(context, parse_node, function.return_slot_id, expr_id);
|
||||
expr_id = Initialize(context, node_id, function.return_slot_id, expr_id);
|
||||
} else {
|
||||
expr_id = ConvertToValueOfType(context, parse_node, expr_id,
|
||||
expr_id = ConvertToValueOfType(context, node_id, expr_id,
|
||||
function.return_type_id);
|
||||
}
|
||||
|
||||
context.AddInst({parse_node, SemIR::ReturnExpr{expr_id}});
|
||||
context.AddInst({node_id, SemIR::ReturnExpr{expr_id}});
|
||||
}
|
||||
|
||||
auto BuildReturnVar(Context& context, Parse::ReturnStatementId parse_node)
|
||||
auto BuildReturnVar(Context& context, Parse::ReturnStatementId node_id)
|
||||
-> void {
|
||||
const auto& function = GetCurrentFunction(context);
|
||||
auto returned_var_id = GetCurrentReturnedVar(context);
|
||||
@@ -155,7 +154,7 @@ auto BuildReturnVar(Context& context, Parse::ReturnStatementId parse_node)
|
||||
if (!returned_var_id.is_valid()) {
|
||||
CARBON_DIAGNOSTIC(ReturnVarWithNoReturnedVar, Error,
|
||||
"`return var;` with no `returned var` in scope.");
|
||||
context.emitter().Emit(parse_node, ReturnVarWithNoReturnedVar);
|
||||
context.emitter().Emit(node_id, ReturnVarWithNoReturnedVar);
|
||||
returned_var_id = SemIR::InstId::BuiltinError;
|
||||
}
|
||||
|
||||
@@ -165,7 +164,7 @@ auto BuildReturnVar(Context& context, Parse::ReturnStatementId parse_node)
|
||||
returned_var_id = ConvertToValueExpr(context, returned_var_id);
|
||||
}
|
||||
|
||||
context.AddInst({parse_node, SemIR::ReturnExpr{returned_var_id}});
|
||||
context.AddInst({node_id, SemIR::ReturnExpr{returned_var_id}});
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
Reference in New Issue
Block a user