@@ -7,6 +7,12 @@ Author: Daniel Kroening, kroening@kroening.com
77
88\*******************************************************************/
99
10+ // #define DEBUG
11+
12+ #ifdef DEBUG
13+ #include < iostream>
14+ #endif
15+
1016#include < util/std_expr.h>
1117#include < util/string_utils.h>
1218#include < goto-programs/goto_functions.h>
@@ -312,7 +318,7 @@ void goto_unwindt::unwind(
312318
313319 goto_programt::const_targett t=i_it->get_target ();
314320
315- if (t->location_number >=loop_head->location_number ||
321+ if (t->location_number >=loop_head->location_number &&
316322 t->location_number <loop_exit->location_number )
317323 {
318324 i_it->set_target (t_skip);
@@ -385,10 +391,21 @@ void goto_unwindt::unwind(
385391{
386392 assert (k>=-1 );
387393
388- forall_goto_program_instructions (i_it, goto_program)
394+ for (goto_programt::const_targett i_it=goto_program.instructions .begin ();
395+ i_it!=goto_program.instructions .end ();)
389396 {
397+ #ifdef DEBUG
398+ symbol_tablet st;
399+ namespacet ns (st);
400+ std::cout << " Instruction:\n " ;
401+ goto_program.output_instruction (ns, " " , std::cout, i_it);
402+ #endif
403+
390404 if (!i_it->is_backwards_goto ())
405+ {
406+ i_it++;
391407 continue ;
408+ }
392409
393410 const irep_idt func=i_it->function ;
394411 assert (!func.empty ());
@@ -398,7 +415,10 @@ void goto_unwindt::unwind(
398415 int final_k=get_k (func, loop_number, k, unwind_set);
399416
400417 if (final_k==-1 )
418+ {
419+ i_it++;
401420 continue ;
421+ }
402422
403423 goto_programt::const_targett loop_head=i_it->get_target ();
404424 goto_programt::const_targett loop_exit=i_it;
@@ -409,7 +429,6 @@ void goto_unwindt::unwind(
409429
410430 // necessary as we change the goto program in the previous line
411431 i_it=loop_exit;
412- i_it--; // as for loop first increments
413432 }
414433}
415434
@@ -440,6 +459,10 @@ void goto_unwindt::operator()(
440459 if (!goto_function.body_available ())
441460 continue ;
442461
462+ #ifdef DEBUG
463+ std::cout << " Function: " << it->first << std::endl;
464+ #endif
465+
443466 goto_programt &goto_program=goto_function.body ;
444467
445468 unwind (goto_program, unwind_set, k, unwind_strategy);
0 commit comments