diff --git a/src/goto-programs/class_hierarchy.cpp b/src/goto-programs/class_hierarchy.cpp index 1311a3e7fdc..14e8cdadee9 100644 --- a/src/goto-programs/class_hierarchy.cpp +++ b/src/goto-programs/class_hierarchy.cpp @@ -135,3 +135,30 @@ void class_hierarchyt::output(std::ostream &out) const << ch << '\n'; } } + +/*******************************************************************\ + +Function: output_dot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +std::ostream &output_dot(std::ostream &ostr, const class_hierarchyt &hierarchy) +{ + ostr << "digraph call_graph {\n" + << " rankdir=BT;\n" + << " node [fontsize=12 shape=box];\n"; + for(const auto &c : hierarchy.class_map) + for(const auto &ch : c.second.parents) + ostr << " \"" << c.first << "\" -> " + << "\"" << ch << "\" " + << " [arrowhead=\"vee\"];" + << "\n"; + ostr << "}\n"; + return ostr; +} diff --git a/src/goto-programs/class_hierarchy.h b/src/goto-programs/class_hierarchy.h index bef2c7ec7eb..d124c66e558 100644 --- a/src/goto-programs/class_hierarchy.h +++ b/src/goto-programs/class_hierarchy.h @@ -55,4 +55,6 @@ class class_hierarchyt void get_parents_trans_rec(const irep_idt &, idst &) const; }; +std::ostream &output_dot(std::ostream &ostr, const class_hierarchyt &hierarchy); + #endif // CPROVER_GOTO_PROGRAMS_CLASS_HIERARCHY_H