mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:31:04 +01:00
Add a flag to dump the C++ AST (#5918)
Use it to dump the AST that includes a generated C++ thunk. Based on #5917. Also added printing of the full actual text when check fails to make debugging easier. Changed line replacement to allow removing complete lines. Part of #5514.
This commit is contained in:
@@ -208,6 +208,14 @@ Dump the full SemIR to stdout when built.
|
||||
)""",
|
||||
},
|
||||
[&](auto& arg_b) { arg_b.Set(&dump_sem_ir); });
|
||||
b.AddFlag(
|
||||
{
|
||||
.name = "dump-cpp-ast",
|
||||
.help = R"""(
|
||||
Dump the full C++ AST to stdout when built.
|
||||
)""",
|
||||
},
|
||||
[&](auto& arg_b) { arg_b.Set(&dump_cpp_ast); });
|
||||
|
||||
b.AddOneOfOption(
|
||||
{
|
||||
@@ -399,6 +407,11 @@ auto CompileSubcommand::ValidateOptions(
|
||||
PhaseToString(options_.phase));
|
||||
return false;
|
||||
}
|
||||
if (options_.dump_cpp_ast) {
|
||||
emitter.Emit(CompilePhaseFlagConflict, "C++ AST",
|
||||
PhaseToString(options_.phase));
|
||||
return false;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case Phase::Check:
|
||||
if (options_.dump_llvm_ir) {
|
||||
@@ -1015,11 +1028,15 @@ auto CompileSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
|
||||
options.gen_implicit_type_impls = options_.gen_implicit_type_impls;
|
||||
options.vlog_stream = driver_env.vlog_stream;
|
||||
options.fuzzing = driver_env.fuzzing;
|
||||
if (options.vlog_stream || options_.dump_sem_ir || options_.dump_raw_sem_ir) {
|
||||
if (options.vlog_stream || options_.dump_sem_ir || options_.dump_cpp_ast ||
|
||||
options_.dump_raw_sem_ir) {
|
||||
options.include_in_dumps = &cache.include_in_dumps();
|
||||
if (options_.dump_sem_ir) {
|
||||
options.dump_stream = driver_env.output_stream;
|
||||
}
|
||||
if (options_.dump_cpp_ast) {
|
||||
options.dump_cpp_ast_stream = driver_env.output_stream;
|
||||
}
|
||||
if (options.vlog_stream || options_.dump_sem_ir) {
|
||||
options.dump_sem_ir_ranges = options_.dump_sem_ir_ranges;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user