Enforce that the parse node for an instruction has the kind specified in the instruction definition (#4264)

Remove `ReusingLoc` and add enforcement that even for imported
locations, the kind of the parse node for an instruction matches the
kind specified in the instruction definition.

Change the node kind for a few instructions to `NodeId`:

- A couple of instructions had a typed node but could be created
implicitly with any node as part of a builtin implicit conversion. This
happened for `AddrOf`, `ArrayIndex`, and `Deref`.
- A bunch of instructions had `InvalidNodeId` as their associated parse
node kind but were actually always created with a location.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2024-08-29 21:10:14 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent dada4fc29f
commit 891c7d8368
14 changed files with 220 additions and 185 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
// not the declaration itself.
auto type_id = context.GetAssociatedEntityType(
self_type_id, context.insts().Get(decl_id).type_id());
return context.AddInstReusingLoc<SemIR::AssociatedEntity>(
return context.AddInst<SemIR::AssociatedEntity>(
context.insts().GetLocId(decl_id),
{.type_id = type_id, .index = index, .decl_id = decl_id});
}