Switch CalleeFunction to a variant (#6104)

Trying to make it easier to see what's intended to be present/correct on
`CalleeFunction` in its various modes.
This commit is contained in:
Jon Ross-Perkins
2025-09-22 22:56:38 +00:00
committed by GitHub
parent a73e259620
commit 0f7df4ed7e
11 changed files with 210 additions and 127 deletions
+8 -8
View File
@@ -570,25 +570,25 @@ class Stringifier {
auto StringifyInst(InstId /*inst_id*/, SpecificFunction inst) -> void {
auto callee = GetCalleeFunction(*sem_ir_, inst.callee_id);
if (callee.function_id.has_value()) {
step_stack_->PushEntityName(sem_ir_->functions().Get(callee.function_id),
if (auto* fn = std::get_if<CalleeFunction::Function>(&callee.info)) {
step_stack_->PushEntityName(sem_ir_->functions().Get(fn->function_id),
inst.specific_id);
} else {
step_stack_->PushString("<invalid specific function>");
return;
}
step_stack_->PushString("<invalid specific function>");
}
auto StringifyInst(InstId /*inst_id*/, SpecificImplFunction inst) -> void {
auto callee = GetCalleeFunction(*sem_ir_, inst.callee_id);
if (callee.function_id.has_value()) {
if (auto* fn = std::get_if<CalleeFunction::Function>(&callee.info)) {
// TODO: The specific_id here is for the interface member, but the
// entity we're passing is the impl member. This might result in
// strange output once we render specific arguments properly.
step_stack_->PushEntityName(sem_ir_->functions().Get(callee.function_id),
step_stack_->PushEntityName(sem_ir_->functions().Get(fn->function_id),
inst.specific_id);
} else {
step_stack_->PushString("<invalid specific function>");
return;
}
step_stack_->PushString("<invalid specific function>");
}
auto StringifyInst(InstId /*inst_id*/, StructType inst) -> void {