30 if(!ignore_labels && !it->labels.empty())
34 return !it->code.get_bool(ID_explicit);
38 if(it->guard.is_false())
49 return it->guard.is_true() &&
50 it->get_target()==next_it;
58 const irep_idt &statement=it->code.get_statement();
60 if(statement==ID_skip)
62 else if(statement==ID_expression)
66 if(expr.
id()==ID_typecast &&
67 expr.
type().
id()==ID_empty &&
100 typedef std::map<goto_programt::targett, goto_programt::targett>
102 new_targetst new_targets;
106 for(goto_programt::instructionst::iterator it =
begin; it !=
end;)
111 std::list<irep_idt> labels;
113 while(
is_skip(goto_program, it,
true))
118 it == std::prev(
end) ||
119 (std::next(it)->is_end_function() &&
120 (!labels.empty() || !it->labels.empty())))
126 labels.splice(labels.end(), it->labels);
133 it->labels.splice(it->labels.begin(), labels);
135 if(new_target!=old_target)
137 for(; old_target!=new_target; ++old_target)
138 new_targets[old_target]=new_target;
147 if(ins.is_goto() || ins.is_start_thread() || ins.is_catch())
149 for(
auto &target : ins.targets)
151 new_targetst::const_iterator result = new_targets.find(target);
153 if(result!=new_targets.end())
154 target = result->second;
159 while(new_targets.find(
begin) != new_targets.end())
164 for(
const auto &new_target : new_targets)
176 if(
is_skip(goto_program, last) && !last->is_target())
200 f_it->second.body.instructions.begin(),
201 f_it->second.body.instructions.end());
void update()
Update all indices.
bool is_skip(const goto_programt &body, goto_programt::const_targett it, bool ignore_labels)
Determine whether the instruction is semantically equivalent to a skip (no-op).
typet & type()
Return the type of the expression.
codet representation of an expression statement.
code_expressiont & to_code_expression(codet &code)
const irep_idt & id() const
instructionst::iterator targett
instructionst instructions
The list of instructions in the goto program.
instructionst::const_iterator const_targett
A collection of goto functions.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
virtual iteratort begin()=0
virtual iteratort end()=0
bool is_constant() const
Return whether the expression is a constant.
A generic container class for the GOTO intermediate representation of one function.
Base class for all expressions.
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
#define Forall_goto_functions(it, functions)
void compute_target_numbers()
Compute the target numbers.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const exprt & expression() const
goto_functionst goto_functions
GOTO functions.