Modify SemanticsIR printing to produce stable output on builtin changes. (#2702)

These changes should make output more stable when builtins are added to semantics. By omitting them from nodes and printing nodes as "relative to the last builtin", I should be able to add and remove builtins without automatically affecting every test. Also by printing builtin nodes as `nodeNameOfBuiltin`, it's a little easier to understand what's going on (for me, at least).
This commit is contained in:
Jon Ross-Perkins
2023-03-22 10:24:03 -07:00
committed by GitHub
parent e89fb83e7e
commit 4ca2e81877
46 changed files with 604 additions and 813 deletions
+9 -2
View File
@@ -139,13 +139,20 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer,
}
args = args.drop_front();
auto parse_tree_preorder = false;
bool parse_tree_preorder = false;
if (dump_mode == DumpMode::ParseTree && !args.empty() &&
args.front() == "--preorder") {
args = args.drop_front();
parse_tree_preorder = true;
}
bool semantics_ir_include_builtins = false;
if (dump_mode == DumpMode::SemanticsIR && !args.empty() &&
args.front() == "--include_builtins") {
args = args.drop_front();
semantics_ir_include_builtins = true;
}
if (args.empty()) {
error_stream_ << "ERROR: No input file specified.\n";
return false;
@@ -204,7 +211,7 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer,
CARBON_VLOG() << "*** SemanticsIR::MakeFromParseTree done ***\n";
if (dump_mode == DumpMode::SemanticsIR) {
consumer.Flush();
output_stream_ << semantics_ir;
semantics_ir.Print(output_stream_, semantics_ir_include_builtins);
return !has_errors;
}
CARBON_VLOG() << "semantics_ir: " << semantics_ir;