Line data Source code
1 : /* Converting directed graphs to dot.
2 : Copyright (C) 2025 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 : static std::unique_ptr<converter>
39 : make (const digraph &dg);
40 :
41 : virtual std::unique_ptr<dot::graph>
42 : make_dot_graph_from_diagnostic_graph (const digraph &);
43 :
44 : std::unique_ptr<dot::stmt>
45 : make_dot_node_from_digraph_node (const digraph_node &);
46 :
47 : std::unique_ptr<dot::edge_stmt>
48 : make_dot_edge_from_digraph_edge (const digraph_edge &);
49 :
50 : dot::id
51 : get_dot_id_for_node (const digraph_node &);
52 :
53 : dot::node_id
54 : get_node_id_for_node (const digraph_node &,
55 : const char *compass_point = nullptr);
56 :
57 : bool
58 : has_edges_p (const digraph_node &);
59 :
60 : virtual void
61 : add_any_subgraph_attrs (const digraph_node &input_node,
62 : dot::subgraph &output_subgraph);
63 :
64 : virtual void
65 : add_any_node_attrs (const digraph_node &input_node,
66 : dot::node_stmt &output_node);
67 :
68 : virtual void
69 : add_any_edge_attrs (const digraph_edge &input_edge,
70 : dot::edge_stmt &output_edge);
71 :
72 : private:
73 : std::set<const digraph_node *> m_nodes_with_edges;
74 : std::map<const digraph_node *, dot::stmt *> m_node_map;
75 : };
76 :
77 : extern std::unique_ptr<converter>
78 : make_converter_from_cfg ();
79 :
80 : } // namespace to_dot
81 : } // namespace digraphs
82 : } // namespace diagnostics
83 :
84 : #endif /* ! GCC_DIAGNOSTICS_DIGRAPHS_TO_DOT_H */
|