Remove InstId::Builtin members (#4632)

- `InstId::Builtin<Inst>` -> `<Inst>::SingletonInstId`
- `InstId::PackageNamespace` -> `Namespace::PackageInstId`
This commit is contained in:
Jon Ross-Perkins
2024-12-05 18:13:46 +00:00
committed by GitHub
parent d79d9e0884
commit efab39cbd9
38 changed files with 131 additions and 150 deletions
+14 -14
View File
@@ -143,17 +143,17 @@ static auto AccessMemberOfInterfaceWitness(
-> SemIR::InstId {
auto member_value_id = context.constant_values().GetConstantInstId(member_id);
if (!member_value_id.is_valid()) {
if (member_value_id != SemIR::InstId::BuiltinErrorInst) {
if (member_value_id != SemIR::ErrorInst::SingletonInstId) {
context.TODO(member_id, "non-constant associated entity");
}
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
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::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
// TODO: This produces the type of the associated entity with no value for
@@ -181,7 +181,7 @@ static auto PerformImplLookup(
context.TODO(loc_id,
"Lookup of impl witness not yet supported except for a single "
"interface");
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
auto witness_id =
@@ -209,7 +209,7 @@ static auto PerformImplLookup(
interface_type_id,
context.GetTypeIdForTypeConstant(type_const_id));
}
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
return AccessMemberOfInterfaceWitness(context, loc_id, witness_id,
interface_type->specific_id, assoc_type,
@@ -236,7 +236,7 @@ static auto LookupMemberNameInScope(Context& context, SemIR::LocId loc_id,
/*required=*/true, access_info);
if (!result.inst_id.is_valid()) {
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
// TODO: This duplicates the work that HandleNameAsExpr does. Factor this out.
@@ -310,7 +310,7 @@ static auto LookupMemberNameInScope(Context& context, SemIR::LocId loc_id,
context.TODO(member_id,
"associated entity not found in facet type, need to do "
"impl lookup");
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
member_id = AccessMemberOfInterfaceWitness(
@@ -432,7 +432,7 @@ auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
return context.emitter().Build(base_id, IncompleteTypeInMemberAccess,
base_id);
})) {
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
// Materialize a temporary for the base expression if necessary.
@@ -464,7 +464,7 @@ auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
SemIR::NameId);
context.emitter().Emit(loc_id, QualifiedExprNameNotFound, base_id,
name_id);
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
if (base_type_id != SemIR::ErrorInst::SingletonTypeId) {
@@ -473,7 +473,7 @@ auto PerformMemberAccess(Context& context, SemIR::LocId loc_id,
TypeOfInstId);
context.emitter().Emit(loc_id, QualifiedExprUnsupported, base_id);
}
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
// Perform lookup into the base type.
@@ -540,7 +540,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::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
auto diag_non_constant_index = [&] {
@@ -548,7 +548,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::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
};
// Diagnose a non-constant index prior to conversion to IntLiteral, because
// the conversion will fail if the index is not constant.
@@ -563,7 +563,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::ErrorInst::SingletonConstantId) {
return SemIR::InstId::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
} else if (!index_const_id.is_template()) {
return diag_non_constant_index();
}
@@ -574,7 +574,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::BuiltinErrorInst;
return SemIR::ErrorInst::SingletonInstId;
}
// TODO: Handle the case when `index_val->getZExtValue()` has too many bits.