Line data Source code
1 : /* Converting directed graphs to dot.
2 : Copyright (C) 2025-2026 Free Software Foundation, Inc.
3 : Contributed by David Malcolm <dmalcolm@redhat.com>
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 : #ifndef GCC_DIAGNOSTICS_DIGRAPHS_TO_DOT_H
22 : #define GCC_DIAGNOSTICS_DIGRAPHS_TO_DOT_H
23 :
24 : #include "diagnostics/digraphs.h"
25 : #include "graphviz.h"
26 :
27 : namespace diagnostics {
28 : namespace digraphs {
29 : namespace to_dot {
30 :
31 : using digraph = diagnostics::digraphs::digraph;
32 : using digraph_node = diagnostics::digraphs::node;
33 : using digraph_edge = diagnostics::digraphs::edge;
34 :
35 56 : class converter
36 : {
37 : public:
38 67 : virtual ~converter () {}
39 :
40 : static std::unique_ptr<converter>
41 : make (const digraph &dg);
42 :
43 : virtual std::unique_ptr<dot::graph>
44 : make_dot_graph_from_diagnostic_graph (const digraph &);
45 :
46 : std::unique_ptr<dot::stmt>
47 : make_dot_node_from_digraph_node (const digraph_node &);
48 :
49 : std::unique_ptr<dot::edge_stmt>
50 : make_dot_edge_from_digraph_edge (const digraph_edge &);
51 :
52 : dot::id
53 : get_dot_id_for_node (const digraph_node &);
54 :
55 : dot::node_id
56 : get_node_id_for_node (const digraph_node &,
57 : const char *compass_point = nullptr);
58 :
59 : bool
60 : has_edges_p (const digraph_node &);
61 :
62 : virtual void
63 : add_any_subgraph_attrs (const digraph_node &input_node,
64 : dot::subgraph &output_subgraph);
65 :
66 : virtual void
67 : add_any_node_attrs (const digraph_node &input_node,
68 : dot::node_stmt &output_node);
69 :
70 : virtual void
71 : add_any_edge_attrs (const digraph_edge &input_edge,
72 : dot::edge_stmt &output_edge);
73 :
74 : private:
75 : std::set<const digraph_node *> m_nodes_with_edges;
76 : std::map<const digraph_node *, dot::stmt *> m_node_map;
77 : };
78 :
79 : extern std::unique_ptr<converter>
80 : make_converter_from_cfg ();
81 :
82 : } // namespace to_dot
83 : } // namespace digraphs
84 : } // namespace diagnostics
85 :
86 : #endif /* ! GCC_DIAGNOSTICS_DIGRAPHS_TO_DOT_H */
|