29 if(expr.
id()==ID_side_effect &&
30 expr.
get(ID_statement)==ID_function_call)
44 if(statement==ID_assign)
51 else if(statement==ID_assign_plus ||
52 statement==ID_assign_minus ||
53 statement==ID_assign_mult ||
54 statement==ID_assign_div ||
55 statement==ID_assign_mod ||
56 statement==ID_assign_shl ||
57 statement==ID_assign_ashr ||
58 statement==ID_assign_lshr ||
59 statement==ID_assign_bitand ||
60 statement==ID_assign_bitxor ||
61 statement==ID_assign_bitor)
66 error() << statement <<
" takes two arguments" <<
eom;
72 if(statement==ID_assign_plus)
74 else if(statement==ID_assign_minus)
76 else if(statement==ID_assign_mult)
78 else if(statement==ID_assign_div)
80 else if(statement==ID_assign_mod)
82 else if(statement==ID_assign_shl)
84 else if(statement==ID_assign_ashr)
86 else if(statement==ID_assign_lshr)
88 else if(statement==ID_assign_bitand)
90 else if(statement==ID_assign_bitxor)
92 else if(statement==ID_assign_bitor)
97 error() <<
"assignment `" << statement <<
"' not yet supported" 107 if(op0_type.
id()==ID_c_bool)
124 convert(assignment, dest, mode);
149 error() <<
"preincrement/predecrement must have one operand" <<
eom;
155 assert(statement==ID_preincrement ||
156 statement==ID_predecrement);
161 if(statement==ID_preincrement)
168 if(op_type.
id()==ID_bool)
175 else if(op_type.
id()==ID_c_bool)
183 else if(op_type.
id()==ID_c_enum ||
184 op_type.
id()==ID_c_enum_tag)
195 if(op_type.
id()==ID_pointer)
197 else if(
is_number(op_type) || op_type.
id()==ID_c_bool)
198 constant_type=op_type;
216 convert(assignment, dest, mode);
241 error() <<
"postincrement/postdecrement must have one operand" 248 assert(statement==ID_postincrement ||
249 statement==ID_postdecrement);
254 if(statement==ID_postincrement)
261 if(op_type.
id()==ID_bool)
268 else if(op_type.
id()==ID_c_bool)
276 else if(op_type.
id()==ID_c_enum ||
277 op_type.
id()==ID_c_enum_tag)
288 if(op_type.
id()==ID_pointer)
290 else if(
is_number(op_type) || op_type.
id()==ID_c_bool)
291 constant_type=op_type;
301 if(constant_type.
id()==ID_complex)
318 convert(assignment, tmp2, mode);
356 if(expr.
id()!=ID_side_effect ||
357 expr.
get(ID_statement)!=ID_function_call)
360 error() <<
"expected function call" <<
eom;
367 error() <<
"function_call expects at least one operand" <<
eom;
371 std::string new_base_name =
"return_value";
374 if(expr.
op0().
id()==ID_symbol)
381 new_symbol_mode = symbol.
mode;
415 if(dest.
id()==
"new_object")
457 tmp.copy_to_operands(expr.
op0());
458 tmp.
set(ID_destructor, expr.
find(ID_destructor));
494 call=
codet(ID_expression);
510 error() <<
"temporary_object takes 0 or 1 operands" <<
eom;
521 convert(assignment, dest, mode);
527 exprt initializer=
static_cast<const exprt &
>(expr.
find(ID_initializer));
550 error() <<
"statement_expression takes 1 operand" <<
eom;
554 if(expr.
op0().
id()!=ID_code)
557 error() <<
"statement_expression takes code as operand" <<
eom;
573 error() <<
"statement_expression takes block as operand" <<
eom;
580 error() <<
"statement_expression takes non-empty block as operand" 591 expr.
type(),
"statement_expression", dest, source_location, mode);
594 tmp_symbol_expr.add_source_location()=source_location;
596 if(last.
get(ID_statement)==ID_expression)
603 else if(last.
get(ID_statement)==ID_assign)
608 code.
operands().push_back(assignment);
612 error() <<
"statement_expression expects expression as " 613 <<
"last statement, but got `" 614 << last.
get(ID_statement) <<
"'" <<
eom;
624 static_cast<exprt &
>(expr)=tmp_symbol_expr;
635 if(statement==ID_function_call)
637 else if(statement==ID_assign ||
638 statement==ID_assign_plus ||
639 statement==ID_assign_minus ||
640 statement==ID_assign_mult ||
641 statement==ID_assign_div ||
642 statement==ID_assign_bitor ||
643 statement==ID_assign_bitxor ||
644 statement==ID_assign_bitand ||
645 statement==ID_assign_lshr ||
646 statement==ID_assign_ashr ||
647 statement==ID_assign_shl ||
648 statement==ID_assign_mod)
650 else if(statement==ID_postincrement ||
651 statement==ID_postdecrement)
653 else if(statement==ID_preincrement ||
654 statement==ID_predecrement)
656 else if(statement==ID_cpp_new ||
657 statement==ID_cpp_new_array)
659 else if(statement==ID_cpp_delete ||
660 statement==ID_cpp_delete_array)
662 else if(statement==ID_allocate)
664 else if(statement==ID_temporary_object)
666 else if(statement==ID_statement_expression)
668 else if(statement==ID_nondet)
672 else if(statement==ID_skip)
676 else if(statement==ID_throw)
682 t->code.op0().operands().swap(expr.
operands());
692 error() <<
"cannot remove side effect (" << statement <<
")" <<
eom;
const irep_idt & get_statement() const
The type of an expression.
irep_idt name
The unique identifier.
const std::string & id2string(const irep_idt &d)
void remove_function_call(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
void remove_malloc(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
void remove_pre(side_effect_exprt &expr, goto_programt &dest, bool result_is_used, const irep_idt &mode)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
irep_idt mode
Language mode.
void convert(const codet &code, goto_programt &dest, const irep_idt &mode)
converts 'code' and appends the result to 'dest'
Deprecated expression utility functions.
void copy_to_operands(const exprt &expr)
void move_to_operands(exprt &expr)
Fresh auxiliary symbol creation.
void destructive_append(goto_programt &p)
Appends the given program, which is destroyed.
void remove_temporary_object(side_effect_exprt &expr, goto_programt &dest)
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
static mstreamt & eom(mstreamt &m)
code_expressiont & to_code_expression(codet &code)
A side effect that throws an exception.
static bool has_function_call(const exprt &expr)
const code_assignt & to_code_assign(const codet &code)
const irep_idt & id() const
class symbol_exprt symbol_expr() const
produces a symbol_exprt for a symbol
void convert_decl(const code_declt &code, goto_programt &dest, const irep_idt &mode)
exprt is_not_zero(const exprt &src, const namespacet &ns)
converts a scalar/float expression to C/C++ Booleans
std::string tmp_symbol_prefix
A generic base class for binary expressions.
instructionst::iterator targett
A declaration of a local variable.
const source_locationt & find_source_location() const
source_locationt source_location
void convert_function_call(const code_function_callt &code, goto_programt &dest, const irep_idt &mode)
API to expression classes.
const irep_idt & get(const irep_namet &name) const
void remove_cpp_new(side_effect_exprt &expr, goto_programt &dest, bool result_is_used)
void convert_assign(const code_assignt &code, goto_programt &dest, const irep_idt &mode)
#define forall_operands(it, expr)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
void remove_cpp_delete(side_effect_exprt &expr, goto_programt &dest)
const typet & follow(const typet &) const
bitvector_typet index_type()
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
codet & find_last_statement()
void convert_cpp_delete(const codet &code, goto_programt &dest)
void remove_assignment(side_effect_exprt &expr, goto_programt &dest, bool result_is_used, const irep_idt &mode)
A generic container class for the GOTO intermediate representation of one function.
void remove_post(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
void remove_statement_expression(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
typet type
Type of symbol.
source_locationt location
Source code location of definition of symbol.
bool is_number(const typet &type)
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with the requested name pattern.
targett add_instruction()
Adds an instruction at the end.
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
const source_locationt & source_location() const
symbolt & new_tmp_symbol(const typet &type, const std::string &suffix, goto_programt &dest, const source_locationt &, const irep_idt &mode)
const exprt & expression() const
const complex_typet & to_complex_type(const typet &type)
Cast a generic typet to a complex_typet.
symbol_table_baset & symbol_table
#define Forall_operands(it, expr)
source_locationt & add_source_location()
void remove_side_effect(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
const codet & to_code(const exprt &expr)
Expression to hold a symbol (variable)
const code_blockt & to_code_block(const codet &code)
A statement in a programming language.
signedbv_typet signed_int_type()
void make_temp_symbol(exprt &expr, const std::string &suffix, goto_programt &, const irep_idt &mode)
const typet & subtype() const
An expression containing a side effect.
void make_typecast(const typet &_type)
static void replace_new_object(const exprt &object, exprt &dest)
const irept & find(const irep_namet &name) const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
complex constructor from a pair of numbers
void set(const irep_namet &name, const irep_idt &value)
const irep_idt & get_statement() const