Add stringification for nodes. (#2704)

This is used to make error messages more readable. It'll be particularly important as more complex types are added.
This commit is contained in:
Jon Ross-Perkins
2023-03-22 14:55:53 -07:00
committed by GitHub
parent e0c90767be
commit c615d76196
12 changed files with 95 additions and 27 deletions
@@ -12,4 +12,12 @@ CARBON_DEFINE_ENUM_CLASS_NAMES(SemanticsBuiltinKind) = {
#include "toolchain/semantics/semantics_builtin_kind.def"
};
auto SemanticsBuiltinKind::label() -> llvm::StringRef {
static constexpr llvm::StringLiteral Labels[] = {
#define CARBON_SEMANTICS_BUILTIN_KIND(Name, Type, Label) Label,
#include "toolchain/semantics/semantics_builtin_kind.def"
};
return Labels[AsInt()];
}
} // namespace Carbon