@@ -60,10 +60,11 @@ Author: Diffblue Ltd
6060// / * [function] is_backwards_goto() returning a bool.
6161// / * [function] get_target() which returns an object that needs:
6262// / * [field] location_number which is an unsigned int.
63- template <class P , class T >
64- class lexical_loops_templatet : public loop_analysist <T>
63+ // / \tparam C: comparison to use over `T` typed elements
64+ template <class P , class T , typename C>
65+ class lexical_loops_templatet : public loop_analysist <T, C>
6566{
66- typedef loop_analysist<T> parentt;
67+ typedef loop_analysist<T, C > parentt;
6768
6869public:
6970 typedef typename parentt::loopt lexical_loopt;
@@ -103,16 +104,17 @@ class lexical_loops_templatet : public loop_analysist<T>
103104
104105typedef lexical_loops_templatet<
105106 const goto_programt,
106- goto_programt::const_targett>
107+ goto_programt::const_targett,
108+ goto_programt::target_less_than>
107109 lexical_loopst;
108110
109111#ifdef DEBUG
110112# include < iostream>
111113#endif
112114
113115// / Finds all back-edges and computes the lexical loops
114- template <class P , class T >
115- void lexical_loops_templatet<P, T>::compute(P &program)
116+ template <class P , class T , typename C >
117+ void lexical_loops_templatet<P, T, C >::compute(P &program)
116118{
117119 all_in_lexical_loop_form = true ;
118120
@@ -142,8 +144,8 @@ void lexical_loops_templatet<P, T>::compute(P &program)
142144// / the tail, abandoning the candidate loop if we stray outside the bounds of
143145// / the lexical region bounded by the head and tail, otherwise recording all
144146// / instructions that can reach the backedge as falling within the loop.
145- template <class P , class T >
146- bool lexical_loops_templatet<P, T>::compute_lexical_loop(
147+ template <class P , class T , typename C >
148+ bool lexical_loops_templatet<P, T, C >::compute_lexical_loop(
147149 T loop_tail,
148150 T loop_head)
149151{
@@ -152,7 +154,7 @@ bool lexical_loops_templatet<P, T>::compute_lexical_loop(
152154 " loop header should come lexically before the tail" );
153155
154156 std::stack<T> stack;
155- std::set<T> loop_instructions;
157+ std::set<T, C > loop_instructions;
156158
157159 loop_instructions.insert (loop_head);
158160 loop_instructions.insert (loop_tail);
0 commit comments