Skip to content

Commit c694703

Browse files
marek-trtikpeterschrammel
authored andcommitted
Added output in DOT format for class hierarchy. (#642)
Added output in DOT format.
1 parent ef04e12 commit c694703

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/goto-programs/class_hierarchy.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,30 @@ void class_hierarchyt::output(std::ostream &out) const
135135
<< ch << '\n';
136136
}
137137
}
138+
139+
/*******************************************************************\
140+
141+
Function: output_dot
142+
143+
Inputs:
144+
145+
Outputs:
146+
147+
Purpose:
148+
149+
\*******************************************************************/
150+
151+
std::ostream &output_dot(std::ostream &ostr, const class_hierarchyt &hierarchy)
152+
{
153+
ostr << "digraph call_graph {\n"
154+
<< " rankdir=BT;\n"
155+
<< " node [fontsize=12 shape=box];\n";
156+
for(const auto &c : hierarchy.class_map)
157+
for(const auto &ch : c.second.parents)
158+
ostr << " \"" << c.first << "\" -> "
159+
<< "\"" << ch << "\" "
160+
<< " [arrowhead=\"vee\"];"
161+
<< "\n";
162+
ostr << "}\n";
163+
return ostr;
164+
}

src/goto-programs/class_hierarchy.h

+2
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,6 @@ class class_hierarchyt
5555
void get_parents_trans_rec(const irep_idt &, idst &) const;
5656
};
5757

58+
std::ostream &output_dot(std::ostream &ostr, const class_hierarchyt &hierarchy);
59+
5860
#endif // CPROVER_GOTO_PROGRAMS_CLASS_HIERARCHY_H

0 commit comments

Comments
 (0)