mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:11:27 +01:00
Ensure we evaluate instructions created in uncommon ways. (#3598)
Instructions created by splices during conversion are now evaluated, as are instructions created in cases where we first create a placeholder instruction and later replace it by a different instruction. This also removes the ability to set a parse node and instruction independently after creating an `InstId`, which could lead to them accidentally not matching.
This commit is contained in:
@@ -52,7 +52,8 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
// Add the interface declaration.
|
||||
auto interface_decl =
|
||||
SemIR::InterfaceDecl{SemIR::InterfaceId::Invalid, decl_block_id};
|
||||
auto interface_decl_id = context.AddInst({parse_node, interface_decl});
|
||||
auto interface_decl_id =
|
||||
context.AddPlaceholderInst({parse_node, interface_decl});
|
||||
|
||||
// Check whether this is a redeclaration.
|
||||
auto existing_id = context.decl_name_stack().LookupOrAddName(
|
||||
@@ -85,7 +86,8 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
}
|
||||
|
||||
// Write the interface ID into the InterfaceDecl.
|
||||
context.insts().Set(interface_decl_id, interface_decl);
|
||||
context.ReplaceInstBeforeConstantUse(interface_decl_id,
|
||||
{parse_node, interface_decl});
|
||||
|
||||
return {interface_decl.interface_id, interface_decl_id};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user