32 for(
const auto &symbol_pair : symbol_table.
symbols)
34 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
38 (*this)[new_node_index].class_identifier = symbol_pair.first;
43 for(
const auto &symbol_pair : symbol_table.
symbols)
45 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
49 for(
const auto &base : struct_type.
bases())
51 const irep_idt &parent = base.type().get_identifier();
57 "parent class not in symbol table");
68 const std::vector<node_indext> &node_indices)
const
74 back_inserter(result),
76 return (*
this)[node_index].class_identifier;
97 idst direct_child_ids;
99 const auto &reachable_indices =
get_reachable(node_index, forwards);
106 std::remove(reachable_ids.begin(), reachable_ids.end(), c),
107 reachable_ids.end());
108 return reachable_ids;
133 class_mapt::const_iterator it=
class_map.find(c);
136 const entryt &entry=it->second;
138 for(
const auto &child : entry.
children)
139 dest.push_back(child);
142 for(
const auto &child : entry.
children)
152 for(
const auto &symbol_pair : symbol_table.
symbols)
154 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
158 class_map[symbol_pair.first].is_abstract =
161 for(
const auto &base : struct_type.
bases())
163 const irep_idt &parent = base.type().get_identifier();
167 class_map[parent].children.push_back(symbol_pair.first);
168 class_map[symbol_pair.first].parents.push_back(parent);
183 class_mapt::const_iterator it=
class_map.find(c);
186 const entryt &entry=it->second;
188 for(
const auto &child : entry.
parents)
189 dest.push_back(child);
192 for(
const auto &child : entry.
parents)
203 out << c.first << (c.second.is_abstract ?
" (abstract)" :
"") <<
":\n";
206 out <<
" parents:\n";
207 for(
const auto &pa : c.second.parents)
208 out <<
" " << pa <<
'\n';
210 out <<
" children:\n";
211 for(
const auto &ch : c.second.children)
212 out <<
" " << ch <<
'\n';
220 ostr <<
"digraph class_hierarchy {\n"
222 <<
" node [fontsize=12 shape=box];\n";
225 for(
const auto &ch : c.second.parents)
227 ostr <<
" \"" << c.first <<
"\" -> "
228 <<
"\"" << ch <<
"\" "
229 <<
" [arrowhead=\"vee\"];"
241 bool children_only)
const
252 for(
const auto &pa : c.second.parents)
257 for(
const auto &ch : c.second.children)
268 switch(message_handler.
get_ui())
275 if(msg.
result().tellp() > 0)
static abstract_object_pointert transform(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns)
void show_class_hierarchy(const class_hierarchyt &hierarchy, ui_message_handlert &message_handler, bool children_only)
Output the class hierarchy.
void populate(const symbol_table_baset &)
Populate the class hierarchy graph, such that there is a node for every struct type in the symbol tab...
nodes_by_namet nodes_by_name
Maps class identifiers onto node indices.
idst get_children_trans(const irep_idt &c) const
Get all the classes that inherit (directly or indirectly) from class c.
std::vector< irep_idt > idst
idst get_direct_children(const irep_idt &c) const
Get all the classes that directly (i.e.
idst get_other_reachable_ids(const irep_idt &c, bool forwards) const
Helper function for get_children_trans and get_parents_trans
idst get_parents_trans(const irep_idt &c) const
Get all the classes that class c inherits from (directly or indirectly).
idst ids_from_indices(const std::vector< node_indext > &nodes) const
Helper function that converts a vector of node_indext to a vector of ids that are stored in the corre...
Non-graph-based representation of the class hierarchy.
void output_dot(std::ostream &) const
Output class hierarchy in Graphviz DOT format.
void get_parents_trans_rec(const irep_idt &, idst &) const
Get all the classes that class c inherits from (directly or indirectly).
void operator()(const symbol_table_baset &)
Looks for all the struct types in the symbol table and construct a map from class names to a data str...
void get_children_trans_rec(const irep_idt &, idst &) const
void output(std::ostream &, bool children_only) const
Output the class hierarchy in plain text.
std::vector< irep_idt > idst
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
std::vector< node_indext > get_reachable(node_indext src, bool forwards) const
Run depth-first search on the graph, starting from a single source node.
node_indext add_node(arguments &&... values)
void add_edge(node_indext a, node_indext b)
std::vector< node_indext > get_successors(const node_indext &n) const
bool get_bool(const irep_idt &name) const
Provides methods for streaming JSON arrays.
void push_back(const jsont &json)
Push back a JSON element into the current array stream.
json_stream_objectt & push_back_stream_object()
Add a JSON object child stream.
Provides methods for streaming JSON objects.
json_stream_arrayt & push_back_stream_array(const std::string &key)
Add a JSON array stream for a specific key.
static jsont json_boolean(bool value)
Class that provides messages with a built-in verbosity 'level'.
mstreamt & result() const
Structure type, corresponds to C style structs.
const basest & bases() const
Get the collection of base classes/structs.
The symbol table base class interface.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
virtual uit get_ui() const
virtual json_stream_arrayt & get_json_stream()
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.