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:
@@ -94,7 +94,7 @@ static auto PerformCallToGenericClass(Context& context, SemIR::LocId loc_id,
|
||||
EntityKind::GenericClass, enclosing_specific_id,
|
||||
/*self_id=*/SemIR::InstId::Invalid, arg_ids);
|
||||
if (!callee_specific_id) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
return context.GetOrAddInst<SemIR::ClassType>(
|
||||
loc_id, {.type_id = SemIR::TypeId::TypeType,
|
||||
@@ -114,7 +114,7 @@ static auto PerformCallToGenericInterface(
|
||||
EntityKind::GenericInterface, enclosing_specific_id,
|
||||
/*self_id=*/SemIR::InstId::Invalid, arg_ids);
|
||||
if (!callee_specific_id) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
return context.GetOrAddInst(loc_id, context.FacetTypeFromInterface(
|
||||
interface_id, *callee_specific_id));
|
||||
@@ -144,7 +144,7 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id,
|
||||
"value of type {0} is not callable", TypeOfInstId);
|
||||
context.emitter().Emit(loc_id, CallToNonCallable, callee_id);
|
||||
}
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id,
|
||||
EntityKind::Function, callee_function.enclosing_specific_id,
|
||||
callee_function.self_id, arg_ids);
|
||||
if (!callee_specific_id) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
if (callee_specific_id->is_valid()) {
|
||||
callee_id = context.GetOrAddInst(
|
||||
|
||||
@@ -60,7 +60,7 @@ Context::Context(const Lex::TokenizedBuffer& tokens, DiagnosticEmitter& emitter,
|
||||
// Map the builtin `<error>` and `type` type constants to their corresponding
|
||||
// special `TypeId` values.
|
||||
type_ids_for_type_constants_.Insert(
|
||||
SemIR::ConstantId::ForTemplateConstant(SemIR::InstId::BuiltinError),
|
||||
SemIR::ConstantId::ForTemplateConstant(SemIR::InstId::BuiltinErrorInst),
|
||||
SemIR::TypeId::Error);
|
||||
type_ids_for_type_constants_.Insert(
|
||||
SemIR::ConstantId::ForTemplateConstant(SemIR::InstId::BuiltinTypeType),
|
||||
@@ -345,7 +345,7 @@ auto Context::LookupUnqualifiedName(Parse::NodeId node_id,
|
||||
}
|
||||
|
||||
return {.specific_id = SemIR::SpecificId::Invalid,
|
||||
.inst_id = SemIR::InstId::BuiltinError};
|
||||
.inst_id = SemIR::InstId::BuiltinErrorInst};
|
||||
}
|
||||
|
||||
auto Context::LookupNameInExactScope(SemIRLoc loc, SemIR::NameId name_id,
|
||||
@@ -571,7 +571,7 @@ auto Context::LookupQualifiedName(SemIRLoc loc, SemIR::NameId name_id,
|
||||
emitter_->Emit(loc, NameAmbiguousDueToExtend, name_id);
|
||||
// TODO: Add notes pointing to the scopes.
|
||||
return {.specific_id = SemIR::SpecificId::Invalid,
|
||||
.inst_id = SemIR::InstId::BuiltinError};
|
||||
.inst_id = SemIR::InstId::BuiltinErrorInst};
|
||||
}
|
||||
|
||||
result.inst_id = scope_result_id;
|
||||
@@ -597,7 +597,7 @@ auto Context::LookupQualifiedName(SemIRLoc loc, SemIR::NameId name_id,
|
||||
}
|
||||
|
||||
return {.specific_id = SemIR::SpecificId::Invalid,
|
||||
.inst_id = SemIR::InstId::BuiltinError};
|
||||
.inst_id = SemIR::InstId::BuiltinErrorInst};
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -639,7 +639,7 @@ auto Context::LookupNameInCore(SemIRLoc loc, llvm::StringRef name)
|
||||
-> SemIR::InstId {
|
||||
auto core_package_id = GetCorePackage(*this, loc);
|
||||
if (!core_package_id.is_valid()) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto name_id = SemIR::NameId::ForIdentifier(identifiers().Add(name));
|
||||
@@ -651,7 +651,7 @@ auto Context::LookupNameInCore(SemIRLoc loc, llvm::StringRef name)
|
||||
"name `Core.{0}` implicitly referenced here, but not found",
|
||||
SemIR::NameId);
|
||||
emitter_->Emit(loc, CoreNameNotFound, name_id);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Look through import_refs and aliases.
|
||||
@@ -1006,11 +1006,11 @@ class TypeCompleter {
|
||||
switch (builtin.builtin_inst_kind) {
|
||||
case SemIR::BuiltinInstKind::TypeType:
|
||||
case SemIR::BuiltinInstKind::AutoType:
|
||||
case SemIR::BuiltinInstKind::Error:
|
||||
case SemIR::BuiltinInstKind::ErrorInst:
|
||||
case SemIR::BuiltinInstKind::Invalid:
|
||||
case SemIR::BuiltinInstKind::BoolType:
|
||||
case SemIR::BuiltinInstKind::IntLiteralType:
|
||||
case SemIR::BuiltinInstKind::FloatType:
|
||||
case SemIR::BuiltinInstKind::LegacyFloatType:
|
||||
case SemIR::BuiltinInstKind::NamespaceType:
|
||||
case SemIR::BuiltinInstKind::BoundMethodType:
|
||||
case SemIR::BuiltinInstKind::WitnessType:
|
||||
|
||||
@@ -242,7 +242,7 @@ class Context {
|
||||
-> LookupResult;
|
||||
|
||||
// Returns the instruction corresponding to a name in the core package, or
|
||||
// BuiltinError if not found.
|
||||
// BuiltinErrorInst if not found.
|
||||
auto LookupNameInCore(SemIRLoc loc, llvm::StringRef name) -> SemIR::InstId;
|
||||
|
||||
// Prints a diagnostic for a duplicate name.
|
||||
|
||||
+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};
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
|
||||
|
||||
// A type that has been converted for use as a type expression.
|
||||
struct TypeExpr {
|
||||
// The converted expression of type `type`, or `InstId::BuiltinError`.
|
||||
// The converted expression of type `type`, or `InstId::BuiltinErrorInst`.
|
||||
SemIR::InstId inst_id;
|
||||
// The corresponding type, or `TypeId::Error`.
|
||||
SemIR::TypeId type_id;
|
||||
|
||||
@@ -322,7 +322,7 @@ auto DeductionContext::Deduce() -> bool {
|
||||
DiagnosticAnnotationScope annotate_diagnostics(&context().emitter(),
|
||||
note_initializing_param);
|
||||
arg_id = ConvertToValueOfType(context(), loc_id_, arg_id, param_type_id);
|
||||
if (arg_id == SemIR::InstId::BuiltinError) {
|
||||
if (arg_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,7 +1075,8 @@ static auto MakeConstantForBuiltinCall(Context& context, SemIRLoc loc,
|
||||
if (!ValidateFloatBitWidth(context, loc, arg_ids[0])) {
|
||||
return SemIR::ConstantId::Error;
|
||||
}
|
||||
return context.constant_values().Get(SemIR::InstId::BuiltinFloatType);
|
||||
return context.constant_values().Get(
|
||||
SemIR::InstId::BuiltinLegacyFloatType);
|
||||
}
|
||||
|
||||
case SemIR::BuiltinFunctionKind::BoolMakeType: {
|
||||
@@ -1716,7 +1717,8 @@ auto TryEvalBlockForSpecific(Context& context, SemIR::SpecificId specific_id,
|
||||
result[i] = context.constant_values().GetInstId(const_id);
|
||||
|
||||
// TODO: If this becomes possible through monomorphization failure, produce
|
||||
// a diagnostic and put `SemIR::InstId::BuiltinError` in the table entry.
|
||||
// a diagnostic and put `SemIR::InstId::BuiltinErrorInst` in the table
|
||||
// entry.
|
||||
CARBON_CHECK(result[i].is_valid());
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ auto HandleParseNode(Context& context, Parse::AliasId /*node_id*/) -> bool {
|
||||
"alias initializer must be a name reference");
|
||||
context.emitter().Emit(expr_node, AliasRequiresNameRef);
|
||||
alias_type_id = SemIR::TypeId::Error;
|
||||
alias_value_id = SemIR::InstId::BuiltinError;
|
||||
alias_value_id = SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
auto alias_id = context.AddInst<SemIR::BindAlias>(
|
||||
name_context.loc_id, {.type_id = alias_type_id,
|
||||
|
||||
@@ -46,7 +46,7 @@ auto HandleParseNode(Context& context, Parse::ArrayExprId node_id) -> bool {
|
||||
if (!context.constant_values().Get(bound_inst_id).is_constant()) {
|
||||
CARBON_DIAGNOSTIC(InvalidArrayExpr, Error, "array bound is not a constant");
|
||||
context.emitter().Emit(bound_inst_id, InvalidArrayExpr);
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinErrorInst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,10 +201,10 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
|
||||
break;
|
||||
}
|
||||
if (had_error) {
|
||||
context.AddNameToLookup(name_id, SemIR::InstId::BuiltinError);
|
||||
context.AddNameToLookup(name_id, SemIR::InstId::BuiltinErrorInst);
|
||||
// Replace the parameter with an invalid instruction so that we don't
|
||||
// try constructing a generic based on it.
|
||||
param_pattern_id = SemIR::InstId::BuiltinError;
|
||||
param_pattern_id = SemIR::InstId::BuiltinErrorInst;
|
||||
} else {
|
||||
auto bind_id = context.AddInstInNoBlock(
|
||||
make_bind_name(cast_type_id, SemIR::InstId::Invalid));
|
||||
|
||||
@@ -569,7 +569,7 @@ static auto CheckCompleteAdapterClassType(Context& context,
|
||||
.Build(class_info.adapt_id, AdaptWithBase)
|
||||
.Note(class_info.base_id, AdaptWithBaseHere)
|
||||
.Emit();
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
if (auto fields = context.struct_type_fields().Get(fields_id);
|
||||
@@ -584,7 +584,7 @@ static auto CheckCompleteAdapterClassType(Context& context,
|
||||
.Build(class_info.adapt_id, AdaptWithFields)
|
||||
.Note(first_field_inst_id, AdaptWithFieldHere)
|
||||
.Emit();
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
for (auto inst_id : context.inst_block_stack().PeekCurrentBlockContents()) {
|
||||
@@ -601,7 +601,7 @@ static auto CheckCompleteAdapterClassType(Context& context,
|
||||
.Build(class_info.adapt_id, AdaptWithVirtual)
|
||||
.Note(inst_id, AdaptWithVirtualHere)
|
||||
.Emit();
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ static auto HandleFunctionDefinitionAfterSignature(
|
||||
for (auto param_ref_id : llvm::concat<const SemIR::InstId>(
|
||||
context.inst_blocks().GetOrEmpty(function.implicit_param_refs_id),
|
||||
context.inst_blocks().GetOrEmpty(function.param_refs_id))) {
|
||||
if (param_ref_id == SemIR::InstId::BuiltinError) {
|
||||
if (param_ref_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
continue;
|
||||
}
|
||||
auto param_info =
|
||||
|
||||
@@ -97,7 +97,7 @@ static auto PerformIndexWith(Context& context, Parse::NodeId node_id,
|
||||
CARBON_DIAGNOSTIC(TypeNotIndexable, Error,
|
||||
"type {0} does not support indexing", SemIR::TypeId);
|
||||
context.emitter().Emit(node_id, TypeNotIndexable, operand_type_id);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
Operator op{
|
||||
@@ -160,7 +160,7 @@ auto HandleParseNode(Context& context, Parse::IndexExprId node_id) -> bool {
|
||||
}
|
||||
|
||||
default: {
|
||||
auto elem_id = SemIR::InstId::BuiltinError;
|
||||
auto elem_id = SemIR::InstId::BuiltinErrorInst;
|
||||
if (operand_type_id != SemIR::TypeId::Error) {
|
||||
elem_id = PerformIndexWith(context, node_id, operand_inst_id,
|
||||
operand_type_id, index_inst_id);
|
||||
|
||||
@@ -245,8 +245,8 @@ auto HandleParseNode(Context& context, Parse::LetDeclId node_id) -> bool {
|
||||
auto bind_name = pattern.inst.As<SemIR::AnyBindName>();
|
||||
CARBON_CHECK(!bind_name.value_id.is_valid(),
|
||||
"Binding should not already have a value!");
|
||||
bind_name.value_id =
|
||||
decl_info->init_id ? *decl_info->init_id : SemIR::InstId::BuiltinError;
|
||||
bind_name.value_id = decl_info->init_id ? *decl_info->init_id
|
||||
: SemIR::InstId::BuiltinErrorInst;
|
||||
context.ReplaceInstBeforeConstantUse(decl_info->pattern_id, bind_name);
|
||||
context.inst_block_stack().AddInstId(decl_info->pattern_id);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ auto HandleParseNode(Context& context, Parse::RealLiteralId node_id) -> bool {
|
||||
llvm::APSInt);
|
||||
context.emitter().Emit(node_id, RealMantissaTooLargeForI64,
|
||||
llvm::APSInt(real_value.mantissa, true));
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinErrorInst);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ auto HandleParseNode(Context& context, Parse::RealLiteralId node_id) -> bool {
|
||||
llvm::APSInt);
|
||||
context.emitter().Emit(node_id, RealExponentTooLargeForI64,
|
||||
llvm::APSInt(real_value.exponent, false));
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinErrorInst);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,9 +84,9 @@ auto HandleParseNode(Context& context, Parse::RealLiteralId node_id) -> bool {
|
||||
|
||||
auto float_id = context.sem_ir().floats().Add(llvm::APFloat(double_val));
|
||||
context.AddInstAndPush<SemIR::FloatLiteral>(
|
||||
node_id,
|
||||
{.type_id = context.GetBuiltinType(SemIR::BuiltinInstKind::FloatType),
|
||||
.float_id = float_id});
|
||||
node_id, {.type_id = context.GetBuiltinType(
|
||||
SemIR::BuiltinInstKind::LegacyFloatType),
|
||||
.float_id = float_id});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,13 +233,13 @@ auto HandleParseNode(Context& context, Parse::PrefixOperatorAmpId node_id)
|
||||
CARBON_DIAGNOSTIC(AddrOfEphemeralRef, Error,
|
||||
"cannot take the address of a temporary object");
|
||||
context.emitter().Emit(TokenOnly(node_id), AddrOfEphemeralRef);
|
||||
value_id = SemIR::InstId::BuiltinError;
|
||||
value_id = SemIR::InstId::BuiltinErrorInst;
|
||||
break;
|
||||
default:
|
||||
CARBON_DIAGNOSTIC(AddrOfNonRef, Error,
|
||||
"cannot take the address of non-reference expression");
|
||||
context.emitter().Emit(TokenOnly(node_id), AddrOfNonRef);
|
||||
value_id = SemIR::InstId::BuiltinError;
|
||||
value_id = SemIR::InstId::BuiltinErrorInst;
|
||||
break;
|
||||
}
|
||||
context.AddInstAndPush<SemIR::AddrOf>(
|
||||
|
||||
@@ -139,7 +139,7 @@ auto HandleParseNode(Context& context, Parse::StructLiteralId node_id) -> bool {
|
||||
|
||||
if (DiagnoseDuplicateNames(context, field_name_nodes, fields,
|
||||
/*is_struct_type_literal=*/false)) {
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinErrorInst);
|
||||
} else {
|
||||
auto type_id = context.GetStructType(
|
||||
context.struct_type_fields().AddCanonical(fields));
|
||||
@@ -165,7 +165,7 @@ auto HandleParseNode(Context& context, Parse::StructTypeLiteralId node_id)
|
||||
|
||||
if (DiagnoseDuplicateNames(context, field_name_nodes, fields,
|
||||
/*is_struct_type_literal=*/true)) {
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
|
||||
context.node_stack().Push(node_id, SemIR::InstId::BuiltinErrorInst);
|
||||
} else {
|
||||
auto fields_id = context.struct_type_fields().AddCanonical(fields);
|
||||
context.AddInstAndPush<SemIR::StructType>(
|
||||
|
||||
@@ -103,7 +103,7 @@ auto HandleParseNode(Context& context, Parse::RequirementImplsId node_id)
|
||||
ImplsOnNonFacetType, Error,
|
||||
"right argument of `impls` requirement must be a facet type");
|
||||
context.emitter().Emit(rhs_node, ImplsOnNonFacetType);
|
||||
rhs_as_type.inst_id = SemIR::InstId::BuiltinError;
|
||||
rhs_as_type.inst_id = SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
// TODO: Require that at least one side uses a designator.
|
||||
|
||||
|
||||
+12
-12
@@ -78,7 +78,7 @@ static auto GetSelfSpecificForInterfaceMemberWithSelfType(
|
||||
// Checks that `impl_function_id` is a valid implementation of the function
|
||||
// described in the interface as `interface_function_id`. Returns the value to
|
||||
// put into the corresponding slot in the witness table, which can be
|
||||
// `BuiltinError` if the function is not usable.
|
||||
// `BuiltinErrorInst` if the function is not usable.
|
||||
static auto CheckAssociatedFunctionImplementation(
|
||||
Context& context, SemIR::FunctionType interface_function_type,
|
||||
SemIR::InstId impl_decl_id, SemIR::TypeId self_type_id) -> SemIR::InstId {
|
||||
@@ -95,7 +95,7 @@ static auto CheckAssociatedFunctionImplementation(
|
||||
interface_function_type.function_id);
|
||||
builder.Emit();
|
||||
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Map from the specific for the function type to the specific for the
|
||||
@@ -117,7 +117,7 @@ static auto CheckAssociatedFunctionImplementation(
|
||||
context.functions().Get(interface_function_type.function_id),
|
||||
interface_function_specific_id,
|
||||
/*check_syntax=*/false)) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
return impl_decl_id;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ static auto BuildInterfaceWitness(
|
||||
return context.emitter().Build(
|
||||
impl.definition_id, ImplOfUndefinedInterface, interface.name_id);
|
||||
})) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto& impl_scope = context.name_scopes().Get(impl.scope_id);
|
||||
@@ -159,7 +159,7 @@ static auto BuildInterfaceWitness(
|
||||
CARBON_KIND_SWITCH(decl) {
|
||||
case CARBON_KIND(SemIR::StructValue struct_value): {
|
||||
if (struct_value.type_id == SemIR::TypeId::Error) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
auto type_inst = context.types().GetAsInst(struct_value.type_id);
|
||||
auto fn_type = type_inst.TryAs<SemIR::FunctionType>();
|
||||
@@ -184,7 +184,7 @@ static auto BuildInterfaceWitness(
|
||||
NoteAssociatedFunction(context, builder, fn_type->function_id);
|
||||
builder.Emit();
|
||||
|
||||
table.push_back(SemIR::InstId::BuiltinError);
|
||||
table.push_back(SemIR::InstId::BuiltinErrorInst);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -192,11 +192,11 @@ static auto BuildInterfaceWitness(
|
||||
// TODO: Check we have a value for this constant in the constraint.
|
||||
context.TODO(impl.definition_id,
|
||||
"impl of interface with associated constant");
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
default:
|
||||
CARBON_CHECK(decl_id == SemIR::InstId::BuiltinError,
|
||||
CARBON_CHECK(decl_id == SemIR::InstId::BuiltinErrorInst,
|
||||
"Unexpected kind of associated entity {0}", decl);
|
||||
table.push_back(SemIR::InstId::BuiltinError);
|
||||
table.push_back(SemIR::InstId::BuiltinErrorInst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -215,13 +215,13 @@ auto BuildImplWitness(Context& context, SemIR::ImplId impl_id)
|
||||
|
||||
auto facet_type_id = context.GetTypeIdForTypeInst(impl.constraint_id);
|
||||
if (facet_type_id == SemIR::TypeId::Error) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
auto facet_type = context.types().TryGetAs<SemIR::FacetType>(facet_type_id);
|
||||
if (!facet_type) {
|
||||
CARBON_DIAGNOSTIC(ImplAsNonFacetType, Error, "impl as non-facet-type");
|
||||
context.emitter().Emit(impl.definition_id, ImplAsNonFacetType);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
const SemIR::FacetTypeInfo& facet_type_info =
|
||||
context.facet_types().Get(facet_type->facet_type_id);
|
||||
@@ -229,7 +229,7 @@ auto BuildImplWitness(Context& context, SemIR::ImplId impl_id)
|
||||
auto interface = facet_type_info.TryAsSingleInterface();
|
||||
if (!interface) {
|
||||
context.TODO(impl.definition_id, "impl as not 1 interface");
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
llvm::SmallVector<SemIR::InstId> used_decl_ids;
|
||||
|
||||
@@ -993,7 +993,7 @@ class ImportRefResolver {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (const_inst_id == SemIR::InstId::BuiltinError) {
|
||||
if (const_inst_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::NameScopeId::Invalid;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -18,7 +18,7 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
|
||||
// This should only happen if the interface is erroneously defined more than
|
||||
// once.
|
||||
// TODO: Find a way to CHECK this.
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// The interface type is the type of `Self`.
|
||||
|
||||
@@ -140,7 +140,7 @@ static auto PerformImplLookup(
|
||||
context.TODO(loc_id,
|
||||
"Lookup of impl witness not yet supported except for a single "
|
||||
"interface");
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto witness_id =
|
||||
@@ -168,22 +168,22 @@ static auto PerformImplLookup(
|
||||
interface_type_id,
|
||||
context.GetTypeIdForTypeConstant(type_const_id));
|
||||
}
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto member_value_id = context.constant_values().GetConstantInstId(member_id);
|
||||
if (!member_value_id.is_valid()) {
|
||||
if (member_value_id != SemIR::InstId::BuiltinError) {
|
||||
if (member_value_id != SemIR::InstId::BuiltinErrorInst) {
|
||||
context.TODO(member_id, "non-constant associated entity");
|
||||
}
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto assoc_entity =
|
||||
context.insts().TryGetAs<SemIR::AssociatedEntity>(member_value_id);
|
||||
if (!assoc_entity) {
|
||||
context.TODO(member_id, "unexpected value for associated entity");
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// TODO: This produces the type of the associated entity with no value for
|
||||
@@ -200,7 +200,7 @@ static auto PerformImplLookup(
|
||||
|
||||
// Performs a member name lookup into the specified scope, including performing
|
||||
// impl lookup if necessary. If the scope is invalid, assume an error has
|
||||
// already been diagnosed, and return BuiltinError.
|
||||
// already been diagnosed, and return BuiltinErrorInst.
|
||||
static auto LookupMemberNameInScope(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::InstId /*base_id*/,
|
||||
SemIR::NameId name_id,
|
||||
@@ -217,7 +217,7 @@ static auto LookupMemberNameInScope(Context& context, SemIR::LocId loc_id,
|
||||
/*required=*/true, access_info);
|
||||
|
||||
if (!result.inst_id.is_valid()) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// TODO: This duplicates the work that HandleNameAsExpr does. Factor this out.
|
||||
@@ -355,7 +355,7 @@ auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
|
||||
return context.emitter().Build(base_id, IncompleteTypeInMemberAccess,
|
||||
base_id);
|
||||
})) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Materialize a temporary for the base expression if necessary.
|
||||
@@ -387,7 +387,7 @@ auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::NameId);
|
||||
context.emitter().Emit(loc_id, QualifiedExprNameNotFound, base_id,
|
||||
name_id);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
if (base_type_id != SemIR::TypeId::Error) {
|
||||
@@ -396,7 +396,7 @@ auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
|
||||
TypeOfInstId);
|
||||
context.emitter().Emit(loc_id, QualifiedExprUnsupported, base_id);
|
||||
}
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Perform lookup into the base type.
|
||||
@@ -461,7 +461,7 @@ auto PerformTupleAccess(Context& context, SemIR::LocId loc_id,
|
||||
"tuples can be indexed that way",
|
||||
TypeOfInstId);
|
||||
context.emitter().Emit(loc_id, TupleIndexOnANonTupleType, tuple_inst_id);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto diag_non_constant_index = [&] {
|
||||
@@ -469,7 +469,7 @@ auto PerformTupleAccess(Context& context, SemIR::LocId loc_id,
|
||||
CARBON_DIAGNOSTIC(TupleIndexNotConstant, Error,
|
||||
"tuple index must be a constant");
|
||||
context.emitter().Emit(loc_id, TupleIndexNotConstant);
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
};
|
||||
// Diagnose a non-constant index prior to conversion to IntLiteral, because
|
||||
// the conversion will fail if the index is not constant.
|
||||
@@ -484,7 +484,7 @@ auto PerformTupleAccess(Context& context, SemIR::LocId loc_id,
|
||||
context.GetBuiltinType(SemIR::BuiltinInstKind::IntLiteralType));
|
||||
auto index_const_id = context.constant_values().Get(index_inst_id);
|
||||
if (index_const_id == SemIR::ConstantId::Error) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
} else if (!index_const_id.is_template()) {
|
||||
return diag_non_constant_index();
|
||||
}
|
||||
@@ -495,7 +495,7 @@ auto PerformTupleAccess(Context& context, SemIR::LocId loc_id,
|
||||
std::optional<llvm::APInt> index_val = ValidateTupleIndex(
|
||||
context, loc_id, tuple_inst_id, index_literal, type_block.size());
|
||||
if (!index_val) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// TODO: Handle the case when `index_val->getZExtValue()` has too many bits.
|
||||
|
||||
@@ -39,8 +39,8 @@ auto BuildUnaryOperator(Context& context, SemIR::LocId loc_id, Operator op,
|
||||
// Form `operand.(Op)`.
|
||||
auto bound_op_id = PerformCompoundMemberAccess(context, loc_id, operand_id,
|
||||
op_fn, missing_impl_diagnoser);
|
||||
if (bound_op_id == SemIR::InstId::BuiltinError) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
if (bound_op_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Form `bound_op()`.
|
||||
@@ -57,8 +57,8 @@ auto BuildBinaryOperator(Context& context, SemIR::LocId loc_id, Operator op,
|
||||
// Form `lhs.(Op)`.
|
||||
auto bound_op_id = PerformCompoundMemberAccess(context, loc_id, lhs_id, op_fn,
|
||||
missing_impl_diagnoser);
|
||||
if (bound_op_id == SemIR::InstId::BuiltinError) {
|
||||
return SemIR::InstId::BuiltinError;
|
||||
if (bound_op_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// Form `bound_op(rhs)`.
|
||||
|
||||
@@ -133,8 +133,8 @@ auto MatchContext::DoWork(Context& context) -> SemIR::InstBlockId {
|
||||
|
||||
auto MatchContext::EmitPatternMatch(Context& context,
|
||||
MatchContext::WorkItem entry) -> void {
|
||||
if (entry.pattern_id == SemIR::InstId::BuiltinError) {
|
||||
results_.push_back(SemIR::InstId::BuiltinError);
|
||||
if (entry.pattern_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
results_.push_back(SemIR::InstId::BuiltinErrorInst);
|
||||
return;
|
||||
}
|
||||
DiagnosticAnnotationScope annotate_diagnostics(
|
||||
@@ -187,7 +187,7 @@ auto MatchContext::EmitPatternMatch(Context& context,
|
||||
context.emitter().Emit(
|
||||
TokenOnly(context.insts().GetLocId(entry.scrutinee_id)),
|
||||
AddrSelfIsNonRef);
|
||||
results_.push_back(SemIR::InstId::BuiltinError);
|
||||
results_.push_back(SemIR::InstId::BuiltinErrorInst);
|
||||
return;
|
||||
}
|
||||
auto scrutinee_ref = context.insts().Get(scrutinee_ref_id);
|
||||
@@ -208,8 +208,8 @@ auto MatchContext::EmitPatternMatch(Context& context,
|
||||
switch (kind_) {
|
||||
case MatchKind::Caller: {
|
||||
CARBON_CHECK(entry.scrutinee_id.is_valid());
|
||||
if (entry.scrutinee_id == SemIR::InstId::BuiltinError) {
|
||||
results_.push_back(SemIR::InstId::BuiltinError);
|
||||
if (entry.scrutinee_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
results_.push_back(SemIR::InstId::BuiltinErrorInst);
|
||||
} else {
|
||||
results_.push_back(ConvertToValueOfType(
|
||||
context, context.insts().GetLocId(entry.scrutinee_id),
|
||||
|
||||
@@ -78,7 +78,7 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node,
|
||||
context.emitter().Build(returned_node, ReturnedVarWithNoReturnType);
|
||||
NoteNoReturnTypeProvided(diag, function);
|
||||
diag.Emit();
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// The declared type of the var must match the return type of the function.
|
||||
@@ -91,7 +91,7 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node,
|
||||
context.emitter().Build(type_node, ReturnedVarWrongType, type_id);
|
||||
NoteReturnType(context, diag, function);
|
||||
diag.Emit();
|
||||
return SemIR::InstId::BuiltinError;
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
// The variable aliases the return slot if there is one. If not, it has its
|
||||
@@ -146,7 +146,7 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id,
|
||||
auto diag = context.emitter().Build(node_id, ReturnStatementDisallowExpr);
|
||||
NoteNoReturnTypeProvided(diag, function);
|
||||
diag.Emit();
|
||||
expr_id = SemIR::InstId::BuiltinError;
|
||||
expr_id = SemIR::InstId::BuiltinErrorInst;
|
||||
} else if (returned_var_id.is_valid()) {
|
||||
CARBON_DIAGNOSTIC(
|
||||
ReturnExprWithReturnedVar, Error,
|
||||
@@ -154,11 +154,11 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id,
|
||||
auto diag = context.emitter().Build(node_id, ReturnExprWithReturnedVar);
|
||||
NoteReturnedVar(diag, returned_var_id);
|
||||
diag.Emit();
|
||||
expr_id = SemIR::InstId::BuiltinError;
|
||||
expr_id = SemIR::InstId::BuiltinErrorInst;
|
||||
} else if (!return_info.is_valid()) {
|
||||
// We already diagnosed that the return type is invalid. Don't try to
|
||||
// convert to it.
|
||||
expr_id = SemIR::InstId::BuiltinError;
|
||||
expr_id = SemIR::InstId::BuiltinErrorInst;
|
||||
} else if (return_info.has_return_slot()) {
|
||||
return_slot_id = function.return_slot_id;
|
||||
// Note that this can import a function and invalidate `function`.
|
||||
@@ -181,7 +181,7 @@ auto BuildReturnVar(Context& context, Parse::ReturnStatementId node_id)
|
||||
CARBON_DIAGNOSTIC(ReturnVarWithNoReturnedVar, Error,
|
||||
"`return var;` with no `returned var` in scope");
|
||||
context.emitter().Emit(node_id, ReturnVarWithNoReturnedVar);
|
||||
returned_var_id = SemIR::InstId::BuiltinError;
|
||||
returned_var_id = SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
auto return_slot_id = function.return_slot_id;
|
||||
|
||||
@@ -122,7 +122,7 @@ auto ScopeStack::LookupInLexicalScopes(SemIR::NameId name_id)
|
||||
|
||||
// If we have no lexical results, check all non-lexical scopes.
|
||||
if (lexical_results.empty()) {
|
||||
return {LexicalLookupHasLoadError() ? SemIR::InstId::BuiltinError
|
||||
return {LexicalLookupHasLoadError() ? SemIR::InstId::BuiltinErrorInst
|
||||
: SemIR::InstId::Invalid,
|
||||
non_lexical_scope_stack_};
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,11 +33,11 @@
|
||||
// CHECK:STDOUT: type_block0: {}
|
||||
// CHECK:STDOUT: insts:
|
||||
// CHECK:STDOUT: instTypeType: {kind: BuiltinInst, arg0: TypeType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instError: {kind: BuiltinInst, arg0: Error, type: typeError}
|
||||
// CHECK:STDOUT: instErrorInst: {kind: BuiltinInst, arg0: ErrorInst, type: typeError}
|
||||
// CHECK:STDOUT: instAutoType: {kind: BuiltinInst, arg0: AutoType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instBoolType: {kind: BuiltinInst, arg0: BoolType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instIntLiteralType: {kind: BuiltinInst, arg0: IntLiteralType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instFloatType: {kind: BuiltinInst, arg0: FloatType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instLegacyFloatType: {kind: BuiltinInst, arg0: LegacyFloatType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instStringType: {kind: BuiltinInst, arg0: StringType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instBoundMethodType: {kind: BuiltinInst, arg0: BoundMethodType, type: typeTypeType}
|
||||
// CHECK:STDOUT: instSpecificFunctionType: {kind: BuiltinInst, arg0: SpecificFunctionType, type: typeTypeType}
|
||||
@@ -47,11 +47,11 @@
|
||||
// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst<invalid>, type: type(instNamespaceType)}
|
||||
// CHECK:STDOUT: constant_values:
|
||||
// CHECK:STDOUT: instTypeType: templateConstant(instTypeType)
|
||||
// CHECK:STDOUT: instError: templateConstant(instError)
|
||||
// CHECK:STDOUT: instErrorInst: templateConstant(instErrorInst)
|
||||
// CHECK:STDOUT: instAutoType: templateConstant(instAutoType)
|
||||
// CHECK:STDOUT: instBoolType: templateConstant(instBoolType)
|
||||
// CHECK:STDOUT: instIntLiteralType: templateConstant(instIntLiteralType)
|
||||
// CHECK:STDOUT: instFloatType: templateConstant(instFloatType)
|
||||
// CHECK:STDOUT: instLegacyFloatType: templateConstant(instLegacyFloatType)
|
||||
// CHECK:STDOUT: instStringType: templateConstant(instStringType)
|
||||
// CHECK:STDOUT: instBoundMethodType: templateConstant(instBoundMethodType)
|
||||
// CHECK:STDOUT: instSpecificFunctionType: templateConstant(instSpecificFunctionType)
|
||||
|
||||
@@ -473,12 +473,12 @@ static auto BuildTypeForInst(FileContext& context, SemIR::BuiltinInst inst)
|
||||
case SemIR::BuiltinInstKind::Invalid:
|
||||
case SemIR::BuiltinInstKind::AutoType:
|
||||
CARBON_FATAL("Unexpected builtin type in lowering: {0}", inst);
|
||||
case SemIR::BuiltinInstKind::Error:
|
||||
case SemIR::BuiltinInstKind::ErrorInst:
|
||||
// This is a complete type but uses of it should never be lowered.
|
||||
return nullptr;
|
||||
case SemIR::BuiltinInstKind::TypeType:
|
||||
return context.GetTypeType();
|
||||
case SemIR::BuiltinInstKind::FloatType:
|
||||
case SemIR::BuiltinInstKind::LegacyFloatType:
|
||||
return llvm::Type::getDoubleTy(context.llvm_context());
|
||||
case SemIR::BuiltinInstKind::BoolType:
|
||||
// TODO: We may want to have different representations for `bool`
|
||||
|
||||
@@ -91,7 +91,8 @@ struct AnyInt {
|
||||
struct AnyFloat {
|
||||
static auto Check(const File& sem_ir, ValidateState& state, TypeId type_id)
|
||||
-> bool {
|
||||
if (BuiltinType<InstId::BuiltinFloatType>::Check(sem_ir, state, type_id)) {
|
||||
if (BuiltinType<InstId::BuiltinLegacyFloatType>::Check(sem_ir, state,
|
||||
type_id)) {
|
||||
return true;
|
||||
}
|
||||
return sem_ir.types().Is<FloatType>(type_id);
|
||||
|
||||
@@ -44,7 +44,7 @@ CARBON_SEM_IR_BUILTIN_INST_KIND(TypeType, "type")
|
||||
// required. For example, when there is a type checking issue, this will be used
|
||||
// in the type_id. It's typically used as a cue that semantic checking doesn't
|
||||
// need to issue further diagnostics.
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(Error, "<error>")
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(ErrorInst, "<error>")
|
||||
|
||||
// Used for the type of patterns that do not match a fixed type.
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(AutoType, "auto")
|
||||
@@ -64,8 +64,10 @@ CARBON_SEM_IR_BUILTIN_INST_KIND(BoolType, "bool")
|
||||
// runtime.
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(IntLiteralType, "Core.IntLiteral")
|
||||
|
||||
// The type of floating point values and real literals, currently always f64.
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(FloatType, "f64")
|
||||
// The legacy float type. This is currently used for real literals, and is
|
||||
// treated as f64. It's separate from `FloatType`, and should change to mirror
|
||||
// integers, likely replacing this with a `FloatLiteralType`.
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(LegacyFloatType, "f64")
|
||||
|
||||
// The type of string values and String literals.
|
||||
CARBON_SEM_IR_BUILTIN_INST_KIND(StringType, "String")
|
||||
|
||||
@@ -43,11 +43,11 @@ File::File(CheckIRId check_ir_id, IdentifierId package_id,
|
||||
// Error uses a self-referential type so that it's not accidentally treated as
|
||||
// a normal type. Every other builtin is a type, including the
|
||||
// self-referential TypeType.
|
||||
#define CARBON_SEM_IR_BUILTIN_INST_KIND(Name, ...) \
|
||||
insts_.AddInNoBlock(LocIdAndInst::NoLoc<BuiltinInst>( \
|
||||
{.type_id = BuiltinInstKind::Name == BuiltinInstKind::Error \
|
||||
? TypeId::Error \
|
||||
: TypeId::TypeType, \
|
||||
#define CARBON_SEM_IR_BUILTIN_INST_KIND(Name, ...) \
|
||||
insts_.AddInNoBlock(LocIdAndInst::NoLoc<BuiltinInst>( \
|
||||
{.type_id = BuiltinInstKind::Name == BuiltinInstKind::ErrorInst \
|
||||
? TypeId::Error \
|
||||
: TypeId::TypeType, \
|
||||
.builtin_inst_kind = BuiltinInstKind::Name}));
|
||||
#include "toolchain/sem_ir/builtin_inst_kind.def"
|
||||
CARBON_CHECK(insts_.size() == BuiltinInstKind::ValidCount,
|
||||
@@ -288,7 +288,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory {
|
||||
return value_category;
|
||||
|
||||
case CARBON_KIND(BuiltinInst inst): {
|
||||
if (inst.builtin_inst_kind == BuiltinInstKind::Error) {
|
||||
if (inst.builtin_inst_kind == BuiltinInstKind::ErrorInst) {
|
||||
return ExprCategory::Error;
|
||||
}
|
||||
return value_category;
|
||||
|
||||
@@ -86,7 +86,7 @@ auto Function::GetNameFromPatternId(const File& sem_ir, InstId pattern_id)
|
||||
inst = sem_ir.insts().Get(inst_id);
|
||||
}
|
||||
|
||||
if (inst_id == SemIR::InstId::BuiltinError) {
|
||||
if (inst_id == SemIR::InstId::BuiltinErrorInst) {
|
||||
return SemIR::NameId::Invalid;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ struct Function : public EntityWithParamsBase,
|
||||
-> ParamPatternInfo;
|
||||
|
||||
// Gets the name from the name binding instruction, or invalid if this pattern
|
||||
// has been replaced with BuiltinError.
|
||||
// has been replaced with BuiltinErrorInst.
|
||||
static auto GetNameFromPatternId(const File& sem_ir, InstId param_pattern_id)
|
||||
-> SemIR::NameId;
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ struct ConstantId : public IdBase, public Printable<ConstantId> {
|
||||
|
||||
constexpr ConstantId ConstantId::NotConstant = ConstantId(NotConstantIndex);
|
||||
constexpr ConstantId ConstantId::Error =
|
||||
ConstantId::ForTemplateConstant(InstId::BuiltinError);
|
||||
ConstantId::ForTemplateConstant(InstId::BuiltinErrorInst);
|
||||
constexpr ConstantId ConstantId::Invalid = ConstantId(InvalidIndex);
|
||||
|
||||
// The ID of a EntityName.
|
||||
|
||||
@@ -31,7 +31,7 @@ struct ImplFields {
|
||||
|
||||
// The following members are set at the `}` of the impl definition.
|
||||
|
||||
// The witness for the impl. This can be `BuiltinError`.
|
||||
// The witness for the impl. This can be `BuiltinErrorInst`.
|
||||
InstId witness_id = InstId::Invalid;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user