Add a feature to explicitly include a file's SemIR (#5961)

Trying to figure out an easy way to debug semir in the prelude, #5703
removed an option to set `--exclude-dump-file-prefix` to empty. But,
this is probably an improvement over that flow... With this change, it's
possible to add `//@dump-sem-ir-file` to a specific prelude file, and
its full IR will be printed. Additionally, it becomes an option with the
default `--dump-sem-ir-ranges=only` to add `//@dump-sem-ir-file` and get
the full file's IR.
This commit is contained in:
Jon Ross-Perkins
2025-08-15 18:53:43 +00:00
committed by GitHub
parent 3f9fc633fe
commit 8d08e774fc
11 changed files with 484 additions and 10 deletions
+3 -3
View File
@@ -340,17 +340,17 @@ static auto MaybeDumpFormattedSemIR(
return;
}
bool has_ranges = sem_ir.parse_tree().tokens().has_dump_sem_ir_ranges();
const auto& tokens = sem_ir.parse_tree().tokens();
if (options.dump_sem_ir_ranges ==
CheckParseTreesOptions::DumpSemIRRanges::Only &&
!has_ranges) {
!tokens.has_dump_sem_ir_ranges() && !tokens.has_include_in_dumps()) {
return;
}
bool use_dump_sem_ir_ranges =
options.dump_sem_ir_ranges !=
CheckParseTreesOptions::DumpSemIRRanges::Ignore &&
has_ranges;
tokens.has_dump_sem_ir_ranges();
SemIR::Formatter formatter(&sem_ir, tree_and_subtrees_getter,
options.include_in_dumps, use_dump_sem_ir_ranges);
formatter.Format();