Simplify interface for getting an instruction from a type. (#3455)

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2023-12-08 21:50:33 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 5897e57c21
commit cef7eb5522
14 changed files with 211 additions and 172 deletions
+2 -3
View File
@@ -150,10 +150,9 @@ auto HandlePrefixOperator(Context& context, Parse::NodeId parse_node) -> bool {
value_id = ConvertToValueExpr(context, value_id);
auto type_id =
context.GetUnqualifiedType(context.insts().Get(value_id).type_id());
auto type_inst = context.insts().Get(
context.sem_ir().GetTypeAllowBuiltinTypes(type_id));
auto result_type_id = SemIR::TypeId::Error;
if (auto pointer_type = type_inst.TryAs<SemIR::PointerType>()) {
if (auto pointer_type =
context.types().TryGetAs<SemIR::PointerType>(type_id)) {
result_type_id = pointer_type->pointee_id;
} else if (type_id != SemIR::TypeId::Error) {
CARBON_DIAGNOSTIC(