Add typed nodes to SemIR. (#3280)

Replace `SemIR::Node::GetAsFoo` and `SemIR::Node::Foo::Make` with
`SemIR::Foo` class that represents a particular kind of node, with named
fields.

Rename `SemIR::IntegerLiteral` and `SemIR::RealLiteral` to
`IntegerValue` / `RealValue` to better reflect their purpose and avoid a
name collision with the corresponding `SemIR` node kinds.

Remove `NodeKind::Invalid` and the `SemIR::Node` default constructor
entirely, as they were not used for anything.
This commit is contained in:
Richard Smith
2023-10-11 05:39:59 +00:00
committed by GitHub
parent 0e8e94d8bf
commit c7a9e29a89
41 changed files with 1445 additions and 954 deletions
+3 -3
View File
@@ -44,9 +44,9 @@ auto FunctionContext::LowerBlock(SemIR::NodeBlockId block_id) -> void {
// clang warns on unhandled enum values; clang-tidy is incorrect here.
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
switch (node.kind()) {
#define CARBON_SEMANTICS_NODE_KIND(Name) \
case SemIR::NodeKind::Name: \
Handle##Name(*this, node_id, node); \
#define CARBON_SEMANTICS_NODE_KIND(Name) \
case SemIR::NodeKind::Name: \
Handle##Name(*this, node_id, node.As<SemIR::Name>()); \
break;
#include "toolchain/sem_ir/node_kind.def"
}