@@ -103,10 +103,8 @@ void cfg_dominators_templatet<P, T, post_dom>::initialise(P &program)
103103 cfg (program);
104104
105105 // initialise top element
106- for (typename cfgt::entry_mapt::const_iterator
107- e_it=cfg.entry_map .begin ();
108- e_it!=cfg.entry_map .end (); ++e_it)
109- top.insert (cfg[e_it->second ].PC );
106+ for (const auto &node : cfg.entry_map )
107+ top.insert (cfg[node.second ].PC );
110108}
111109
112110/* ******************************************************************\
@@ -151,24 +149,18 @@ void cfg_dominators_templatet<P, T, post_dom>::fixedpoint(P &program)
151149 bool changed=false ;
152150 typename cfgt::nodet &node=cfg[cfg.entry_map [current]];
153151 if (node.dominators .empty ())
154- for (typename cfgt::edgest::const_iterator
155- p_it=(post_dom?node.out :node.in ).begin ();
156- !changed && p_it!=(post_dom?node.out :node.in ).end ();
157- ++p_it)
158- if (!cfg[p_it->first ].dominators .empty ())
152+ for (const auto & edge : (post_dom?node.out :node.in ))
153+ if (!cfg[edge.first ].dominators .empty ())
159154 {
160- node.dominators =cfg[p_it-> first ].dominators ;
155+ node.dominators =cfg[edge. first ].dominators ;
161156 node.dominators .insert (current);
162157 changed=true ;
163158 }
164159
165160 // compute intersection of predecessors
166- for (typename cfgt::edgest::const_iterator
167- p_it=(post_dom?node.out :node.in ).begin ();
168- p_it!=(post_dom?node.out :node.in ).end ();
169- ++p_it)
161+ for (const auto & edge : (post_dom?node.out :node.in ))
170162 {
171- const target_sett &other=cfg[p_it-> first ].dominators ;
163+ const target_sett &other=cfg[edge. first ].dominators ;
172164 if (other.empty ())
173165 continue ;
174166
@@ -198,12 +190,9 @@ void cfg_dominators_templatet<P, T, post_dom>::fixedpoint(P &program)
198190
199191 if (changed) // fixed point for node reached?
200192 {
201- for (typename cfgt::edgest::const_iterator
202- s_it=(post_dom?node.in :node.out ).begin ();
203- s_it!=(post_dom?node.in :node.out ).end ();
204- ++s_it)
193+ for (const auto & edge : (post_dom?node.in :node.out ))
205194 {
206- worklist.push_back (cfg[s_it-> first ].PC );
195+ worklist.push_back (cfg[edge. first ].PC );
207196 }
208197 }
209198 }
@@ -224,21 +213,21 @@ Function: cfg_dominators_templatet::output
224213template <class P , class T , bool post_dom>
225214void cfg_dominators_templatet<P, T, post_dom>::output(std::ostream &out) const
226215{
227- for (typename cfgt::entry_mapt::const_iterator
228- it=cfg.entry_map .begin ();
229- it!=cfg.entry_map .end (); ++it)
216+ for (const auto &node : cfg.entry_map )
230217 {
231- unsigned n=it-> first ->location_number ;
218+ unsigned n=node. first ->location_number ;
232219
233220 if (post_dom)
234221 out << n << " post-dominated by " ;
235222 else
236223 out << n << " dominated by " ;
237- for (typename target_sett::const_iterator d_it=it->second .dominators .begin ();
238- d_it!=it->second .dominators .end ();)
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++
239228 {
240229 out << (*d_it)->location_number ;
241- if (++d_it!=it-> second .dominators .end ())
230+ if (++d_it!=node. second .dominators .end ())
242231 out << " , " ;
243232 }
244233 out << " \n " ;
0 commit comments