mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Rename the builtin FloatType to LegacyFloatType, Error to ErrorInst (#4555)
This is for more clearly distinct names, and to make it a clearer transition from `BuiltinInst` for name conflicts. `FloatType` is also an instruction, and we have `Carbon::Error` (common/error.h). This avoids affecting tests, although the name is embedded in the builtin test. In `LegacyFloatType`, `Legacy` because I was having trouble coming up with a more appropriate name. I'm not clear this is a `FloatLiteralType` at present, it needs some work to mirror `IntLiteralType`. In `ErrorInst`, the suffix `Inst` was discussed as good and similar to `BuiltinInst` (although I'm trying to get rid of that).
This commit is contained in:
+23
-23
@@ -247,7 +247,7 @@ static auto ConvertTupleToArray(Context& context, SemIR::TupleType tuple_type,
|
||||
? ArrayInitFromExprArgCountMismatch
|
||||
: ArrayInitFromLiteralArgCountMismatch,
|
||||
array_bound, tuple_elem_types.size());
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
PendingBlock target_block_storage(context);
|
||||
@@ -276,8 +276,8 @@ static auto ConvertTupleToArray(Context& context, SemIR::TupleType tuple_type,
|
||||
context, value_loc_id, value_id, src_type_id, literal_elems,
|
||||
ConversionTarget::FullInitializer, return_slot_id,
|
||||
array_type.element_type_id, target_block, i);
|
||||
if (init_id == SemIR::InstId::BuiltinError) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
if (init_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
inits.push_back(init_id);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ static auto ConvertTupleToTuple(Context& context, SemIR::TupleType src_type,
|
||||
IntAsSelect, IntAsSelect);
|
||||
context.emitter().Emit(value_loc_id, TupleInitElementCountMismatch,
|
||||
dest_elem_types.size(), src_elem_types.size());
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// If we're forming an initializer, then we want an initializer for each
|
||||
@@ -357,8 +357,8 @@ static auto ConvertTupleToTuple(Context& context, SemIR::TupleType src_type,
|
||||
ConvertAggregateElement<SemIR::TupleAccess, SemIR::TupleAccess>(
|
||||
context, value_loc_id, value_id, src_type_id, literal_elems,
|
||||
inner_kind, target.init_id, dest_type_id, target.init_block, i);
|
||||
if (init_id == SemIR::InstId::BuiltinError) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
if (init_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
new_block.Set(i, init_id);
|
||||
}
|
||||
@@ -423,7 +423,7 @@ static auto ConvertStructToStructOrClass(Context& context,
|
||||
context.emitter().Emit(value_loc_id, StructInitElementCountMismatch,
|
||||
ToClass, dest_elem_fields_size,
|
||||
src_elem_fields.size());
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Prepare to look up fields in the source by index.
|
||||
@@ -459,7 +459,7 @@ static auto ConvertStructToStructOrClass(Context& context,
|
||||
for (auto [i, dest_field] : llvm::enumerate(dest_elem_fields)) {
|
||||
if (dest_field.name_id == SemIR::NameId::Vptr) {
|
||||
// TODO: Initialize the vptr to point to a vtable.
|
||||
new_block.Set(i, SemIR::InstId::BuiltinError);
|
||||
new_block.Set(i, SemIR::InstId::BuiltinErrorInst);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ static auto ConvertStructToStructOrClass(Context& context,
|
||||
StructInitMissingFieldInConversion, value_id,
|
||||
target.type_id, dest_field.name_id);
|
||||
}
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
}
|
||||
auto src_field = src_elem_fields[src_field_index];
|
||||
@@ -497,8 +497,8 @@ static auto ConvertStructToStructOrClass(Context& context,
|
||||
context, value_loc_id, value_id, src_field.type_id, literal_elems,
|
||||
inner_kind, target.init_id, dest_field.type_id, target.init_block,
|
||||
src_field_index);
|
||||
if (init_id == SemIR::InstId::BuiltinError) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
if (init_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
new_block.Set(i, init_id);
|
||||
}
|
||||
@@ -548,7 +548,7 @@ static auto ConvertStructToClass(Context& context, SemIR::StructType src_type,
|
||||
auto object_repr_id =
|
||||
dest_class_info.GetObjectRepr(context.sem_ir(), dest_type.specific_id);
|
||||
if (object_repr_id == SemIR::TypeId::Error) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
auto dest_struct_type =
|
||||
context.types().GetAs<SemIR::StructType>(object_repr_id);
|
||||
@@ -911,7 +911,7 @@ static auto PerformCopy(Context& context, SemIR::InstId expr_id)
|
||||
auto expr = context.insts().Get(expr_id);
|
||||
auto type_id = expr.type_id();
|
||||
if (type_id == SemIR::TypeId::Error) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// TODO: Directly track on the value representation whether it's a copy of
|
||||
@@ -930,7 +930,7 @@ static auto PerformCopy(Context& context, SemIR::InstId expr_id)
|
||||
CARBON_DIAGNOSTIC(CopyOfUncopyableType, Error,
|
||||
"cannot copy value of type {0}", TypeOfInstId);
|
||||
context.emitter().Emit(expr_id, CopyOfUncopyableType, expr_id);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
|
||||
@@ -942,7 +942,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
|
||||
// result is invalid and we shouldn't error.
|
||||
if (sem_ir.insts().Get(expr_id).type_id() == SemIR::TypeId::Error ||
|
||||
target.type_id == SemIR::TypeId::Error) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
if (SemIR::GetExprCategory(sem_ir, expr_id) == SemIR::ExprCategory::NotExpr) {
|
||||
@@ -952,7 +952,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
|
||||
CARBON_DIAGNOSTIC(UseOfNonExprAsValue, Error,
|
||||
"expression cannot be used as a value");
|
||||
context.emitter().Emit(expr_id, UseOfNonExprAsValue);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// We can only perform initialization for complete types.
|
||||
@@ -985,12 +985,12 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
|
||||
return context.emitter().Build(loc_id, AbstractTypeInInit,
|
||||
target.type_id);
|
||||
})) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Check whether any builtin conversion applies.
|
||||
expr_id = PerformBuiltinConversion(context, loc_id, expr_id, target);
|
||||
if (expr_id == SemIR::InstId::BuiltinError) {
|
||||
if (expr_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return expr_id;
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
|
||||
});
|
||||
|
||||
// Pull a value directly out of the initializer if possible and wanted.
|
||||
if (expr_id != SemIR::InstId::BuiltinError &&
|
||||
if (expr_id != SemIR::InstId::BuiltinErrorInst &&
|
||||
CanUseValueOfInitializer(sem_ir, target.type_id, target.kind)) {
|
||||
expr_id = context.AddInst<SemIR::ValueOfInitializer>(
|
||||
loc_id, {.type_id = target.type_id, .init_id = expr_id});
|
||||
@@ -1049,7 +1049,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
|
||||
sem_ir.insts().Get(expr_id));
|
||||
|
||||
case SemIR::ExprCategory::Error:
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
|
||||
case SemIR::ExprCategory::Initializing:
|
||||
if (target.is_initializer()) {
|
||||
@@ -1202,7 +1202,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
|
||||
.Build(call_loc_id, MissingObjectInMethodCall)
|
||||
.Note(callee_decl_id, InCallToFunction)
|
||||
.Emit();
|
||||
self_id = SemIR::InstId::BuiltinError;
|
||||
self_id = SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
return CallerPatternMatch(context, callee_specific_id, self_param_id,
|
||||
@@ -1214,7 +1214,7 @@ auto ExprAsType(Context& context, SemIR::LocId loc_id, SemIR::InstId value_id)
|
||||
-> TypeExpr {
|
||||
auto type_inst_id =
|
||||
ConvertToValueOfType(context, loc_id, value_id, SemIR::TypeId::TypeType);
|
||||
if (type_inst_id == SemIR::InstId::BuiltinError) {
|
||||
if (type_inst_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return {.inst_id = type_inst_id, .type_id = SemIR::TypeId::Error};
|
||||
}
|
||||
|
||||
@@ -1223,7 +1223,7 @@ auto ExprAsType(Context& context, SemIR::LocId loc_id, SemIR::InstId value_id)
|
||||
CARBON_DIAGNOSTIC(TypeExprEvaluationFailure, Error,
|
||||
"cannot evaluate type expression");
|
||||
context.emitter().Emit(loc_id, TypeExprEvaluationFailure);
|
||||
return {.inst_id = SemIR::InstId::BuiltinError,
|
||||
return {.inst_id = SemIR::InstId::BuiltinErrorInst,
|
||||
.type_id = SemIR::TypeId::Error};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user