aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2025-07-25 15:13:36 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2025-07-25 15:13:36 -0400
commitc9c996d3f0373e912b43da5a601c9677a2d9b3b4 (patch)
treee425940555f5f586117b161106aa74210c39e874
parentaccd28c1aa02439901c05a9a41d9a3611978d809 (diff)
downloadgcc-c9c996d3f0373e912b43da5a601c9677a2d9b3b4.zip
gcc-c9c996d3f0373e912b43da5a601c9677a2d9b3b4.tar.gz
gcc-c9c996d3f0373e912b43da5a601c9677a2d9b3b4.tar.bz2
diagnostics: move diagnostics_output_spec to diagnostics::output_spec
No functional change intended. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Replace diagnostic-output-spec.o with diagnostics/output-spec.o. * diagnostic-output-spec.cc: Move to... * diagnostics/output-spec.cc: ...here. Update #include for move of diagnostic-output-spec.h to diagnostics/output-spec.h. (namespace::diagnostics_output_spec): Replace with... (namespace diagnostics::output_spec): ...this, removing redundant prefixes. (diagnostics_output_spec::gcc_spec_context): Replace with... (diagnostics::output_spec::dc_spec_context): ...this. (diagnostic_output_spec_cc_tests): Rename to... (diagnostics_output_spec_cc_tests): ...this. * diagnostic-output-spec.h: Move to... * diagnostics/output-spec.h: ...here and update inclusion guard. (namespace::diagnostics_output_spec): Replace with... (namespace diagnostics::output_spec): ...this, removing redundant prefixes. (diagnostics_output_spec::gcc_spec_context): Replace with... (diagnostics::output_spec::dc_spec_context): ...this. * libgdiagnostics.cc: Update #include for move of diagnostic-output-spec.h to diagnostics/output-spec.h. * opts-diagnostic.cc: Likewise. Update for namespace and name changes. * selftest-run-tests.cc (selftest::run_tests): Update for renaming of diagnostic_output_spec_cc_tests to diagnostics_output_spec_cc_tests. * selftest.h (diagnostic_output_spec_cc_tests): Rename decl to... (diagnostics_output_spec_cc_tests): ...this. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/diagnostics/output-spec.cc (renamed from gcc/diagnostic-output-spec.cc)56
-rw-r--r--gcc/diagnostics/output-spec.h (renamed from gcc/diagnostic-output-spec.h)26
-rw-r--r--gcc/libgdiagnostics.cc4
-rw-r--r--gcc/opts-diagnostic.cc16
-rw-r--r--gcc/selftest-run-tests.cc2
-rw-r--r--gcc/selftest.h2
7 files changed, 56 insertions, 52 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 7610deb..f263f90 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1858,12 +1858,12 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
diagnostic-format-text.o \
diagnostic-global-context.o \
diagnostic-macro-unwinding.o \
- diagnostic-output-spec.o \
diagnostic-path.o \
diagnostic-path-output.o \
diagnostic-show-locus.o \
diagnostics/digraphs.o \
diagnostics/edit-context.o \
+ diagnostics/output-spec.o \
diagnostics/state-graphs.o \
diagnostics/state-graphs-to-dot.o \
diagnostics/selftest-logical-locations.o \
diff --git a/gcc/diagnostic-output-spec.cc b/gcc/diagnostics/output-spec.cc
index b028482c..35d593e 100644
--- a/gcc/diagnostic-output-spec.cc
+++ b/gcc/diagnostics/output-spec.cc
@@ -40,12 +40,13 @@ along with GCC; see the file COPYING3. If not see
#include "selftest.h"
#include "selftest-diagnostic.h"
#include "pretty-print-markup.h"
-#include "diagnostic-output-spec.h"
+#include "diagnostics/output-spec.h"
/* A namespace for handling the DSL of the arguments of
-fdiagnostics-add-output= and -fdiagnostics-set-output=. */
-namespace diagnostics_output_spec {
+namespace diagnostics {
+namespace output_spec {
/* Decls. */
@@ -241,16 +242,16 @@ context::report_missing_key (const char *unparsed_arg,
get_option_name (), scheme_name.c_str (), key.c_str (), metavar);
}
-diagnostics::output_file
+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 diagnostics::output_file (nullptr, false, std::move (filename));
+ return output_file (nullptr, false, std::move (filename));
}
- return diagnostics::output_file (outf, true, std::move (filename));
+ return output_file (outf, true, std::move (filename));
}
static std::unique_ptr<scheme_name_and_params>
@@ -307,11 +308,11 @@ std::unique_ptr<diagnostic_output_format>
context::parse_and_make_sink (const char *unparsed_arg,
diagnostic_context &dc)
{
- auto parsed_arg = diagnostics_output_spec::parse (*this, unparsed_arg);
+ auto parsed_arg = parse (*this, unparsed_arg);
if (!parsed_arg)
return nullptr;
- diagnostics_output_spec::output_factory factory;
+ output_factory factory;
return factory.make_sink (*this, dc, unparsed_arg, *parsed_arg);
}
@@ -488,9 +489,9 @@ sarif_scheme_handler::make_sink (const context &ctxt,
return nullptr;
}
- diagnostics::output_file output_file;
+ output_file output_file_;
if (filename.get ())
- output_file = ctxt.open_output_file (std::move (filename));
+ output_file_ = ctxt.open_output_file (std::move (filename));
else
// Default filename
{
@@ -503,14 +504,14 @@ sarif_scheme_handler::make_sink (const context &ctxt,
"FILENAME");
return nullptr;
}
- output_file
+ output_file_
= diagnostic_output_format_open_sarif_file
(dc,
ctxt.get_affected_location_mgr (),
basename,
serialization_kind);
}
- if (!output_file)
+ if (!output_file_)
return nullptr;
auto sarif_gen_opts = make_sarif_gen_opts (version, state_graph);
@@ -521,7 +522,7 @@ sarif_scheme_handler::make_sink (const context &ctxt,
*ctxt.get_affected_location_mgr (),
std::move (serialization_obj),
sarif_gen_opts,
- std::move (output_file));
+ std::move (output_file_));
return sink;
}
@@ -621,9 +622,9 @@ html_scheme_handler::make_sink (const context &ctxt,
return nullptr;
}
- diagnostics::output_file output_file;
+ output_file output_file_;
if (filename.get ())
- output_file = ctxt.open_output_file (std::move (filename));
+ output_file_ = ctxt.open_output_file (std::move (filename));
else
// Default filename
{
@@ -636,13 +637,13 @@ html_scheme_handler::make_sink (const context &ctxt,
"FILENAME");
return nullptr;
}
- output_file
+ output_file_
= diagnostic_output_format_open_html_file
(dc,
ctxt.get_affected_location_mgr (),
basename);
}
- if (!output_file)
+ if (!output_file_)
return nullptr;
html_generation_options html_gen_opts;
@@ -655,11 +656,12 @@ html_scheme_handler::make_sink (const context &ctxt,
auto sink = make_html_sink (dc,
*ctxt.get_affected_location_mgr (),
html_gen_opts,
- std::move (output_file));
+ std::move (output_file_));
return sink;
}
-} // namespace diagnostics_output_spec
+} // namespace output_spec
+} // namespace diagnostics
#if CHECKING_P
@@ -688,18 +690,18 @@ private:
struct parser_test
{
- class test_spec_context : public diagnostics_output_spec::gcc_spec_context
+ class test_spec_context : public diagnostics::output_spec::dc_spec_context
{
public:
test_spec_context (diagnostic_context &dc,
line_maps *location_mgr,
location_t loc,
const char *option_name)
- : gcc_spec_context (dc,
- location_mgr,
- location_mgr,
- loc,
- option_name)
+ : dc_spec_context (dc,
+ location_mgr,
+ location_mgr,
+ loc,
+ option_name)
{
}
@@ -718,10 +720,10 @@ struct parser_test
pp_buffer (m_fmt.get_printer ())->m_flush_p = false;
}
- std::unique_ptr<diagnostics_output_spec::scheme_name_and_params>
+ std::unique_ptr<diagnostics::output_spec::scheme_name_and_params>
parse (const char *unparsed_arg)
{
- return diagnostics_output_spec::parse (m_ctxt, unparsed_arg);
+ return diagnostics::output_spec::parse (m_ctxt, unparsed_arg);
}
bool execution_failed_p () const
@@ -838,7 +840,7 @@ test_output_arg_parsing ()
/* Run all of the selftests within this file. */
void
-diagnostic_output_spec_cc_tests ()
+diagnostics_output_spec_cc_tests ()
{
test_output_arg_parsing ();
}
diff --git a/gcc/diagnostic-output-spec.h b/gcc/diagnostics/output-spec.h
index 1ffe4a3..49a84b2 100644
--- a/gcc/diagnostic-output-spec.h
+++ b/gcc/diagnostics/output-spec.h
@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#ifndef GCC_DIAGNOSTIC_OUTPUT_SPEC_H
-#define GCC_DIAGNOSTIC_OUTPUT_SPEC_H
+#ifndef GCC_DIAGNOSTICS_OUTPUT_SPEC_H
+#define GCC_DIAGNOSTICS_OUTPUT_SPEC_H
#include "diagnostic-format.h"
#include "diagnostics/output-file.h"
-namespace diagnostics_output_spec {
+namespace diagnostics {
+namespace output_spec {
/* An abstract base class for handling the DSL of -fdiagnostics-add-output=
and -fdiagnostics-set-output=. */
@@ -52,7 +53,7 @@ class context
const std::string &scheme_name,
const char *metavar) const;
- diagnostics::output_file
+ output_file
open_output_file (label_text &&filename) const;
const char *
@@ -83,14 +84,14 @@ protected:
/* A subclass that implements reporting errors via a diagnostic_context. */
-struct gcc_spec_context : public diagnostics_output_spec::context
+struct dc_spec_context : public output_spec::context
{
public:
- gcc_spec_context (diagnostic_context &dc,
- line_maps *affected_location_mgr,
- line_maps *control_location_mgr,
- location_t loc,
- const char *option_name)
+ dc_spec_context (diagnostic_context &dc,
+ line_maps *affected_location_mgr,
+ line_maps *control_location_mgr,
+ location_t loc,
+ const char *option_name)
: context (option_name, affected_location_mgr),
m_dc (dc),
m_control_location_mgr (control_location_mgr),
@@ -111,6 +112,7 @@ public:
location_t m_loc;
};
-} // namespace diagnostics_output_spec
+} // namespace output_spec
+} // namespace diagnostics
-#endif
+#endif // #ifndef GCC_DIAGNOSTICS_OUTPUT_SPEC_H
diff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc
index 692fca7..b1bd014 100644
--- a/gcc/libgdiagnostics.cc
+++ b/gcc/libgdiagnostics.cc
@@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/client-data-hooks.h"
#include "diagnostic-format-sarif.h"
#include "diagnostic-format-text.h"
-#include "diagnostic-output-spec.h"
+#include "diagnostics/output-spec.h"
#include "diagnostics/digraphs.h"
#include "diagnostics/state-graphs.h"
#include "diagnostics/logical-locations.h"
@@ -2419,7 +2419,7 @@ diagnostic_logical_location_get_decorated_name (const diagnostic_logical_locatio
namespace {
-struct spec_context : public diagnostics_output_spec::context
+struct spec_context : public diagnostics::output_spec::context
{
public:
spec_context (const char *option_name,
diff --git a/gcc/opts-diagnostic.cc b/gcc/opts-diagnostic.cc
index d2c3a93..9c08f8b 100644
--- a/gcc/opts-diagnostic.cc
+++ b/gcc/opts-diagnostic.cc
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
/* This file implements the options -fdiagnostics-add-output=,
-fdiagnostics-set-output=. Most of the work is done
- by diagnostic-output-spec.cc so it can be shared by libgdiagnostics. */
+ by diagnostics/output-spec.cc so it can be shared by libgdiagnostics. */
#include "config.h"
#define INCLUDE_ARRAY
@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "version.h"
#include "intl.h"
#include "diagnostic.h"
-#include "diagnostic-output-spec.h"
+#include "diagnostics/output-spec.h"
#include "opts.h"
#include "options.h"
@@ -39,7 +39,7 @@ along with GCC; see the file COPYING3. If not see
namespace {
-struct opt_spec_context : public diagnostics_output_spec::gcc_spec_context
+struct opt_spec_context : public diagnostics::output_spec::dc_spec_context
{
public:
opt_spec_context (const gcc_options &opts,
@@ -47,11 +47,11 @@ public:
line_maps *location_mgr,
location_t loc,
const char *option_name)
- : gcc_spec_context (dc,
- location_mgr,
- location_mgr,
- loc,
- option_name),
+ : dc_spec_context (dc,
+ location_mgr,
+ location_mgr,
+ loc,
+ option_name),
m_opts (opts)
{}
diff --git a/gcc/selftest-run-tests.cc b/gcc/selftest-run-tests.cc
index 734959a..81434cd 100644
--- a/gcc/selftest-run-tests.cc
+++ b/gcc/selftest-run-tests.cc
@@ -103,7 +103,7 @@ selftest::run_tests ()
diagnostic_format_html_cc_tests ();
diagnostic_format_sarif_cc_tests ();
diagnostics_digraphs_cc_tests ();
- diagnostic_output_spec_cc_tests ();
+ diagnostics_output_spec_cc_tests ();
diagnostics_state_graphs_cc_tests ();
edit_context_cc_tests ();
fold_const_cc_tests ();
diff --git a/gcc/selftest.h b/gcc/selftest.h
index f66f472..b125a23 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -224,10 +224,10 @@ extern void dbgcnt_cc_tests ();
extern void diagnostic_color_cc_tests ();
extern void diagnostic_format_html_cc_tests ();
extern void diagnostic_format_sarif_cc_tests ();
-extern void diagnostic_output_spec_cc_tests ();
extern void diagnostic_path_output_cc_tests ();
extern void diagnostic_show_locus_cc_tests ();
extern void diagnostics_digraphs_cc_tests ();
+extern void diagnostics_output_spec_cc_tests ();
extern void diagnostics_selftest_logical_locations_cc_tests ();
extern void diagnostics_state_graphs_cc_tests ();
extern void digraph_cc_tests ();