Add analyzer-graphs option for SARIF output.
New option captures analyzer's internal graphs in SARIF output for debugging.
This commit introduces a new suboption, analyzer-graphs=yes|no, for GCC’s -fdiagnostics-add-output=sarif flag. When enabled, this option captures detailed internal graph structures of the static analyzer, specifically its supergraph and exploded graph, and embeds them within the SARIF output. This feature is intended as a debugging aid for developers working on the analyzer itself, allowing for more in-depth analysis of its internal state.
In Details
The GCC static analyzer's SARIF diagnostic sink now supports an analyzer-graphs=yes|no option. When enabled, this causes the analyzer to serialize its internal supergraph and exploded_graph into the theRun.graphs array within the SARIF JSON output. This involves additions to sarif-sink.cc, json.cc, and opts-diagnostic.cc to handle graph serialization and option parsing. The gcc/analyzer/analyzer-diagnostic-extensions.cc file is new, providing the extension points for this functionality. This is primarily a developer-facing debugging feature.
- static analyzer
- A tool that analyzes source code to find potential bugs or vulnerabilities without executing the code. GCC has a built-in static analyzer.
- SARIF
- Static Analysis Results Interchange Format. A standard JSON-based format for representing the output of static analysis tools.
- supergraph
- In static analysis, a control flow graph that represents all possible execution paths within a program, including complex relationships between basic blocks.
- exploded graph
- A data structure used in abstract interpretation and static analysis to represent the state of the program at each node of the control flow graph, tracking possible values and conditions.
- diagnostics
- Messages issued by the compiler to inform the user about errors, warnings, or other information related to the code.