From e3f5bd27f7c0d39e7fdcd8ee3b44056df110fe40 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Tue, 9 Oct 2018 13:50:13 +0100 Subject: [PATCH] dot: use irep_idt for function identifier We are working towards removing the "function" field from goto_programt::instructionst::instructiont. Thus we should use an available function identifier, rather than reading it from instructiont, where possible. --- src/goto-instrument/dot.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/goto-instrument/dot.cpp b/src/goto-instrument/dot.cpp index 5acaa52076e..39be311134a 100644 --- a/src/goto-instrument/dot.cpp +++ b/src/goto-instrument/dot.cpp @@ -44,10 +44,8 @@ class dott std::list function_calls; std::list clusters; - void write_dot_subgraph( - std::ostream &, - const std::string &, - const goto_programt &); + void + write_dot_subgraph(std::ostream &, const irep_idt &, const goto_programt &); void do_dot_function_calls(std::ostream &); @@ -64,21 +62,23 @@ class dott std::set &); }; -/// writes the dot graph that corresponds to the goto program to the output +/// Write the dot graph that corresponds to the goto program to the output /// stream. -/// \par parameters: output stream, name and goto program +/// \param out: output stream +/// \param function_id: name of \p goto_program +/// \param goto_program: goto program the dot graph of which is written /// \return true on error, false otherwise void dott::write_dot_subgraph( std::ostream &out, - const std::string &name, + const irep_idt &function_id, const goto_programt &goto_program) { clusters.push_back(exprt("cluster")); - clusters.back().set("name", name); + clusters.back().set("name", function_id); clusters.back().set("nr", subgraphscount); - out << "subgraph \"cluster_" << name << "\" {\n"; - out << "label=\"" << name << "\";\n"; + out << "subgraph \"cluster_" << function_id << "\" {\n"; + out << "label=\"" << function_id << "\";\n"; const goto_programt::instructionst &instructions = goto_program.instructions; @@ -111,7 +111,7 @@ void dott::write_dot_subgraph( tmp.str("Goto"); else { - std::string t = from_expr(ns, it->function, it->guard); + std::string t = from_expr(ns, function_id, it->guard); while(t[ t.size()-1 ]=='\n') t = t.substr(0, t.size()-1); tmp << escape(t) << "?"; @@ -119,14 +119,14 @@ void dott::write_dot_subgraph( } else if(it->is_assume()) { - std::string t = from_expr(ns, it->function, it->guard); + std::string t = from_expr(ns, function_id, it->guard); while(t[ t.size()-1 ]=='\n') t = t.substr(0, t.size()-1); tmp << "Assume\\n(" << escape(t) << ")"; } else if(it->is_assert()) { - std::string t = from_expr(ns, it->function, it->guard); + std::string t = from_expr(ns, function_id, it->guard); while(t[ t.size()-1 ]=='\n') t = t.substr(0, t.size()-1); tmp << "Assert\\n(" << escape(t) << ")"; @@ -145,7 +145,7 @@ void dott::write_dot_subgraph( tmp.str("Atomic End"); else if(it->is_function_call()) { - std::string t = from_expr(ns, it->function, it->code); + std::string t = from_expr(ns, function_id, it->code); while(t[ t.size()-1 ]=='\n') t = t.substr(0, t.size()-1); tmp.str(escape(t)); @@ -162,7 +162,7 @@ void dott::write_dot_subgraph( it->is_return() || it->is_other()) { - std::string t = from_expr(ns, it->function, it->code); + std::string t = from_expr(ns, function_id, it->code); while(t[ t.size()-1 ]=='\n') t = t.substr(0, t.size()-1); tmp.str(escape(t)); @@ -266,7 +266,7 @@ void dott::output(std::ostream &out) forall_goto_functions(it, goto_model.goto_functions) if(it->second.body_available()) - write_dot_subgraph(out, id2string(it->first), it->second.body); + write_dot_subgraph(out, it->first, it->second.body); do_dot_function_calls(out);