Change result_id to use is_valid instead of an optional. (#2449)

Incrementally shrinks size, but should also make the errors a bit clearer with better context.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2022-12-07 16:30:23 -08:00
1 parent ee998c99ff
commit 34b5349df9
4 files changed
+21 -8

No files matched your search

+4
View File
@@ -23,6 +23,7 @@ struct SemanticsNodeId : public IndexBase {
static auto MakeCrossReference(int32_t index) -> SemanticsNodeId {
return SemanticsNodeId(index | CrossReferenceBit);
}
// Constructs a cross-reference node ID for a builtin. This relies on
// SemanticsIR guarantees for builtin cross-reference placement.
static auto MakeBuiltinReference(SemanticsBuiltinKind kind)
@@ -30,6 +31,9 @@ struct SemanticsNodeId : public IndexBase {
return MakeCrossReference(kind.AsInt());
}
// Constructs an explicitly invalid instance.
static auto MakeInvalid() -> SemanticsNodeId { return SemanticsNodeId(); }
using IndexBase::IndexBase;
auto is_cross_reference() const -> bool { return index & CrossReferenceBit; }