From 6d9152659f4f6a1bc61e8868bff700630612076e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 25 Jul 2025 15:13:34 -0400 Subject: [PATCH] diagnostics: introduce a "gcc/diagnostics" subdirectory The "gcc" subdirectory of our source tree currently contains a total of almost 1000 .cc and .h files, enough to hit rate-limiting in some git web UIs, and obscuring the logical relationships between subsystems. In r16-2211-ga5d9debedd2f46 I started introducing a "namespace diagnostics" so it makes sense to move such code into a new "gcc/diagnostics" subdirectory. My intent is for the "diagnostics" namespace/directory to contain shared parts of the diagnostics code that are in libcommon, in particular which don't have knowledge of trees. This patch begins moving of the existing code within "namespace diagnostics" into a new "gcc/diagnostics" subdirectory. No functional change intended. renamed: gcc/diagnostic-digraphs.cc -> gcc/diagnostics/digraphs.cc renamed: gcc/diagnostic-digraphs.h -> gcc/diagnostics/digraphs.h renamed: gcc/diagnostic-state-to-dot.cc -> gcc/diagnostics/state-graphs-to-dot.cc renamed: gcc/diagnostic-state-graphs.cc -> gcc/diagnostics/state-graphs.cc renamed: gcc/diagnostic-state-graphs.h -> gcc/diagnostics/state-graphs.h contrib/ChangeLog: * gcc.doxy (INPUT): Add gcc/diagnostics subdir. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Rename diagnostic-digraphs.o to diagnostics/digraphs.o. Rename diagnostic-state-graphs.o to diagnostics/state-graphs.o. Rename diagnostic-state-to-dot.o to diagnostics/state-graphs-to-dot.o. (PLUGIN_HEADERS): Add $(srcdir)/diagnostics/*.h. (install-plugin:): Likewise. * configure: Regenerate. * configure.ac (gccdepdir): Add "diagnostics" to directories. * diagnostic-format-html.cc: Update #includes for move of "diagnostic-digraphs.h" to "diagnostics/digraphs.h" and of move of "diagnostic-state-graphs.h" to "diagnostics/state-graphs.h". * diagnostic-format-sarif.cc: Likewise. * diagnostic-path.cc: Likewise for state-graphs.h * diagnostic-digraphs.cc: Move... * diagnostics/digraphs.cc: ...to here. Update #include for renaming of digraphs.h. (selftest::diagnostic_digraphs_cc_tests): Rename to... (selftest::diagnostics_digraphs_cc_tests): ...this. * diagnostic-digraphs.h: Move... * diagnostics/digraphs.h: ...to here, updating header guard. * diagnostic-state-to-dot.cc: Move... * diagnostics/state-graphs-to-dot.cc: ...to here. Update #include of state-graphs.h. * diagnostic-state-graphs.cc: Move... * diagnostics/state-graphs.cc: ...to here. Update #include of state-graphs.h. (selftest::diagnostic_state_graphs_cc_tests): Rename... (selftest::diagnostics_state_graphs_cc_tests): ...to this. * diagnostic-state-graphs.h: Move... * diagnostics/state-graphs.h: ...to here, updating header guard. * libgdiagnostics.cc: Update #includes for move of "diagnostic-digraphs.h" to "diagnostics/digraphs.h" and of move of "diagnostic-state-graphs.h" to "diagnostics/state-graphs.h". * selftest-run-tests.cc (selftest::run_tests): Update for function renamings that reflect file renamings. * selftest.h (selftest::diagnostic_digraphs_cc_tests): Rename to... (selftest::diagnostics_digraphs_cc_tests): ...this. (selftest::diagnostic_state_graphs_cc_tests): Rename... (selftest::diagnostics_state_graphs_cc_tests): ...to this. gcc/analyzer/ChangeLog: * ana-state-to-diagnostic-state.cc: Update #include for move of "diagnostic-state-graphs.h" to "diagnostics/state-graphs.h". * ana-state-to-diagnostic-state.h: Likewise. * checker-event.cc: Likewise. * checker-event.h: Update #include for move of "diagnostic-digraphs.h" to "diagnostics/digraphs.h". * program-state.cc: : Update #include for move of "diagnostic-state-graphs.h" to "diagnostics/state-graphs.h". gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: Update #include for move of "diagnostic-digraphs.h" to "diagnostics/digraphs.h". Signed-off-by: David Malcolm --- contrib/gcc.doxy | 2 +- gcc/Makefile.in | 9 +++++---- gcc/analyzer/ana-state-to-diagnostic-state.cc | 2 +- gcc/analyzer/ana-state-to-diagnostic-state.h | 2 +- gcc/analyzer/checker-event.cc | 2 +- gcc/analyzer/checker-event.h | 2 +- gcc/analyzer/program-state.cc | 2 +- gcc/configure | 2 +- gcc/configure.ac | 2 +- gcc/diagnostic-format-html.cc | 4 ++-- gcc/diagnostic-format-sarif.cc | 4 ++-- gcc/diagnostic-path.cc | 2 +- gcc/{diagnostic-digraphs.cc => diagnostics/digraphs.cc} | 4 ++-- gcc/{diagnostic-digraphs.h => diagnostics/digraphs.h} | 6 +++--- .../state-graphs-to-dot.cc} | 2 +- .../state-graphs.cc} | 4 ++-- .../state-graphs.h} | 8 ++++---- gcc/libgdiagnostics.cc | 4 ++-- gcc/selftest-run-tests.cc | 4 ++-- gcc/selftest.h | 4 ++-- .../gcc.dg/plugin/diagnostic_plugin_test_graphs.cc | 2 +- 21 files changed, 37 insertions(+), 36 deletions(-) rename gcc/{diagnostic-digraphs.cc => diagnostics/digraphs.cc} (99%) rename gcc/{diagnostic-digraphs.h => diagnostics/digraphs.h} (98%) rename gcc/{diagnostic-state-to-dot.cc => diagnostics/state-graphs-to-dot.cc} (99%) rename gcc/{diagnostic-state-graphs.cc => diagnostics/state-graphs.cc} (98%) rename gcc/{diagnostic-state-graphs.h => diagnostics/state-graphs.h} (96%) diff --git a/contrib/gcc.doxy b/contrib/gcc.doxy index cf3281fe0f4..15952046f25 100644 --- a/contrib/gcc.doxy +++ b/contrib/gcc.doxy @@ -478,7 +478,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = gcc gcc/analyzer gcc/text-art +INPUT = gcc gcc/analyzer gcc/diagnostics gcc/text-art # This tag can be used to specify the character encoding of the source files that # doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 05dfa0871be..7391a18a351 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1857,14 +1857,14 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \ diagnostic-format-sarif.o \ diagnostic-format-text.o \ diagnostic-global-context.o \ - diagnostic-digraphs.o \ diagnostic-macro-unwinding.o \ diagnostic-output-spec.o \ diagnostic-path.o \ diagnostic-path-output.o \ diagnostic-show-locus.o \ - diagnostic-state-graphs.o \ - diagnostic-state-to-dot.o \ + diagnostics/digraphs.o \ + diagnostics/state-graphs.o \ + diagnostics/state-graphs-to-dot.o \ edit-context.o \ graphviz.o pex.o \ pretty-print.o intl.o \ @@ -4082,7 +4082,7 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ hash-set.h dominance.h cfg.h cfgrtl.h cfganal.h cfgbuild.h cfgcleanup.h \ lcm.h cfgloopmanip.h file-prefix-map.h builtins.def $(INSN_ATTR_H) \ pass-instances.def params.list $(srcdir)/../include/gomp-constants.h \ - $(EXPR_H) $(srcdir)/analyzer/*.h + $(EXPR_H) $(srcdir)/analyzer/*.h $(srcdir)/diagnostics/*.h # generate the 'build fragment' b-header-vars s-header-vars: Makefile @@ -4120,6 +4120,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype fi; \ case $$path in \ "$(srcdir)"/analyzer/* \ + | "$(srcdir)"/diagnostics/* \ | "$(srcdir)"/config/* | "$(srcdir)"/common/config/* \ | "$(srcdir)"/c-family/* | "$(srcdir)"/*.def ) \ base=`echo "$$path" | sed -e "s|$$srcdirstrip/||"`;; \ diff --git a/gcc/analyzer/ana-state-to-diagnostic-state.cc b/gcc/analyzer/ana-state-to-diagnostic-state.cc index 27012595c8a..2604e09883d 100644 --- a/gcc/analyzer/ana-state-to-diagnostic-state.cc +++ b/gcc/analyzer/ana-state-to-diagnostic-state.cc @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see #define INCLUDE_SET #include "analyzer/common.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" #include "diagnostic-format-sarif.h" #include "analyzer/region-model.h" diff --git a/gcc/analyzer/ana-state-to-diagnostic-state.h b/gcc/analyzer/ana-state-to-diagnostic-state.h index 186e19d2f51..3a5ccc1b430 100644 --- a/gcc/analyzer/ana-state-to-diagnostic-state.h +++ b/gcc/analyzer/ana-state-to-diagnostic-state.h @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_ANALYZER_ANA_STATE_TO_DIAGNOSTIC_STATE_H #define GCC_ANALYZER_ANA_STATE_TO_DIAGNOSTIC_STATE_H -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" #include "tree-logical-location.h" namespace ana { diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc index 8cc5ac2b1da..665bb0d509e 100644 --- a/gcc/analyzer/checker-event.cc +++ b/gcc/analyzer/checker-event.cc @@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "inlining-iterator.h" #include "tree-logical-location.h" #include "diagnostic-format-sarif.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" #include "analyzer/analyzer-logging.h" #include "analyzer/sm.h" diff --git a/gcc/analyzer/checker-event.h b/gcc/analyzer/checker-event.h index cf24e777e29..d3b64e33a19 100644 --- a/gcc/analyzer/checker-event.h +++ b/gcc/analyzer/checker-event.h @@ -24,7 +24,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-logical-location.h" #include "analyzer/program-state.h" #include "analyzer/event-loc-info.h" -#include "diagnostic-digraphs.h" +#include "diagnostics/digraphs.h" namespace ana { diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 85cbe759ee9..ea64bdd9ffb 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "digraph.h" #include "diagnostic-event-id.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" #include "graphviz.h" #include "text-art/tree-widget.h" diff --git a/gcc/configure b/gcc/configure index 7537da20291..bacdd29da69 100755 --- a/gcc/configure +++ b/gcc/configure @@ -36498,7 +36498,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;; "gccdepdir":C) ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR - for lang in $subdirs c-family common analyzer text-art rtl-ssa sym-exec + for lang in $subdirs c-family common analyzer diagnostics text-art rtl-ssa sym-exec do ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR done ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index 24e0aa69c0f..2c43b38178c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1397,7 +1397,7 @@ AC_CHECK_HEADERS(ext/hash_map) ZW_CREATE_DEPDIR AC_CONFIG_COMMANDS([gccdepdir],[ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR - for lang in $subdirs c-family common analyzer text-art rtl-ssa sym-exec + for lang in $subdirs c-family common analyzer diagnostics text-art rtl-ssa sym-exec do ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR done], [subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR]) diff --git a/gcc/diagnostic-format-html.cc b/gcc/diagnostic-format-html.cc index becac39f5dc..bac99260ec3 100644 --- a/gcc/diagnostic-format-html.cc +++ b/gcc/diagnostic-format-html.cc @@ -42,8 +42,8 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "xml.h" #include "xml-printer.h" -#include "diagnostic-digraphs.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/digraphs.h" +#include "diagnostics/state-graphs.h" #include "graphviz.h" #include "json.h" #include "selftest-xml.h" diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index d20ca86ae75..dd8b0793940 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -28,8 +28,8 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "diagnostic.h" #include "diagnostic-metadata.h" -#include "diagnostic-digraphs.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/digraphs.h" +#include "diagnostics/state-graphs.h" #include "diagnostic-path.h" #include "diagnostic-format.h" #include "diagnostic-buffer.h" diff --git a/gcc/diagnostic-path.cc b/gcc/diagnostic-path.cc index 1ae87b7e0bc..e55a11cb54e 100644 --- a/gcc/diagnostic-path.cc +++ b/gcc/diagnostic-path.cc @@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "diagnostic.h" #include "diagnostic-path.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" /* Disable warnings about missing quoting in GCC diagnostics for the print calls below. */ diff --git a/gcc/diagnostic-digraphs.cc b/gcc/diagnostics/digraphs.cc similarity index 99% rename from gcc/diagnostic-digraphs.cc rename to gcc/diagnostics/digraphs.cc index 85c0c5166c0..5571c007802 100644 --- a/gcc/diagnostic-digraphs.cc +++ b/gcc/diagnostics/digraphs.cc @@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "graphviz.h" -#include "diagnostic-digraphs.h" +#include "diagnostics/digraphs.h" #include "diagnostic-format-sarif.h" #include "selftest.h" @@ -473,7 +473,7 @@ test_simple_graph () /* Run all of the selftests within this file. */ void -diagnostic_digraphs_cc_tests () +diagnostics_digraphs_cc_tests () { test_empty_graph (); test_simple_graph (); diff --git a/gcc/diagnostic-digraphs.h b/gcc/diagnostics/digraphs.h similarity index 98% rename from gcc/diagnostic-digraphs.h rename to gcc/diagnostics/digraphs.h index d6f8e7e11ac..5c07fa866c9 100644 --- a/gcc/diagnostic-digraphs.h +++ b/gcc/diagnostics/digraphs.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ -#ifndef GCC_DIAGNOSTIC_DIGRAPHS_H -#define GCC_DIAGNOSTIC_DIGRAPHS_H +#ifndef GCC_DIAGNOSTICS_DIGRAPHS_H +#define GCC_DIAGNOSTICS_DIGRAPHS_H #include "json.h" #include "logical-location.h" @@ -418,4 +418,4 @@ private: } // namespace digraphs } // namespace diagnostics -#endif /* ! GCC_DIAGNOSTIC_DIGRAPHS_H */ +#endif /* ! GCC_DIAGNOSTICS_DIGRAPHS_H */ diff --git a/gcc/diagnostic-state-to-dot.cc b/gcc/diagnostics/state-graphs-to-dot.cc similarity index 99% rename from gcc/diagnostic-state-to-dot.cc rename to gcc/diagnostics/state-graphs-to-dot.cc index 90ceaee756e..9b64fa0889f 100644 --- a/gcc/diagnostic-state-to-dot.cc +++ b/gcc/diagnostics/state-graphs-to-dot.cc @@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" #include "graphviz.h" #include "xml.h" #include "xml-printer.h" diff --git a/gcc/diagnostic-state-graphs.cc b/gcc/diagnostics/state-graphs.cc similarity index 98% rename from gcc/diagnostic-state-graphs.cc rename to gcc/diagnostics/state-graphs.cc index 62eb6f5704a..e2c8c1d33cf 100644 --- a/gcc/diagnostic-state-graphs.cc +++ b/gcc/diagnostics/state-graphs.cc @@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/state-graphs.h" #include "graphviz.h" #include "xml.h" #include "xml-printer.h" @@ -148,7 +148,7 @@ test_node_attrs () /* Run all of the selftests within this file. */ void -diagnostic_state_graphs_cc_tests () +diagnostics_state_graphs_cc_tests () { test_node_attrs (); } diff --git a/gcc/diagnostic-state-graphs.h b/gcc/diagnostics/state-graphs.h similarity index 96% rename from gcc/diagnostic-state-graphs.h rename to gcc/diagnostics/state-graphs.h index def6d058897..ccf8bde821a 100644 --- a/gcc/diagnostic-state-graphs.h +++ b/gcc/diagnostics/state-graphs.h @@ -18,10 +18,10 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ -#ifndef GCC_DIAGNOSTIC_STATE_GRAPHS_H -#define GCC_DIAGNOSTIC_STATE_GRAPHS_H +#ifndef GCC_DIAGNOSTICS_STATE_GRAPHS_H +#define GCC_DIAGNOSTICS_STATE_GRAPHS_H -#include "diagnostic-digraphs.h" +#include "diagnostics/digraphs.h" #include "logical-location.h" /* diagnostics::digraphs provides support for directed graphs. @@ -153,4 +153,4 @@ make_dot_graph (const diagnostics::digraphs::digraph &state_graph, } // namespace state_graphs } // namespace diagnostics -#endif /* ! GCC_DIAGNOSTIC_STATE_GRAPHS_H */ +#endif /* ! GCC_DIAGNOSTICS_STATE_GRAPHS_H */ diff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc index 172f19c59bd..7bf0cbd7f4b 100644 --- a/gcc/libgdiagnostics.cc +++ b/gcc/libgdiagnostics.cc @@ -33,8 +33,8 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-format-sarif.h" #include "diagnostic-format-text.h" #include "diagnostic-output-spec.h" -#include "diagnostic-digraphs.h" -#include "diagnostic-state-graphs.h" +#include "diagnostics/digraphs.h" +#include "diagnostics/state-graphs.h" #include "logical-location.h" #include "edit-context.h" #include "libgdiagnostics.h" diff --git a/gcc/selftest-run-tests.cc b/gcc/selftest-run-tests.cc index d43d9dd6513..8cd04149f1a 100644 --- a/gcc/selftest-run-tests.cc +++ b/gcc/selftest-run-tests.cc @@ -102,9 +102,9 @@ selftest::run_tests () diagnostic_show_locus_cc_tests (); diagnostic_format_html_cc_tests (); diagnostic_format_sarif_cc_tests (); - diagnostic_digraphs_cc_tests (); + diagnostics_digraphs_cc_tests (); diagnostic_output_spec_cc_tests (); - diagnostic_state_graphs_cc_tests (); + diagnostics_state_graphs_cc_tests (); edit_context_cc_tests (); fold_const_cc_tests (); spellcheck_cc_tests (); diff --git a/gcc/selftest.h b/gcc/selftest.h index 06485e1fffa..5b1d2b00ad8 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -222,13 +222,13 @@ extern void cgraph_cc_tests (); extern void convert_cc_tests (); extern void dbgcnt_cc_tests (); extern void diagnostic_color_cc_tests (); -extern void diagnostic_digraphs_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 diagnostic_state_graphs_cc_tests (); +extern void diagnostics_digraphs_cc_tests (); +extern void diagnostics_state_graphs_cc_tests (); extern void digraph_cc_tests (); extern void dumpfile_cc_tests (); extern void edit_context_cc_tests (); diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_graphs.cc b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_graphs.cc index d4321617063..cfaffbf3461 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_graphs.cc +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_graphs.cc @@ -34,7 +34,7 @@ #include "context.h" #include "gcc-rich-location.h" #include "diagnostic-metadata.h" -#include "diagnostic-digraphs.h" +#include "diagnostics/digraphs.h" #include "pass_manager.h" -- 2.47.2