mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user