mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +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:
@@ -138,7 +138,8 @@ static auto BuildFunctionDecl(Context& context,
|
||||
auto function_decl = SemIR::FunctionDecl{
|
||||
context.GetBuiltinType(SemIR::BuiltinKind::FunctionType),
|
||||
SemIR::FunctionId::Invalid};
|
||||
auto function_decl_id = context.AddInst({parse_node, function_decl});
|
||||
auto function_decl_id =
|
||||
context.AddPlaceholderInst({parse_node, function_decl});
|
||||
|
||||
// Check whether this is a redeclaration.
|
||||
auto existing_id =
|
||||
@@ -180,7 +181,8 @@ static auto BuildFunctionDecl(Context& context,
|
||||
}
|
||||
|
||||
// Write the function ID into the FunctionDecl.
|
||||
context.insts().Set(function_decl_id, function_decl);
|
||||
context.ReplaceInstBeforeConstantUse(function_decl_id,
|
||||
{parse_node, function_decl});
|
||||
|
||||
if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) {
|
||||
// TODO: Update this once valid signatures for the entry point are decided.
|
||||
|
||||
Reference in New Issue
Block a user