@@ -124,13 +124,13 @@ void cfg_dominators_templatet<P, T, post_dom>::fixedpoint(P &program)
124
124
{
125
125
std::list<T> worklist;
126
126
127
- if (program. instructions . empty ( ))
127
+ if (cfg. nodes_empty (program ))
128
128
return ;
129
129
130
130
if (post_dom)
131
- entry_node = --program. instructions . end ( );
131
+ entry_node=cfg. get_last_node (program );
132
132
else
133
- entry_node = program. instructions . begin ( );
133
+ entry_node=cfg. get_first_node (program );
134
134
typename cfgt::nodet &n=cfg[cfg.entry_map [entry_node]];
135
135
n.dominators .insert (entry_node);
136
136
@@ -200,6 +200,25 @@ void cfg_dominators_templatet<P, T, post_dom>::fixedpoint(P &program)
200
200
201
201
/* ******************************************************************\
202
202
203
+ Function: dominators_pretty_print_node
204
+
205
+ Inputs: `node` to print and stream `out` to pretty-print it to
206
+
207
+ Outputs:
208
+
209
+ Purpose: Pretty-print a single node in the dominator tree.
210
+ Supply a specialisation if operator<< is not sufficient.
211
+
212
+ \*******************************************************************/
213
+
214
+ template <class T >
215
+ void dominators_pretty_print_node (const T &node, std::ostream &out)
216
+ {
217
+ out << node;
218
+ }
219
+
220
+ /* ******************************************************************\
221
+
203
222
Function: cfg_dominators_templatet::output
204
223
205
224
Inputs:
@@ -215,20 +234,20 @@ void cfg_dominators_templatet<P, T, post_dom>::output(std::ostream &out) const
215
234
{
216
235
for (const auto &node : cfg.entry_map )
217
236
{
218
- unsigned n=node.first -> location_number ;
237
+ T n=node.first ;
219
238
239
+ dominators_pretty_print_node (n, out);
220
240
if (post_dom)
221
- out << n << " post-dominated by " ;
241
+ out << " post-dominated by " ;
222
242
else
223
- out << n << " dominated by " ;
224
- for (typename target_sett::const_iterator
225
- d_it=node.second .dominators .begin ();
226
- d_it!=node.second .dominators .end ();
227
- ) // no d_it++
243
+ out << " dominated by " ;
244
+ bool first=true ;
245
+ for (const auto &d : cfg[node.second ].dominators )
228
246
{
229
- out << (*d_it)->location_number ;
230
- if (++d_it!=node.second .dominators .end ())
247
+ if (!first)
231
248
out << " , " ;
249
+ first=false ;
250
+ dominators_pretty_print_node (d, out);
232
251
}
233
252
out << " \n " ;
234
253
}
@@ -240,4 +259,12 @@ typedef cfg_dominators_templatet<const goto_programt, goto_programt::const_targe
240
259
typedef cfg_dominators_templatet<const goto_programt, goto_programt::const_targett, true >
241
260
cfg_post_dominatorst;
242
261
262
+ template <>
263
+ inline void dominators_pretty_print_node (
264
+ const goto_programt::const_targett& node,
265
+ std::ostream& out)
266
+ {
267
+ out << node->location_number ;
268
+ }
269
+
243
270
#endif // CPROVER_ANALYSES_CFG_DOMINATORS_H
0 commit comments