Go to the documentation of this file.
31 for(
const auto &symbol_pair : symbol_table.
symbols)
33 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
37 (*this)[new_node_index].class_identifier = symbol_pair.first;
42 for(
const auto &symbol_pair : symbol_table.
symbols)
44 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
48 for(
const auto &base : struct_type.
bases())
50 const irep_idt &parent = base.type().get_identifier();
56 "parent class not in symbol table");
67 const std::vector<node_indext> &node_indices)
const
73 back_inserter(result),
75 return (*
this)[node_index].class_identifier;
96 idst direct_child_ids;
98 const auto &reachable_indices =
get_reachable(node_index, forwards);
105 std::remove(reachable_ids.begin(), reachable_ids.end(), c),
106 reachable_ids.end());
107 return reachable_ids;
132 class_mapt::const_iterator it=
class_map.find(c);
135 const entryt &entry=it->second;
137 for(
const auto &child : entry.
children)
138 dest.push_back(child);
141 for(
const auto &child : entry.
children)
151 for(
const auto &symbol_pair : symbol_table.
symbols)
153 if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct)
157 class_map[symbol_pair.first].is_abstract =
160 for(
const auto &base : struct_type.
bases())
162 const irep_idt &parent = base.type().get_identifier();
166 class_map[parent].children.push_back(symbol_pair.first);
167 class_map[symbol_pair.first].parents.push_back(parent);
182 class_mapt::const_iterator it=
class_map.find(c);
185 const entryt &entry=it->second;
187 for(
const auto &child : entry.
parents)
188 dest.push_back(child);
191 for(
const auto &child : entry.
parents)
202 out << c.first << (c.second.is_abstract ?
" (abstract)" :
"") <<
":\n";
205 out <<
" parents:\n";
206 for(
const auto &pa : c.second.parents)
207 out <<
" " << pa <<
'\n';
209 out <<
" children:\n";
210 for(
const auto &ch : c.second.children)
211 out <<
" " << ch <<
'\n';
219 ostr <<
"digraph class_hierarchy {\n"
221 <<
" node [fontsize=12 shape=box];\n";
224 for(
const auto &ch : c.second.parents)
226 ostr <<
" \"" << c.first <<
"\" -> "
227 <<
"\"" << ch <<
"\" "
228 <<
" [arrowhead=\"vee\"];"
240 bool children_only)
const
251 for(
const auto &pa : c.second.parents)
256 for(
const auto &ch : c.second.children)
267 switch(message_handler.
get_ui())
274 if(msg.
result().tellp() > 0)
Class that provides messages with a built-in verbosity 'level'.
std::vector< irep_idt > idst
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
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 operator()(const symbol_tablet &)
Looks for all the struct types in the symbol table and construct a map from class names to a data str...
void output(std::ostream &, bool children_only) const
Output the class hierarchy in plain text.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
void show_class_hierarchy(const class_hierarchyt &hierarchy, ui_message_handlert &message_handler, bool children_only)
Output the class hierarchy.
void get_children_trans_rec(const irep_idt &, idst &) const
node_indext add_node(arguments &&... values)
void get_parents_trans_rec(const irep_idt &, idst &) const
Get all the classes that class c inherits from (directly or indirectly).
idst get_children_trans(const irep_idt &c) const
Get all the classes that inherit (directly or indirectly) from class c.
virtual uit get_ui() const
json_stream_arrayt & push_back_stream_array(const std::string &key)
Add a JSON array stream for a specific key.
virtual json_stream_arrayt & get_json_stream()
bool get_bool(const irep_namet &name) const
mstreamt & result() const
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
nodes_by_namet nodes_by_name
Maps class identifiers onto node indices.
Provides methods for streaming JSON arrays.
const basest & bases() const
Get the collection of base classes/structs.
std::vector< irep_idt > idst
void add_edge(node_indext a, node_indext b)
json_stream_objectt & push_back_stream_object()
Add a JSON object child stream.
Provides methods for streaming JSON objects.
Structure type, corresponds to C style structs.
idst get_other_reachable_ids(const irep_idt &c, bool forwards) const
Helper function for get_children_trans and get_parents_trans
std::vector< node_indext > get_successors(const node_indext &n) const
const symbolst & symbols
Read-only field, used to look up symbols given their names.
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.
void output_dot(std::ostream &) const
Output class hierarchy in Graphviz DOT format.
void push_back(const jsont &json)
Push back a JSON element into the current array stream.
static jsont json_boolean(bool value)
idst get_direct_children(const irep_idt &c) const
Get all the classes that directly (i.e.
void populate(const symbol_tablet &)
Populate the class hierarchy graph, such that there is a node for every struct type in the symbol tab...