mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
Add a convenience method for dumping the formatted SemIR file. (#4123)
This commit is contained in:
@@ -69,6 +69,7 @@ cc_library(
|
||||
"//toolchain/parse:tree_node_diagnostic_converter",
|
||||
"//toolchain/sem_ir:builtin_inst_kind",
|
||||
"//toolchain/sem_ir:file",
|
||||
"//toolchain/sem_ir:formatter",
|
||||
"//toolchain/sem_ir:ids",
|
||||
"//toolchain/sem_ir:inst",
|
||||
"//toolchain/sem_ir:inst_kind",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "toolchain/parse/node_kind.h"
|
||||
#include "toolchain/sem_ir/builtin_inst_kind.h"
|
||||
#include "toolchain/sem_ir/file.h"
|
||||
#include "toolchain/sem_ir/formatter.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/import_ir.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
@@ -1197,4 +1198,8 @@ auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void {
|
||||
args_type_info_stack_.PrintForStackDump(output);
|
||||
}
|
||||
|
||||
auto Context::DumpFormattedFile() const -> void {
|
||||
FormatFile(*tokens_, *parse_tree_, *sem_ir_, llvm::errs());
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
@@ -345,6 +345,9 @@ class Context {
|
||||
// Prints information for a stack dump.
|
||||
auto PrintForStackDump(llvm::raw_ostream& output) const -> void;
|
||||
|
||||
// Prints the the formatted sem_ir to stderr.
|
||||
LLVM_DUMP_METHOD auto DumpFormattedFile() const -> void;
|
||||
|
||||
// Get the Lex::TokenKind of a node for diagnostics.
|
||||
auto token_kind(Parse::NodeId node_id) -> Lex::TokenKind {
|
||||
return tokens().GetKind(parse_tree().node_token(node_id));
|
||||
|
||||
Reference in New Issue
Block a user