Remove the SemIRLoc typedef (#5299)

Replace SemIRLoc typedef uses with explicitly SemIR::LocId, loc ->
loc_id for consistency.
This commit is contained in:
Jon Ross-Perkins
2025-04-14 14:28:15 +00:00
committed by GitHub
parent 77cbcd0aa8
commit 55da026a46
27 changed files with 253 additions and 236 deletions
+9 -9
View File
@@ -11,8 +11,8 @@
namespace Carbon::Check {
// Enforces that an integer type has a valid bit width.
auto ValidateIntType(Context& context, SemIRLoc loc, SemIR::IntType result)
-> bool {
auto ValidateIntType(Context& context, SemIR::LocId loc_id,
SemIR::IntType result) -> bool {
auto bit_width =
context.insts().TryGetAs<SemIR::IntValue>(result.bit_width_id);
if (!bit_width) {
@@ -26,7 +26,7 @@ auto ValidateIntType(Context& context, SemIRLoc loc, SemIR::IntType result)
CARBON_DIAGNOSTIC(IntWidthNotPositive, Error,
"integer type width of {0} is not positive", TypedInt);
context.emitter().Emit(
loc, IntWidthNotPositive,
loc_id, IntWidthNotPositive,
{.type = bit_width->type_id, .value = bit_width_val});
return false;
}
@@ -35,7 +35,7 @@ auto ValidateIntType(Context& context, SemIRLoc loc, SemIR::IntType result)
"integer type width of {0} is greater than the "
"maximum supported width of {1}",
TypedInt, int);
context.emitter().Emit(loc, IntWidthTooLarge,
context.emitter().Emit(loc_id, IntWidthTooLarge,
{.type = bit_width->type_id, .value = bit_width_val},
IntStore::MaxIntWidth);
return false;
@@ -44,7 +44,7 @@ auto ValidateIntType(Context& context, SemIRLoc loc, SemIR::IntType result)
}
// Enforces that the bit width is 64 for a float.
auto ValidateFloatBitWidth(Context& context, SemIRLoc loc,
auto ValidateFloatBitWidth(Context& context, SemIR::LocId loc_id,
SemIR::InstId inst_id) -> bool {
auto inst = context.insts().GetAs<SemIR::IntValue>(inst_id);
if (context.ints().Get(inst.int_id) == 64) {
@@ -52,20 +52,20 @@ auto ValidateFloatBitWidth(Context& context, SemIRLoc loc,
}
CARBON_DIAGNOSTIC(CompileTimeFloatBitWidth, Error, "bit width must be 64");
context.emitter().Emit(loc, CompileTimeFloatBitWidth);
context.emitter().Emit(loc_id, CompileTimeFloatBitWidth);
return false;
}
// Enforces that a float type has a valid bit width.
auto ValidateFloatType(Context& context, SemIRLoc loc, SemIR::FloatType result)
-> bool {
auto ValidateFloatType(Context& context, SemIR::LocId loc_id,
SemIR::FloatType result) -> bool {
auto bit_width =
context.insts().TryGetAs<SemIR::IntValue>(result.bit_width_id);
if (!bit_width) {
// Symbolic bit width.
return true;
}
return ValidateFloatBitWidth(context, loc, result.bit_width_id);
return ValidateFloatBitWidth(context, loc_id, result.bit_width_id);
}
// Gets or forms a type_id for a type, given the instruction kind and arguments.