No functional change intended.
gcc/ChangeLog:
* diagnostic-format-html.cc: Update #include for move of
diagnostic-output-file.h to diagnostics/output-file.h. Update for
move of diagnostic_output_file to diagnostics::output_file.
* diagnostic-format-html.h: Likewise.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-sarif.h: Likewise.
* diagnostic-output-spec.cc: Likewise.
* diagnostic-output-spec.h (along): Likewise.
* diagnostic-output-file.h: Move to...
* diagnostics/output-file.h: ...here, updating header guard.
(class diagnostic_output_file): Move to...
(class diagnostics::output_file): ...here.
* libgdiagnostics.cc (sarif_sink::sarif_sink): Update for
move of diagnostic_output_file to diagnostics::output_file.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
#include "diagnostic-format-html.h"
#include "diagnostic-format-text.h"
#include "diagnostic-format-sarif.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
#include "diagnostic-buffer.h"
#include "diagnostic-path.h"
#include "diagnostics/client-data-hooks.h"
html_file_output_format (diagnostic_context &context,
const line_maps *line_maps,
const html_generation_options &html_gen_opts,
- diagnostic_output_file output_file)
+ output_file output_file_)
: html_output_format (context, line_maps, html_gen_opts),
- m_output_file (std::move (output_file))
+ m_output_file (std::move (output_file_))
{
gcc_assert (m_output_file.get_open_file ());
gcc_assert (m_output_file.get_filename ());
}
private:
- diagnostic_output_file m_output_file;
+ output_file m_output_file;
};
/* Attempt to open BASE_FILE_NAME.html for writing.
- Return a non-null diagnostic_output_file,
- or return a null diagnostic_output_file and complain to CONTEXT
+ Return a non-null output_file,
+ or return a null output_file and complain to CONTEXT
using LINE_MAPS. */
-diagnostic_output_file
+output_file
diagnostic_output_format_open_html_file (diagnostic_context &context,
line_maps *line_maps,
const char *base_file_name)
context.emit_diagnostic_with_group
(DK_ERROR, richloc, nullptr, 0,
"unable to determine filename for HTML output");
- return diagnostic_output_file ();
+ return output_file ();
}
label_text filename = label_text::take (concat (base_file_name,
(DK_ERROR, richloc, nullptr, 0,
"unable to open %qs for HTML output: %m",
filename.get ());
- return diagnostic_output_file ();
+ return output_file ();
}
- return diagnostic_output_file (outf, true, std::move (filename));
+ return output_file (outf, true, std::move (filename));
}
std::unique_ptr<diagnostic_output_format>
make_html_sink (diagnostic_context &context,
const line_maps &line_maps,
const html_generation_options &html_gen_opts,
- diagnostic_output_file output_file)
+ output_file output_file_)
{
auto sink
= std::make_unique<html_file_output_format> (context,
&line_maps,
html_gen_opts,
- std::move (output_file));
+ std::move (output_file_));
sink->update_printer ();
return sink;
}
#define GCC_DIAGNOSTIC_FORMAT_HTML_H
#include "diagnostic-format.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
struct html_generation_options
{
bool m_show_state_diagrams_dot_src;
};
-extern diagnostic_output_file
+extern diagnostics::output_file
diagnostic_output_format_open_html_file (diagnostic_context &context,
line_maps *line_maps,
const char *base_file_name);
make_html_sink (diagnostic_context &context,
const line_maps &line_maps,
const html_generation_options &html_gen_opts,
- diagnostic_output_file output_file);
+ diagnostics::output_file output_file_);
extern void
print_path_as_html (xml::printer &xp,
{
m_builder.on_report_diagnostic (diagnostic, orig_diag_kind, m_buffer);
}
- void on_diagram (const diagnostics::diagram &d) final override
+ void on_diagram (const diagram &d) final override
{
m_builder.emit_diagram (d);
}
const line_maps *line_maps,
std::unique_ptr<sarif_serialization_format> serialization_format,
const sarif_generation_options &sarif_gen_opts,
- diagnostic_output_file output_file)
+ output_file output_file_)
: sarif_output_format (context, line_maps,
std::move (serialization_format), sarif_gen_opts),
- m_output_file (std::move (output_file))
+ m_output_file (std::move (output_file_))
{
gcc_assert (m_output_file.get_open_file ());
gcc_assert (m_output_file.get_filename ());
}
private:
- diagnostic_output_file m_output_file;
+ output_file m_output_file;
};
/* Print the start of an embedded link to PP, as per 3.11.6. */
}
/* Attempt to open "BASE_FILE_NAME""EXTENSION" for writing.
- Return a non-null diagnostic_output_file,
- or return a null diagnostic_output_file and complain to CONTEXT
+ Return a non-null output_file,
+ or return a null output_file and complain to CONTEXT
using LINE_MAPS. */
-diagnostic_output_file
-diagnostic_output_file::try_to_open (diagnostic_context &context,
- line_maps *line_maps,
- const char *base_file_name,
- const char *extension,
- bool is_binary)
+output_file
+output_file::try_to_open (diagnostic_context &context,
+ line_maps *line_maps,
+ const char *base_file_name,
+ const char *extension,
+ bool is_binary)
{
gcc_assert (extension);
gcc_assert (extension[0] == '.');
context.emit_diagnostic_with_group
(DK_ERROR, richloc, nullptr, 0,
"unable to determine filename for SARIF output");
- return diagnostic_output_file ();
+ return output_file ();
}
label_text filename = label_text::take (concat (base_file_name,
(DK_ERROR, richloc, nullptr, 0,
"unable to open %qs for diagnostic output: %m",
filename.get ());
- return diagnostic_output_file ();
+ return output_file ();
}
- return diagnostic_output_file (outf, true, std::move (filename));
+ return output_file (outf, true, std::move (filename));
}
/* Attempt to open BASE_FILE_NAME.sarif for writing JSON.
- Return a non-null diagnostic_output_file,
- or return a null diagnostic_output_file and complain to CONTEXT
+ Return a non-null output_file,
+ or return a null output_file and complain to CONTEXT
using LINE_MAPS. */
-diagnostic_output_file
+output_file
diagnostic_output_format_open_sarif_file (diagnostic_context &context,
line_maps *line_maps,
const char *base_file_name,
break;
}
- return diagnostic_output_file::try_to_open (context,
- line_maps,
- base_file_name,
- suffix,
- is_binary);
+ return output_file::try_to_open (context,
+ line_maps,
+ base_file_name,
+ suffix,
+ is_binary);
}
/* Populate CONTEXT in preparation for SARIF output to a file named
{
gcc_assert (line_maps);
- diagnostic_output_file output_file
+ output_file output_file_
= diagnostic_output_format_open_sarif_file (context,
line_maps,
base_file_name,
line_maps,
std::move (serialization),
sarif_gen_opts,
- std::move (output_file)));
+ std::move (output_file_)));
}
/* Populate CONTEXT in preparation for SARIF output to STREAM.
const line_maps &line_maps,
std::unique_ptr<sarif_serialization_format> serialization,
const sarif_generation_options &sarif_gen_opts,
- diagnostic_output_file output_file)
+ output_file output_file_)
{
auto sink
= std::make_unique<sarif_file_output_format> (context,
&line_maps,
std::move (serialization),
sarif_gen_opts,
- std::move (output_file));
+ std::move (output_file_));
sink->update_printer ();
return sink;
}
#include "json.h"
#include "diagnostic-format.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
#include "diagnostics/logical-locations.h"
/* Enum for choosing what format to serializing the generated SARIF into. */
num_values
};
-extern diagnostic_output_file
+extern diagnostics::output_file
diagnostic_output_format_open_sarif_file (diagnostic_context &context,
line_maps *line_maps,
const char *base_file_name,
const line_maps &line_maps,
std::unique_ptr<sarif_serialization_format> serialization_format,
const sarif_generation_options &sarif_gen_opts,
- diagnostic_output_file output_file);
+ diagnostics::output_file output_file_);
class sarif_builder;
class sarif_location_manager;
get_option_name (), scheme_name.c_str (), key.c_str (), metavar);
}
-diagnostic_output_file
+diagnostics::output_file
context::open_output_file (label_text &&filename) const
{
FILE *outf = fopen (filename.get (), "w");
if (!outf)
{
report_error ("unable to open %qs: %m", filename.get ());
- return diagnostic_output_file (nullptr, false, std::move (filename));
+ return diagnostics::output_file (nullptr, false, std::move (filename));
}
- return diagnostic_output_file (outf, true, std::move (filename));
+ return diagnostics::output_file (outf, true, std::move (filename));
}
static std::unique_ptr<scheme_name_and_params>
return nullptr;
}
- diagnostic_output_file output_file;
+ diagnostics::output_file output_file;
if (filename.get ())
output_file = ctxt.open_output_file (std::move (filename));
else
return nullptr;
}
- diagnostic_output_file output_file;
+ diagnostics::output_file output_file;
if (filename.get ())
output_file = ctxt.open_output_file (std::move (filename));
else
#define GCC_DIAGNOSTIC_OUTPUT_SPEC_H
#include "diagnostic-format.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
namespace diagnostics_output_spec {
const std::string &scheme_name,
const char *metavar) const;
- diagnostic_output_file
+ diagnostics::output_file
open_output_file (label_text &&filename) const;
const char *
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#ifndef GCC_DIAGNOSTIC_OUTPUT_FILE_H
-#define GCC_DIAGNOSTIC_OUTPUT_FILE_H
+#ifndef GCC_DIAGNOSTICS_OUTPUT_FILE_H
+#define GCC_DIAGNOSTICS_OUTPUT_FILE_H
+
+namespace diagnostics {
/* RAII class for wrapping a FILE * that could be borrowed or owned,
along with the underlying filename. */
-class diagnostic_output_file
+class output_file
{
public:
- diagnostic_output_file ()
+ output_file ()
: m_outf (nullptr),
m_owned (false),
m_filename ()
{
}
- diagnostic_output_file (FILE *outf, bool owned, label_text filename)
+ output_file (FILE *outf, bool owned, label_text filename)
: m_outf (outf),
m_owned (owned),
m_filename (std::move (filename))
if (m_owned)
gcc_assert (m_outf);
}
- ~diagnostic_output_file ()
+ ~output_file ()
{
if (m_owned)
{
fclose (m_outf);
}
}
- diagnostic_output_file (const diagnostic_output_file &other) = delete;
- diagnostic_output_file (diagnostic_output_file &&other)
+ output_file (const output_file &other) = delete;
+ output_file (output_file &&other)
: m_outf (other.m_outf),
m_owned (other.m_owned),
m_filename (std::move (other.m_filename))
if (m_owned)
gcc_assert (m_outf);
}
- diagnostic_output_file &
- operator= (const diagnostic_output_file &other) = delete;
- diagnostic_output_file &
- operator= (diagnostic_output_file &&other)
+ output_file &
+ operator= (const output_file &other) = delete;
+ output_file &
+ operator= (output_file &&other)
{
if (m_owned)
{
FILE *get_open_file () const { return m_outf; }
const char *get_filename () const { return m_filename.get (); }
- static diagnostic_output_file
+ static output_file
try_to_open (diagnostic_context &context,
line_maps *line_maps,
const char *base_file_name,
label_text m_filename;
};
-#endif /* ! GCC_DIAGNOSTIC_OUTPUT_FILE_H */
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_OUTPUT_FILE_H */
const sarif_generation_options &sarif_gen_opts)
: sink (mgr)
{
- diagnostic_output_file output_file (dst_stream, false,
- label_text::borrow ("sarif_sink"));
+ diagnostics::output_file output_file (dst_stream, false,
+ label_text::borrow ("sarif_sink"));
auto serialization = std::make_unique<sarif_serialization_format_json> (true);
auto inner_sink = make_sarif_sink (mgr.get_dc (),
*mgr.get_line_table (),