Add Inst::IsOneOf to check if an inst is one of a few kinds (#6523)

Adds Inst::IsOneOf which takes a variadic generic parameter pack of
kinds to check against. Also add forwarding functions to TypeStore and
InstStore. Convert uses of the regex `Is<.*\|\|` to IsOneOf.

This is based on #6522
This commit is contained in:
Dana Jansens
2026-01-07 21:41:05 +00:00
committed by GitHub
parent f7fa83ead6
commit 30562826b8
8 changed files with 31 additions and 15 deletions
+1 -2
View File
@@ -758,8 +758,7 @@ static auto IsLiteralType(const File& sem_ir, TypeId type_id) -> bool {
// Unwrap adapters.
type_id = sem_ir.types().GetTransitiveAdaptedType(type_id);
auto type_inst_id = sem_ir.types().GetAsInst(type_id);
return type_inst_id.Is<IntLiteralType>() ||
type_inst_id.Is<FloatLiteralType>();
return type_inst_id.IsOneOf<IntLiteralType, FloatLiteralType>();
}
// Determines whether a builtin call involves an integer or floating-point