mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Adding ValueStore printing and --dump-shared-values (#3320)
This replaces the printing that was removed from SemIR's raw dump. It's separate because (for example) lexing generates shared values, and so reviewing them is not specific to any particular phase.
This commit is contained in:
@@ -180,6 +180,14 @@ and displaying them in source order.
|
||||
},
|
||||
[&](auto& arg_b) { arg_b.Set(&stream_errors); });
|
||||
|
||||
b.AddFlag(
|
||||
{
|
||||
.name = "dump-shared-values",
|
||||
.help = R"""(
|
||||
Dumps shared values. These aren't owned by any particular file or phase.
|
||||
)""",
|
||||
},
|
||||
[&](auto& arg_b) { arg_b.Set(&dump_shared_values); });
|
||||
b.AddFlag(
|
||||
{
|
||||
.name = "dump-tokens",
|
||||
@@ -257,6 +265,7 @@ Dump the generated assembly to stdout after codegen.
|
||||
|
||||
bool asm_output = false;
|
||||
bool force_obj_output = false;
|
||||
bool dump_shared_values = false;
|
||||
bool dump_tokens = false;
|
||||
bool dump_parse_tree = false;
|
||||
bool dump_raw_sem_ir = false;
|
||||
@@ -599,7 +608,6 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
SharedValueStores value_stores;
|
||||
llvm::SmallVector<std::unique_ptr<CompilationUnit>> units;
|
||||
auto flush = llvm::make_scope_exit([&]() {
|
||||
// The diagnostics consumer must be flushed before compilation artifacts are
|
||||
@@ -609,6 +617,12 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
|
||||
unit->Flush();
|
||||
}
|
||||
});
|
||||
SharedValueStores value_stores;
|
||||
auto dump_shared_values = llvm::make_scope_exit([&]() {
|
||||
if (options.dump_shared_values) {
|
||||
output_stream_ << value_stores;
|
||||
}
|
||||
});
|
||||
for (const auto& input_file_name : options.input_file_names) {
|
||||
units.push_back(std::make_unique<CompilationUnit>(
|
||||
this, &value_stores, options, input_file_name));
|
||||
|
||||
Reference in New Issue
Block a user