mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-20 00:26:40 +00:00
Split `node.h` into separate files for ID types (`id.h`) and for typed nodes (`typed_nodes.h`). The per-node-kind data is now specified as part of declaring the typed nodes, and is removed from the node kinds x-macros, which now simply enumerate the node kinds.
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/sem_ir/node.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
auto Node::Print(llvm::raw_ostream& out) const -> void {
|
|
out << "{kind: " << kind_;
|
|
|
|
auto print_args = [&](auto info) {
|
|
using Info = decltype(info);
|
|
if constexpr (Info::NumArgs > 0) {
|
|
out << ", arg0: " << FromRaw<typename Info::template ArgType<0>>(arg0_);
|
|
}
|
|
if constexpr (Info::NumArgs > 1) {
|
|
out << ", arg1: " << FromRaw<typename Info::template ArgType<1>>(arg1_);
|
|
}
|
|
};
|
|
|
|
// clang warns on unhandled enum values; clang-tidy is incorrect here.
|
|
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
|
|
switch (kind_) {
|
|
#define CARBON_SEM_IR_NODE_KIND(Name) \
|
|
case Name::Kind: \
|
|
print_args(TypedNodeArgsInfo<Name>()); \
|
|
break;
|
|
#include "toolchain/sem_ir/node_kind.def"
|
|
}
|
|
if (type_id_.is_valid()) {
|
|
out << ", type: " << type_id_;
|
|
}
|
|
out << "}";
|
|
}
|
|
|
|
} // namespace Carbon::SemIR
|