14 static bool is_skip(goto_programt::instructionst::iterator it)
19 if(!it->labels.empty())
23 return !it->code.get_bool(ID_explicit);
27 if(it->guard.is_false())
30 if(it->targets.size()!=1)
33 goto_programt::instructionst::iterator next_it=it;
38 return it->guard.is_true() &&
39 it->targets.front()==next_it;
47 const irep_idt &statement=it->code.get_statement();
49 if(statement==ID_skip)
51 else if(statement==ID_expression)
55 if(expr.
id()==ID_typecast &&
56 expr.
type().
id()==ID_empty &&
82 typedef std::map<goto_programt::targett, goto_programt::targett>
84 new_targetst new_targets;
88 for(goto_programt::instructionst::iterator
95 std::list<irep_idt> labels;
105 labels.splice(labels.end(), it->labels);
112 it->labels.splice(it->labels.begin(), labels);
114 if(new_target!=old_target)
116 for(; old_target!=new_target; ++old_target)
117 new_targets[old_target]=new_target;
126 if(i_it->is_goto() || i_it->is_start_thread() || i_it->is_catch())
128 for(goto_programt::instructiont::targetst::iterator
129 t_it=i_it->targets.begin();
130 t_it!=i_it->targets.end();
133 new_targetst::const_iterator
134 result=new_targets.find(*t_it);
136 if(result!=new_targets.end())
137 *t_it=result->second;
143 for(
const auto &new_target : new_targets)
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast a generic exprt to a typecast_exprt.
instructionst instructions
The list of instructions in the goto program.
code_expressiont & to_code_expression(codet &code)
void compute_incoming_edges()
const irep_idt & id() const
A specialization of goto_program_templatet over goto programs in which instructions have codet type...
void remove_skip(goto_programt &goto_program)
remove unnecessary skip statements
Base class for all expressions.
#define Forall_goto_functions(it, functions)
const exprt & expression() const
#define Forall_goto_program_instructions(it, program)
static bool is_skip(goto_programt::instructionst::iterator it)
instructionst::iterator targett