Add diagnostic support so that we can just pass in TypeId. (#3695)

Note we may also want to do this with NameId, maybe some other things,
but the TypeId use is pretty broad and repetitive -- I thought I'd start
with it first.
This commit is contained in:
Jon Ross-Perkins
2024-02-09 16:25:23 +00:00
committed by GitHub
parent bdff7ccf28
commit 1bf4dc53d9
16 changed files with 168 additions and 104 deletions
+4 -5
View File
@@ -257,11 +257,10 @@ static auto PerformAggregateIndex(Context& context, SemIR::Inst inst)
context.ints().Get(bound->int_id).ule(index_val.getZExtValue())) {
CARBON_DIAGNOSTIC(ArrayIndexOutOfBounds, Error,
"Array index `{0}` is past the end of type `{1}`.",
llvm::APSInt, std::string);
context.emitter().Emit(
index_inst.index_id, ArrayIndexOutOfBounds,
llvm::APSInt(index_val, /*isUnsigned=*/true),
context.sem_ir().StringifyType(aggregate_type_id));
llvm::APSInt, SemIR::TypeId);
context.emitter().Emit(index_inst.index_id, ArrayIndexOutOfBounds,
llvm::APSInt(index_val, /*isUnsigned=*/true),
aggregate_type_id);
return SemIR::ConstantId::Error;
}
}