30 if(expr.
id()==ID_side_effect &&
31 expr.
get(ID_statement)==ID_function_call)
48 if(statement==ID_assign)
52 if(result_is_used && !address_taken &&
needs_cleaning(old_assignment.lhs()))
54 if(!old_assignment.rhs().is_constant())
57 replacement_expr_opt = old_assignment.rhs();
63 code_assignt new_assignment(std::move(new_lhs), std::move(new_rhs));
68 else if(statement==ID_assign_plus ||
69 statement==ID_assign_minus ||
70 statement==ID_assign_mult ||
71 statement==ID_assign_div ||
72 statement==ID_assign_mod ||
73 statement==ID_assign_shl ||
74 statement==ID_assign_ashr ||
75 statement==ID_assign_lshr ||
76 statement==ID_assign_bitand ||
77 statement==ID_assign_bitxor ||
78 statement==ID_assign_bitor)
82 id2string(statement) +
" expects two arguments",
87 if(statement==ID_assign_plus)
89 else if(statement==ID_assign_minus)
91 else if(statement==ID_assign_mult)
93 else if(statement==ID_assign_div)
95 else if(statement==ID_assign_mod)
97 else if(statement==ID_assign_shl)
99 else if(statement==ID_assign_ashr)
101 else if(statement==ID_assign_lshr)
103 else if(statement==ID_assign_bitand)
105 else if(statement==ID_assign_bitxor)
107 else if(statement==ID_assign_bitor)
119 op0_type.
id() != ID_c_enum_tag && op0_type.
id() != ID_c_enum &&
120 op0_type.
id() != ID_c_bool && op0_type.
id() != ID_bool);
129 result_is_used && !address_taken &&
133 replacement_expr_opt = rhs;
142 convert(assignment, dest, mode);
148 if(replacement_expr_opt.has_value())
154 else if(result_is_used)
165 lhs.
id() == ID_typecast,
167 " expression with different operand type expected to have a "
171 id2string(expr.
id()) +
" type mismatch in lhs operand");
189 "preincrement/predecrement must have one operand",
195 statement == ID_preincrement || statement == ID_predecrement,
196 "expects preincrement or predecrement");
201 if(statement==ID_preincrement)
207 const typet &op_type = op.type();
210 op_type.
id() != ID_c_enum_tag && op_type.
id() != ID_c_enum &&
211 op_type.
id() != ID_c_bool && op_type.
id() != ID_bool);
215 if(op_type.
id() == ID_pointer)
218 constant_type = op_type;
226 if(constant_type.
id() == ID_complex)
236 rhs.
type() = op.type();
238 const bool cannot_use_lhs =
246 convert(assignment, dest, mode);
275 "postincrement/postdecrement must have one operand",
281 statement == ID_postincrement || statement == ID_postdecrement,
282 "expects postincrement or postdecrement");
287 if(statement==ID_postincrement)
293 const typet &op_type = op.type();
296 op_type.
id() != ID_c_enum_tag && op_type.
id() != ID_c_enum &&
297 op_type.
id() != ID_c_bool && op_type.
id() != ID_bool);
301 if(op_type.
id() == ID_pointer)
304 constant_type = op_type;
312 if(constant_type.
id() == ID_complex)
322 rhs.
type() = op.type();
327 convert(assignment, tmp2, mode);
360 std::string new_base_name =
"return_value";
371 new_symbol_mode = symbol.
mode;
403 if(dest.
id()==
"new_object")
446 tmp.
set(ID_destructor, expr.
find(ID_destructor));
493 "temporary_object takes zero or one operands",
504 convert(assignment, dest, mode);
511 "temporary_object takes zero operands",
513 exprt initializer=
static_cast<const exprt &
>(expr.
find(ID_initializer));
544 "statement_expression takes block as operand",
549 "statement_expression takes non-empty block as operand",
558 expr.
type(),
"statement_expression", dest, source_location, mode);
563 if(last.
get(ID_statement)==ID_expression)
570 else if(last.
get(ID_statement)==ID_assign)
575 code.
operands().push_back(assignment);
588 static_cast<exprt &
>(expr)=tmp_symbol_expr;
600 if(statement==ID_function_call)
603 else if(statement==ID_assign ||
604 statement==ID_assign_plus ||
605 statement==ID_assign_minus ||
606 statement==ID_assign_mult ||
607 statement==ID_assign_div ||
608 statement==ID_assign_bitor ||
609 statement==ID_assign_bitxor ||
610 statement==ID_assign_bitand ||
611 statement==ID_assign_lshr ||
612 statement==ID_assign_ashr ||
613 statement==ID_assign_shl ||
614 statement==ID_assign_mod)
616 else if(statement==ID_postincrement ||
617 statement==ID_postdecrement)
619 else if(statement==ID_preincrement ||
620 statement==ID_predecrement)
621 remove_pre(expr, dest, result_is_used, address_taken, mode);
622 else if(statement==ID_cpp_new ||
623 statement==ID_cpp_new_array)
625 else if(statement==ID_cpp_delete ||
626 statement==ID_cpp_delete_array)
628 else if(statement==ID_allocate)
630 else if(statement==ID_temporary_object)
632 else if(statement==ID_statement_expression)
634 else if(statement==ID_nondet)
638 else if(statement==ID_skip)
642 else if(statement==ID_throw)
bitvector_typet index_type()
A codet representing an assignment in the program.
codet & find_last_statement()
A codet representing the declaration of a local variable.
codet representation of an expression statement.
const exprt & expression() const
codet representation of a function call statement.
Data structure for representing an arbitrary statement in a program.
const irep_idt & get_statement() const
Complex constructor from a pair of numbers.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
source_locationt & add_source_location()
const source_locationt & source_location() const
typet & type()
Return the type of the expression.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
void remove_temporary_object(side_effect_exprt &expr, goto_programt &dest)
void remove_function_call(side_effect_expr_function_callt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
symbol_table_baset & symbol_table
void remove_pre(side_effect_exprt &expr, goto_programt &dest, bool result_is_used, bool address_taken, const irep_idt &mode)
void convert_assign(const code_assignt &code, goto_programt &dest, const irep_idt &mode)
void convert_decl(const code_declt &code, goto_programt &dest, const irep_idt &mode)
void remove_post(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_cpp_delete(side_effect_exprt &expr, goto_programt &dest)
std::string tmp_symbol_prefix
void remove_side_effect(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used, bool address_taken)
void convert_function_call(const code_function_callt &code, goto_programt &dest, const irep_idt &mode)
symbolt & new_tmp_symbol(const typet &type, const std::string &suffix, goto_programt &dest, const source_locationt &, const irep_idt &mode)
void remove_statement_expression(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
void convert_cpp_delete(const codet &code, goto_programt &dest)
static bool has_function_call(const exprt &expr)
static bool needs_cleaning(const exprt &expr)
void remove_assignment(side_effect_exprt &expr, goto_programt &dest, bool result_is_used, bool address_taken, const irep_idt &mode)
void convert(const codet &code, goto_programt &dest, const irep_idt &mode)
converts 'code' and appends the result to 'dest'
void remove_cpp_new(side_effect_exprt &expr, goto_programt &dest, bool result_is_used)
static void replace_new_object(const exprt &object, exprt &dest)
void make_temp_symbol(exprt &expr, const std::string &suffix, goto_programt &, const irep_idt &mode)
This class represents an instruction in the GOTO intermediate representation.
A generic container class for the GOTO intermediate representation of one function.
void destructive_append(goto_programt &p)
Appends the given program p to *this. p is destroyed.
targett add(instructiont &&instruction)
Adds a given instruction at the end.
void set(const irep_namet &name, const irep_idt &value)
const irept & find(const irep_namet &name) const
const irep_idt & id() const
const irep_idt & get(const irep_namet &name) const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
A side_effect_exprt representation of a function call side effect.
exprt::operandst & arguments()
A side_effect_exprt representation of a side effect that throws an exception.
An expression containing a side effect.
const irep_idt & get_statement() const
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
irep_idt base_name
Base (non-scoped) name.
source_locationt location
Source code location of definition of symbol.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt mode
Language mode.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
const typet & subtype() const
#define forall_operands(it, expr)
#define Forall_operands(it, expr)
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
Deprecated expression utility functions.
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, const namespacet &ns, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with respect to the given namespace ns with the requested name pattern ...
Fresh auxiliary symbol creation.
const std::string & id2string(const irep_idt &d)
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
nonstd::optional< T > optionalt
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
Same as invariant, with one or more diagnostics attached Diagnostics can be of any type that has a sp...
side_effect_expr_statement_expressiont & to_side_effect_expr_statement_expression(exprt &expr)
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
const codet & to_code(const exprt &expr)
side_effect_expr_assignt & to_side_effect_expr_assign(exprt &expr)
code_expressiont & to_code_expression(codet &code)
const code_blockt & to_code_block(const codet &code)
const code_assignt & to_code_assign(const codet &code)
API to expression classes.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.