Go to the documentation of this file.
30 if(expr.
id()==ID_side_effect &&
31 expr.
get(ID_statement)==ID_function_call)
45 if(statement==ID_assign)
51 code_assignt new_assignment(std::move(new_lhs), std::move(new_rhs));
56 else if(statement==ID_assign_plus ||
57 statement==ID_assign_minus ||
58 statement==ID_assign_mult ||
59 statement==ID_assign_div ||
60 statement==ID_assign_mod ||
61 statement==ID_assign_shl ||
62 statement==ID_assign_ashr ||
63 statement==ID_assign_lshr ||
64 statement==ID_assign_bitand ||
65 statement==ID_assign_bitxor ||
66 statement==ID_assign_bitor)
70 id2string(statement) +
" expects two arguments",
75 if(statement==ID_assign_plus)
77 else if(statement==ID_assign_minus)
79 else if(statement==ID_assign_mult)
81 else if(statement==ID_assign_div)
83 else if(statement==ID_assign_mod)
85 else if(statement==ID_assign_shl)
87 else if(statement==ID_assign_ashr)
89 else if(statement==ID_assign_lshr)
91 else if(statement==ID_assign_bitand)
93 else if(statement==ID_assign_bitxor)
95 else if(statement==ID_assign_bitor)
107 op0_type.
id() != ID_c_enum_tag && op0_type.
id() != ID_c_enum &&
108 op0_type.
id() != ID_c_bool && op0_type.
id() != ID_bool);
123 convert(assignment, dest, mode);
147 "preincrement/predecrement must have one operand",
153 statement == ID_preincrement || statement == ID_predecrement,
154 "expects preincrement or predecrement");
159 if(statement==ID_preincrement)
165 const typet &op_type = op.type();
168 op_type.
id() != ID_c_enum_tag && op_type.
id() != ID_c_enum &&
169 op_type.
id() != ID_c_bool && op_type.
id() != ID_bool);
173 if(op_type.
id() == ID_pointer)
176 constant_type = op_type;
184 if(constant_type.
id() == ID_complex)
194 rhs.
type() = op.type();
199 convert(assignment, dest, mode);
223 "postincrement/postdecrement must have one operand",
229 statement == ID_postincrement || statement == ID_postdecrement,
230 "expects postincrement or postdecrement");
235 if(statement==ID_postincrement)
241 const typet &op_type = op.type();
244 op_type.
id() != ID_c_enum_tag && op_type.
id() != ID_c_enum &&
245 op_type.
id() != ID_c_bool && op_type.
id() != ID_bool);
249 if(op_type.
id() == ID_pointer)
252 constant_type = op_type;
260 if(constant_type.
id() == ID_complex)
270 rhs.
type() = op.type();
275 convert(assignment, tmp2, mode);
308 std::string new_base_name =
"return_value";
319 new_symbol_mode = symbol.
mode;
351 if(dest.
id()==
"new_object")
394 tmp.
set(ID_destructor, expr.
find(ID_destructor));
441 "temporary_object takes zero or one operands",
452 convert(assignment, dest, mode);
459 "temporary_object takes zero operands",
461 exprt initializer=
static_cast<const exprt &
>(expr.
find(ID_initializer));
492 "statement_expression takes block as operand",
497 "statement_expression takes non-empty block as operand",
506 expr.
type(),
"statement_expression", dest, source_location, mode);
511 if(last.
get(ID_statement)==ID_expression)
518 else if(last.
get(ID_statement)==ID_assign)
523 code.
operands().push_back(assignment);
536 static_cast<exprt &
>(expr)=tmp_symbol_expr;
547 if(statement==ID_function_call)
550 else if(statement==ID_assign ||
551 statement==ID_assign_plus ||
552 statement==ID_assign_minus ||
553 statement==ID_assign_mult ||
554 statement==ID_assign_div ||
555 statement==ID_assign_bitor ||
556 statement==ID_assign_bitxor ||
557 statement==ID_assign_bitand ||
558 statement==ID_assign_lshr ||
559 statement==ID_assign_ashr ||
560 statement==ID_assign_shl ||
561 statement==ID_assign_mod)
563 else if(statement==ID_postincrement ||
564 statement==ID_postdecrement)
566 else if(statement==ID_preincrement ||
567 statement==ID_predecrement)
569 else if(statement==ID_cpp_new ||
570 statement==ID_cpp_new_array)
572 else if(statement==ID_cpp_delete ||
573 statement==ID_cpp_delete_array)
575 else if(statement==ID_allocate)
577 else if(statement==ID_temporary_object)
579 else if(statement==ID_statement_expression)
581 else if(statement==ID_nondet)
585 else if(statement==ID_skip)
589 else if(statement==ID_throw)
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
#define UNREACHABLE
This should be used to mark dead code.
void convert_function_call(const code_function_callt &code, goto_programt &dest, const irep_idt &mode)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
static exprt conditional_cast(const exprt &expr, const typet &type)
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
code_expressiont & to_code_expression(codet &code)
const typet & subtype() const
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
#define Forall_operands(it, expr)
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
static void replace_new_object(const exprt &object, exprt &dest)
void convert(const codet &code, goto_programt &dest, const irep_idt &mode)
converts 'code' and appends the result to 'dest'
The type of an expression, extends irept.
Fresh auxiliary symbol creation.
typet type
Type of symbol.
static bool has_function_call(const exprt &expr)
A side_effect_exprt representation of a function call side effect.
std::string tmp_symbol_prefix
const irept & find(const irep_namet &name) const
A codet representing the declaration of a local variable.
targett add(instructiont &&instruction)
Adds a given instruction at the end.
void remove_pre(side_effect_exprt &expr, goto_programt &dest, bool result_is_used, const irep_idt &mode)
void remove_function_call(side_effect_expr_function_callt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
void remove_side_effect(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
Expression to hold a symbol (variable)
bitvector_typet index_type()
side_effect_expr_statement_expressiont & to_side_effect_expr_statement_expression(exprt &expr)
symbolt & new_tmp_symbol(const typet &type, const std::string &suffix, goto_programt &dest, const source_locationt &, const irep_idt &mode)
const codet & to_code(const exprt &expr)
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
#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...
typet & type()
Return the type of the expression.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
codet representation of a function call statement.
irep_idt mode
Language mode.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const std::string & id2string(const irep_idt &d)
#define forall_operands(it, expr)
#define PRECONDITION(CONDITION)
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
const irep_idt & get_identifier() const
void remove_statement_expression(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
void remove_malloc(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
void remove_cpp_new(side_effect_exprt &expr, goto_programt &dest, bool result_is_used)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
Complex constructor from a pair of numbers.
void remove_cpp_delete(side_effect_exprt &expr, goto_programt &dest)
void remove_post(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used)
void convert_decl(const code_declt &code, goto_programt &dest, const irep_idt &mode)
void convert_assign(const code_assignt &code, goto_programt &dest, const irep_idt &mode)
side_effect_expr_assignt & to_side_effect_expr_assign(exprt &expr)
const irep_idt & get_statement() const
void destructive_append(goto_programt &p)
Appends the given program p to *this. p is destroyed.
Deprecated expression utility functions.
void remove_temporary_object(side_effect_exprt &expr, goto_programt &dest)
const code_assignt & to_code_assign(const codet &code)
const irep_idt & get(const irep_namet &name) const
source_locationt location
Source code location of definition of symbol.
void remove_assignment(side_effect_exprt &expr, goto_programt &dest, bool result_is_used, const irep_idt &mode)
void set(const irep_namet &name, const irep_idt &value)
exprt::operandst & arguments()
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
A generic container class for the GOTO intermediate representation of one function.
A side_effect_exprt representation of a side effect that throws an exception.
symbol_table_baset & symbol_table
const code_blockt & to_code_block(const codet &code)
void convert_cpp_delete(const codet &code, goto_programt &dest)
const exprt & expression() const
codet & find_last_statement()
source_locationt & add_source_location()
A codet representing an assignment in the program.
const irep_idt & get_statement() const
This class represents an instruction in the GOTO intermediate representation.
API to expression classes.
const source_locationt & source_location() const
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 ...
irep_idt name
The unique identifier.
An expression containing a side effect.
codet representation of an expression statement.
Data structure for representing an arbitrary statement in a program.
void make_temp_symbol(exprt &expr, const std::string &suffix, goto_programt &, const irep_idt &mode)