mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:11:05 +01:00
Reduce explicit SemIR::LocIdAndInst construction (#5153)
Building on #5151 reducing `UncheckedLoc` use, further remove uses of the `SemIR::LocIdAndInst` constructor where we typically have overloads that don't need it. Add parallel convenience wrappers for placeholder insts. Also refactors `MergeReplacing`. I don't think it makes sense to add an overload for `ReplaceLocIdAndInstBeforeConstantUse`, but we can still reduce the `LocIdAndInst` construction there.
This commit is contained in:
@@ -63,18 +63,16 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
|
||||
is_template);
|
||||
if (is_generic) {
|
||||
bind_id = AddInstInNoBlock(
|
||||
context, SemIR::LocIdAndInst(name_node,
|
||||
SemIR::BindSymbolicName{
|
||||
.type_id = cast_type_id,
|
||||
.entity_name_id = entity_name_id,
|
||||
.value_id = SemIR::InstId::None}));
|
||||
context, name_node,
|
||||
SemIR::BindSymbolicName{.type_id = cast_type_id,
|
||||
.entity_name_id = entity_name_id,
|
||||
.value_id = SemIR::InstId::None});
|
||||
} else {
|
||||
bind_id = AddInstInNoBlock(
|
||||
context,
|
||||
SemIR::LocIdAndInst(
|
||||
name_node, SemIR::BindName{.type_id = cast_type_id,
|
||||
.entity_name_id = entity_name_id,
|
||||
.value_id = SemIR::InstId::None}));
|
||||
bind_id =
|
||||
AddInstInNoBlock(context, name_node,
|
||||
SemIR::BindName{.type_id = cast_type_id,
|
||||
.entity_name_id = entity_name_id,
|
||||
.value_id = SemIR::InstId::None});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,10 +193,8 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
|
||||
.decl_block_id = SemIR::InstBlockId::None};
|
||||
auto decl_id = AddPlaceholderInstInNoBlock(
|
||||
context,
|
||||
SemIR::LocIdAndInst(
|
||||
context.parse_tree().As<Parse::CompileTimeBindingPatternId>(
|
||||
node_id),
|
||||
assoc_const_decl));
|
||||
context.parse_tree().As<Parse::CompileTimeBindingPatternId>(node_id),
|
||||
assoc_const_decl);
|
||||
assoc_const_decl.assoc_const_id = context.associated_constants().Add(
|
||||
{.name_id = name_id,
|
||||
.parent_scope_id = context.scope_stack().PeekNameScopeId(),
|
||||
|
||||
Reference in New Issue
Block a user