GCC Middle and Back End API Reference
dot Namespace Reference

Data Structures

struct  ast_node
struct  attr_list
struct  attr_stmt
struct  edge_stmt
struct  graph
struct  id
struct  kv_pair
struct  kv_stmt
struct  node_id
struct  node_stmt
struct  port
struct  stmt
struct  stmt_list
struct  stmt_with_attr_list
struct  subgraph
class  writer

Enumerations

enum class  compass_pt {
  n , ne , e , se ,
  s , sw , w , nw ,
  c
}

Functions

static std::unique_ptr< std::string > make_svg_document_buffer_from_graph (const graph &g)
std::unique_ptr< xml::nodemake_svg_from_graph (const graph &g)

Detailed Description

Extensions to diagnostics::digraphs to support state graphs.
   Copyright (C) 2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

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/>.   
diagnostics::digraphs provides support for directed graphs.

diagnostics::state_graphs provides a way to extend these graphs
for representing "state graphs" i.e. a representation of the state
of memory inside a program, for use e.g. by -fanalyzer.

Specifically, nodes represent memory regions, and we use property bags
in these nodes to stash extra properties (e.g. what kind of memory region
a node is e.g. stack vs heap).   

Enumeration Type Documentation

◆ compass_pt

enum class dot::compass_pt
strong
node_id : ID [ port ]  
Enumerator
ne 
se 
sw 
nw 

Function Documentation

◆ make_svg_document_buffer_from_graph()

std::unique_ptr< std::string > dot::make_svg_document_buffer_from_graph ( const graph & g)
static
Convert G to graphviz source, attempt to invoke "dot -Tsvg" on it
as a subprocess, and get the SVG source from stdout, or nullptr
if there was a problem.   

References g, gcc_assert, pex::input_file(), pp_flush(), file_wrapper::read_all(), pex::read_output(), pex::run(), pretty_printer::set_output_stream(), and w.

Referenced by make_svg_from_graph().

◆ make_svg_from_graph()

std::unique_ptr< xml::node > dot::make_svg_from_graph ( const graph & g)
Convert G to graphviz source, attempt to invoke "dot -Tsvg" on it
as a subprocess, and get the SVG source from stdout, and extract
the "svg" subtree as an xml::raw node.

Note that this
(a) invokes "dot" as a subprocess
(b) assumes that we trust the output from "dot".

Return nullptr if there was a problem.   

References g, and make_svg_document_buffer_from_graph().

Referenced by diagnostics::html_builder::add_graph(), and diagnostics::html_builder::maybe_make_state_diagram().