Go to file
David Malcolm c89bd48e7e diagnostics: generalize state graph code to use json::property instances (v2)
In r16-1631-g2334d30cd8feac I added support for capturing state
information from -fanalyzer in the form of embedded XML strings
in SARIF output.

In r16-2211-ga5d9debedd2f46 I rewrote this so the state was captured in
the form of a SARIF directed graph, using various custom types.

I want to add the ability to capture other kinds of graph in our SARIF
output (e.g. inheritance hierarchies, CFGs, etc), so  the following patch
reworks the state graph handling code to minimize the use of custom types.
Instead, the patch introduces various json::property types, and
describes the state graph serialization in terms of instances of these
properties, rather than hardcoding string attribute names in readers and
writers.  The custom SARIF properties live in a new
"gcc/custom-sarif-properties/" directory.

The "experimental-html" scheme keys "show-state-diagrams-dot-src" and
"show-state-diagrams-sarif" become "show-graph-dot-src" and
"show-graph-dot-src" in preparation for new kinds of graph in the output.

This is an updated version of the patch, tested to build with GCC 5
(which the previous version didn't leading to PR bootstrap/122151)

contrib/ChangeLog:
	* gcc.doxy (INPUT): Add gcc/custom-sarif-properties

gcc/ChangeLog:
	* Makefile.in (OBJS-libcommon): Add
	custom-sarif-properties/digraphs.o and
	custom-sarif-properties/state-graphs.o.  Remove
	diagnostics/state-graphs.o.
	* configure: Regenerate.
	* configure.ac: Add custom-sarif-properties to subdir iteration.
	* custom-sarif-properties/digraphs.cc: New file.
	* custom-sarif-properties/digraphs.h: New file.
	* custom-sarif-properties/state-graphs.cc: New file.
	* custom-sarif-properties/state-graphs.h: New file.
	* diagnostics/diagnostics-selftests.cc
	(run_diagnostics_selftests): Drop call of state_graphs_cc_tests.
	* diagnostics/diagnostics-selftests.h (state_graphs_cc_tests):
	Delete decl.
	* diagnostics/digraphs.cc: Include
	"custom-sarif-properties/digraphs.h".  Move include of
	"selftest.h" to within CHECKING_P section.
	(using digraph_object): New.
	(namespace properties): New.
	(diagnostics::digraphs::object::get_attr): Delete.
	(diagnostics::digraphs::object::set_attr): Delete.
	(diagnostics::digraphs::object::set_json_attr): Delete.
	(digraph_object::get_property): New definitions, for various
	property types.
	(digraph_object::set_property): Likewise.
	(digraph_object::maybe_get_property): New.
	(digraph_object::get_property_as_tristate): New.
	(digraph_object::ensure_property_bag): New.
	(digraph::get_graph_kind): New.
	(digraph::set_graph_kind): New.
	Add include of "custom-sarif-properties/state-graphs.h".
	(selftest::test_simple_graph): Rewrite to use json::property
	instances rather than string attribute names.
	(selftest::test_property_objects): New test.
	(selftest::digraphs_cc_tests): Call it.
	* diagnostics/digraphs.h: Include "tristate.h".
	(object::get_attr): Delete.
	(object::set_attr): Delete.
	(object::get_property): New decls.
	(object::set_property): New decls.
	(object::maybe_get_property): New.
	(object::get_property_as_tristate): New.
	(object::set_json_attr): Delete.
	(object::ensure_property_bag): New.
	(graph::get_graph_kind): New.
	(graph::set_graph_kind): New.
	* diagnostics/html-sink.cc
	(html_generation_options::html_generation_options): Update for
	field renamings.
	(html_generation_options::dump): Likewise.
	(html_builder::maybe_make_state_diagram): Likewise.
	(html_builder::add_graph): Show SARIF and .dot src inline, if
	requested.
	* diagnostics/html-sink.h
	(html_generation_options::m_show_state_diagrams_sarif): Rename
	to...
	(html_generation_options::m_show_graph_sarif): ...this.
	(html_generation_options::m_show_state_diagrams_dot_src): Rename
	to...
	(html_generation_options::m_show_graph_dot_src0): ...this.
	* diagnostics/output-spec.cc
	(html_scheme_handler::maybe_handle_kv): Rename keys.
	(html_scheme_handler::get_keys): Likewise.
	* diagnostics/state-graphs-to-dot.cc: : Reimplement throughout to
	use json::property instances found within custom_sarif_properties
	throughout, rather than types in diagnostics::state_graphs.
	* diagnostics/state-graphs.cc: Deleted file.
	* diagnostics/state-graphs.h: Delete almost all, except decl of
	diagnostics::state_graphs::make_dot_graph.
	* doc/invoke.texi: Update for changes to "experimental-html" sink
	keys.
	* json.cc (json::object::set_string): New.
	(json::object::set_integer): New.
	(json::object::set_bool): New.
	(json::object::set_array_of_string): New.
	* json.h: Include "label-text.h".
	(struct json::property): New template.
	(json::string_property): New.
	(json::integer_property): New.
	(json::bool_property): New.
	(json::json_property): New.
	(using json::array_of_string_property): New.
	(struct json::enum_traits): New.
	(enum_json::property): New.
	(json::value::dyn_cast_array): New vfunc.
	(json::value::dyn_cast_integer_number): New vfunc.
	(json::value::set_string): New.
	(json::value::set_integer): New.
	(json::value::set_bool): New.
	(json::value::set_array_of_string): New.
	(json::value::maybe_get_enum): New.
	(json::value::set_enum): New.
	(json::array::dyn_cast_array): New.
	(json::integer_number::dyn_cast_integer_number): New.
	(object::maybe_get_enum): New.
	(object::set_enum): New.

gcc/analyzer/ChangeLog:
	* ana-state-to-diagnostic-state.cc: Reimplement throughout to use
	json::property instances found within custom_sarif_properties
	throughout, rather than types in diagnostics::state_graphs.
	* ana-state-to-diagnostic-state.h: Likewise.
	* checker-event.cc: Likewise.
	* sm-malloc.cc: Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc
	(report_diag_with_graphs): Port from set_attr to set_property.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-10-16 17:39:03 -04:00
.forgejo top-level: Add pull request template for Forgejo 2024-10-23 19:45:09 +01:00
.github
INSTALL
c++tools Daily bump. 2025-06-03 00:18:06 +00:00
config Daily bump. 2025-10-05 16:50:51 +00:00
contrib diagnostics: generalize state graph code to use json::property instances (v2) 2025-10-16 17:39:03 -04:00
fixincludes Daily bump. 2025-08-29 00:19:55 +00:00
gcc diagnostics: generalize state graph code to use json::property instances (v2) 2025-10-16 17:39:03 -04:00
gnattools Daily bump. 2025-06-23 00:16:33 +00:00
gotools Daily bump. 2024-04-16 00:18:06 +00:00
include dwarf: add wiki link for DWARF GNU_annotation extensions 2025-10-16 11:08:30 -07:00
libada Update copyright years. 2025-01-02 11:59:57 +01:00
libatomic Daily bump. 2025-10-10 00:21:51 +00:00
libbacktrace Daily bump. 2025-10-05 16:50:51 +00:00
libcc1 Daily bump. 2025-10-10 00:21:51 +00:00
libcody Update Copyright year in ChangeLog files 2025-01-02 11:13:18 +01:00
libcpp Daily bump. 2025-10-14 00:20:06 +00:00
libdecnumber Update copyright years. 2025-01-02 11:59:57 +01:00
libffi Daily bump. 2025-10-05 16:50:51 +00:00
libgcc Daily bump. 2025-10-10 00:21:51 +00:00
libgcobol Daily bump. 2025-10-11 00:21:09 +00:00
libgfortran Daily bump. 2025-10-05 16:50:51 +00:00
libgm2 Daily bump. 2025-10-08 00:20:55 +00:00
libgo runtime: avoid libc memmove and memclr 2025-07-08 15:49:16 -07:00
libgomp libgomp.c/declare-variant-4-gfx*: Add missing archs + dg-excess-errors 2025-10-16 11:11:39 +02:00
libgrust Daily bump. 2025-10-05 16:50:51 +00:00
libiberty Daily bump. 2025-10-05 16:50:51 +00:00
libitm Daily bump. 2025-10-05 16:50:51 +00:00
libobjc Daily bump. 2025-10-05 16:50:51 +00:00
libphobos Daily bump. 2025-10-05 16:50:51 +00:00
libquadmath Daily bump. 2025-10-05 16:50:51 +00:00
libsanitizer Daily bump. 2025-10-05 16:50:51 +00:00
libssp Daily bump. 2025-10-05 16:50:51 +00:00
libstdc++-v3 libstdc++: Improve ostream output for std::stacktrace 2025-10-16 14:59:42 +01:00
libvtv Daily bump. 2025-10-05 16:50:51 +00:00
lto-plugin Daily bump. 2025-10-05 16:50:51 +00:00
maintainer-scripts Daily bump. 2025-09-02 00:19:26 +00:00
zlib Daily bump. 2025-10-05 16:50:51 +00:00
.b4-config Add config file so b4 uses inbox.sourceware.org automatically 2024-07-28 11:13:16 +01:00
.dir-locals.el dir-locals: apply our C settings in C++ also 2024-07-31 20:38:27 +02:00
.editorconfig toplevel: unify the GCC and GDB/binutils .editorconfig files 2025-10-01 15:42:59 +01:00
.gitattributes
.gitignore Rust: Move 'libformat_parser' build into the GCC build directory 2025-08-05 16:36:43 +02:00
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2025-10-16 00:21:56 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Add myself as an aarch64 port reviewer 2025-09-04 14:35:30 +00:00
Makefile.def PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
Makefile.in [PATCH] Makefile.tpl: remove an extra \; from find command 2025-10-15 11:32:21 -06:00
Makefile.tpl [PATCH] Makefile.tpl: remove an extra \; from find command 2025-10-15 11:32:21 -06:00
README
SECURITY.txt Remove Debian from SECURITY.txt 2024-11-19 12:27:33 +01:00
ar-lib
compile
config-ml.in *: Fix patch email address 2025-10-11 11:08:01 +02:00
config.guess
config.rpath
config.sub
configure PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
configure.ac PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
depcomp
install-sh
libtool-ldflags
libtool.m4 Sync toplevel files from binutils-gdb 2025-10-02 15:00:06 +08:00
ltgcc.m4
ltmain.sh ltmain.sh: allow more flags at link-time 2024-09-25 19:05:24 +01:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree *: Fix patch email address 2025-10-11 11:08:01 +02:00
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.