mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +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:
@@ -55,7 +55,7 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId parse_node)
|
||||
|
||||
// Add the class declaration.
|
||||
auto class_decl = SemIR::ClassDecl{SemIR::ClassId::Invalid, decl_block_id};
|
||||
auto class_decl_id = context.AddInst({parse_node, class_decl});
|
||||
auto class_decl_id = context.AddPlaceholderInst({parse_node, class_decl});
|
||||
|
||||
// Check whether this is a redeclaration.
|
||||
auto existing_id =
|
||||
@@ -110,7 +110,7 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId parse_node)
|
||||
}
|
||||
|
||||
// Write the class ID into the ClassDecl.
|
||||
context.insts().Set(class_decl_id, class_decl);
|
||||
context.ReplaceInstBeforeConstantUse(class_decl_id, {parse_node, class_decl});
|
||||
|
||||
return {class_decl.class_id, class_decl_id};
|
||||
}
|
||||
@@ -304,9 +304,9 @@ auto HandleBaseDecl(Context& context, Parse::BaseDeclId parse_node) -> bool {
|
||||
|
||||
// Add a corresponding field to the object representation of the class.
|
||||
// TODO: Consider whether we want to use `partial T` here.
|
||||
context.args_type_info_stack().AddInst(
|
||||
context.args_type_info_stack().AddInstId(context.AddInstInNoBlock(
|
||||
{parse_node,
|
||||
SemIR::StructTypeField{SemIR::NameId::Base, base_info.type_id}});
|
||||
SemIR::StructTypeField{SemIR::NameId::Base, base_info.type_id}}));
|
||||
|
||||
// Bind the name `base` in the class to the base field.
|
||||
context.decl_name_stack().AddNameToLookup(
|
||||
|
||||
Reference in New Issue
Block a user