61 if(t->has_condition())
64 checked.insert(t->location_number);
92 for(
const auto &op : expr.
operands())
99 if(expr.
id()==ID_typecast)
103 if(typecast_expr.op().is_constant())
106 const typet &old_type = typecast_expr.op().type();
110 if(type.
id()==ID_signedbv)
112 if(old_type.
id()==ID_signedbv)
115 if(new_width >= old_width)
131 else if(old_type.
id()==ID_unsignedbv)
134 if(new_width >= old_width + 1)
146 else if(type.
id()==ID_unsignedbv)
148 if(old_type.
id()==ID_signedbv)
153 if(new_width < old_width - 1)
162 else if(old_type.
id()==ID_unsignedbv)
165 if(new_width>=old_width)
178 else if(expr.
id()==ID_div)
183 if(type.
id()==ID_signedbv)
189 cases.insert(
and_exprt(int_min_eq, minus_one_eq));
192 else if(expr.
id()==ID_unary_minus)
194 if(type.
id()==ID_signedbv)
203 else if(expr.
id()==ID_plus ||
204 expr.
id()==ID_minus ||
209 for(std::size_t i = 1; i < expr.
operands().size(); i++)
227 cases.insert(overflow);
240 for(expr_sett::iterator it=cases.begin();
280 assignment->swap(*t);
282 added.push_back(assignment);
API to expression classes for bitvectors.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
A base class for binary expressions.
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
A base class for relations, i.e., binary predicates whose two operands have the same type.
std::size_t get_width() const
A goto_instruction_codet representing an assignment in the program.
Base class for all expressions.
typet & type()
Return the type of the expression.
The Boolean constant false.
instructionst instructions
The list of instructions in the goto program.
instructionst::iterator targett
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
targett insert_after(const_targett target)
Insertion after the instruction pointed-to by the given instruction iterator target.
void compute_location_numbers(unsigned &nr)
Compute location numbers.
targett insert_before(const_targett target)
Insertion before the instruction pointed-to by the given instruction iterator target.
std::list< targett > targetst
const irep_idt & id() const
void add_overflow_checks()
std::set< unsigned > checked
void fix_types(binary_exprt &overflow)
void accumulate_overflow(goto_programt::targett t, const exprt &expr, goto_programt::targetst &added)
const exprt & overflow_var
void overflow_expr(const exprt &expr, expr_sett &cases)
Semantic type conversion.
The type of an expression, extends irept.
std::unordered_set< exprt, irep_hash > expr_sett
#define Forall_goto_program_instructions(it, program)
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
typet join_types(const typet &t1, const typet &t2)
Return the smallest type that both t1 and t2 can be cast to without losing information.