mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:11:05 +01:00
Change the builtin enum approach to enforce addition. (#2584)
It feels like every time I add a builtin, I forget to add it to the builtin IR. This approach enforces the addition of builtin nodes, and also takes advantage of the normalized structure to set types appropriately (I think the new approach is simpler on this aspect).
This commit is contained in:
@@ -22,7 +22,7 @@ struct SemanticsNodeId : public IndexBase {
|
||||
static const SemanticsNodeId Invalid;
|
||||
|
||||
// Builtin node IDs.
|
||||
#define CARBON_SEMANTICS_BUILTIN_KIND(Name) \
|
||||
#define CARBON_SEMANTICS_BUILTIN_KIND_NAME(Name) \
|
||||
static const SemanticsNodeId Builtin##Name;
|
||||
#include "toolchain/semantics/semantics_builtin_kind.def"
|
||||
|
||||
@@ -37,7 +37,7 @@ constexpr SemanticsNodeId SemanticsNodeId::Invalid = SemanticsNodeId();
|
||||
|
||||
// Uses the cross-reference node ID for a builtin. This relies on SemanticsIR
|
||||
// guarantees for builtin cross-reference placement.
|
||||
#define CARBON_SEMANTICS_BUILTIN_KIND(Name) \
|
||||
#define CARBON_SEMANTICS_BUILTIN_KIND_NAME(Name) \
|
||||
constexpr SemanticsNodeId SemanticsNodeId::Builtin##Name = \
|
||||
SemanticsNodeId(SemanticsBuiltinKind::Name.AsInt());
|
||||
#include "toolchain/semantics/semantics_builtin_kind.def"
|
||||
|
||||
Reference in New Issue
Block a user