aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-session-manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r--gcc/rust/rust-session-manager.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index bbc4d6e..9fd112c 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -53,6 +53,7 @@ const char *kLexDumpFile = "gccrs.lex.dump";
const char *kASTDumpFile = "gccrs.ast.dump";
const char *kASTExpandedDumpFile = "gccrs.ast-expanded.dump";
const char *kHIRDumpFile = "gccrs.hir.dump";
+const char *kHIRPrettyDumpFile = "gccrs.hir-pretty.dump";
const char *kHIRTypeResolutionDumpFile = "gccrs.type-resolution.dump";
const char *kTargetOptionsDumpFile = "gccrs.target-options.dump";
@@ -529,6 +530,10 @@ Session::enable_dump (std::string arg)
{
options.enable_dump_option (CompileOptions::HIR_DUMP);
}
+ else if (arg == "hir-pretty")
+ {
+ options.enable_dump_option (CompileOptions::HIR_DUMP_PRETTY);
+ }
else
{
rust_error_at (
@@ -735,6 +740,11 @@ Session::parse_file (const char *filename)
dump_hir (hir);
}
+ if (options.dump_option_enabled (CompileOptions::HIR_DUMP_PRETTY))
+ {
+ dump_hir_pretty (hir);
+ }
+
if (saw_errors ())
return;
@@ -1057,6 +1067,22 @@ Session::dump_hir (HIR::Crate &crate) const
return;
}
+ out << crate.as_string ();
+ out.close ();
+}
+
+void
+Session::dump_hir_pretty (HIR::Crate &crate) const
+{
+ std::ofstream out;
+ out.open (kHIRPrettyDumpFile);
+ if (out.fail ())
+ {
+ rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
+ kHIRPrettyDumpFile);
+ return;
+ }
+
HIR::Dump (out).go (crate);
out.close ();
}