Skip to content

Commit 1a13ea1

Browse files
committed
Change diagnostics flag to require an output file string
1 parent 0db44c1 commit 1a13ea1

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

source/cppfront.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ static cpp2::cmdline_processor::register_flag cmd_debug(
2020
[]{ flag_debug_output = true; }
2121
);
2222

23-
static auto flag_diagnostics_output = false;
23+
static auto flag_diagnostics = std::string();
2424
static cpp2::cmdline_processor::register_flag cmd_diagnostics(
2525
9,
26-
"diagnostics",
27-
"Emit compiler diagnostics output",
28-
[]{ flag_diagnostics_output = true; }
26+
"diagnostics outfile",
27+
"Emit compiler diagnostics output to outfile (or diagnostics.json if not specified)",
28+
nullptr,
29+
[](std::string const& output){ flag_diagnostics = output; }
2930
);
3031

3132
static auto flag_quiet = false;
@@ -179,8 +180,8 @@ auto main(
179180
}
180181

181182
// And, if requested, the diagnostics information
182-
if( flag_diagnostics_output) {
183-
c.diagnostics_print();
183+
if (flag_diagnostics != "") {
184+
c.diagnostics_print(flag_diagnostics);
184185
}
185186
}
186187

source/to_cpp1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7203,14 +7203,14 @@ class cppfront
72037203
//-----------------------------------------------------------------------
72047204
// diagnostics_print
72057205
//
7206-
auto diagnostics_print() const
7206+
auto diagnostics_print(std::string const& file) const
72077207
-> void
72087208
{
72097209
if (source_loaded)
72107210
{
7211-
auto out_file = std::ofstream{ sourcefile+"-diagnostics" };
7211+
auto outfile = std::ofstream{ file == "" ? "diagnostics.json" : file };
72127212
auto diagnostics = get_diagnostics(sema);
7213-
print_diagnostics(out_file, diagnostics);
7213+
print_diagnostics(outfile, diagnostics);
72147214
}
72157215
}
72167216

0 commit comments

Comments
 (0)