Go to the documentation of this file.
35 new_symbol.
value=expr;
41 result.add_source_location()=source_location;
50 convert(code_assign, dest, mode);
70 expr.
id() == ID_side_effect || expr.
id() == ID_compound_literal ||
71 expr.
id() == ID_comma)
90 if(expr.
id()==ID_forall || expr.
id()==ID_exists)
104 expr.
id() == ID_and || expr.
id() == ID_or || expr.
id() == ID_implies);
110 "' must be Boolean, but got ",
114 if(
auto implies = expr_try_dynamic_cast<implies_exprt>(expr))
116 expr =
if_exprt{std::move(implies->lhs()),
117 std::move(implies->rhs()),
128 if(expr.
id()==ID_and)
136 for(exprt::operandst::reverse_iterator
145 "boolean operators must have only boolean operands",
148 if(expr.
id()==ID_and)
154 if(expr.
id() == ID_or)
183 if(expr.
id() == ID_and || expr.
id() == ID_or || expr.
id() == ID_implies)
192 else if(expr.
id()==ID_if)
207 "condition for an 'if' must be boolean",
248 convert(assignment_true, tmp_true, mode);
254 convert(assignment_false, tmp_false, mode);
268 convert(code_expression, tmp_true, mode);
277 convert(code_expression, tmp_false, mode);
285 if_expr.
cond(), tmp_true, tmp_false, source_location, dest, mode);
289 else if(expr.
id()==ID_comma)
297 bool last=(it==--expr.
operands().end());
333 else if(expr.
id()==ID_typecast)
345 else if(expr.
id()==ID_side_effect)
350 if(statement==ID_gcc_conditional_expression)
356 else if(statement==ID_statement_expression)
364 else if(statement==ID_assign)
369 "side-effect assignment expressions must have two operands");
374 side_effect_assign.rhs().id() == ID_side_effect &&
378 clean_expr(side_effect_assign.lhs(), dest, mode);
379 exprt lhs = side_effect_assign.lhs();
394 side_effect_assign.rhs(), new_lhs.
type());
395 code_assignt assignment(std::move(new_lhs), std::move(new_rhs));
400 expr = must_use_rhs ? side_effect_assign.rhs() : lhs;
407 else if(expr.
id()==ID_forall || expr.
id()==ID_exists)
411 "the front-end should check quantified expressions for side-effects");
413 else if(expr.
id()==ID_address_of)
425 if(expr.
id()==ID_side_effect)
430 else if(expr.
id()==ID_compound_literal)
434 expr.
operands().size() == 1,
"ID_compound_literal has a single operand");
447 if(expr.
id()==ID_compound_literal)
450 expr.
operands().size() == 1,
"ID_compound_literal has a single operand");
454 else if(expr.
id()==ID_string_constant)
459 else if(expr.
id()==ID_index)
465 else if(expr.
id()==ID_dereference)
470 else if(expr.
id()==ID_comma)
479 bool last=(it==--expr.
operands().end());
499 else if(expr.
id() == ID_side_effect)
#define UNREACHABLE
This should be used to mark dead code.
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.
static bool needs_cleaning(const exprt &expr)
Returns 'true' for expressions that may change the program state.
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)
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
#define Forall_operands(it, expr)
@ AUTOMATIC_LOCAL
Allocate local objects with automatic lifetime.
void convert(const codet &code, goto_programt &dest, const irep_idt &mode)
converts 'code' and appends the result to 'dest'
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
void copy(const codet &code, goto_program_instruction_typet type, goto_programt &dest)
void clean_expr(exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used=true)
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Operator to dereference a pointer.
void remove_gcc_conditional_expression(exprt &expr, goto_programt &dest, const irep_idt &mode)
The trinary if-then-else operator.
std::string tmp_symbol_prefix
A goto_instruction_codet representing the declaration of a local variable.
void generate_ifthenelse(const exprt &cond, goto_programt &true_case, goto_programt &false_case, const source_locationt &, goto_programt &dest, const irep_idt &mode)
if(guard) true_case; else false_case;
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.
void clean_expr_address_of(exprt &expr, goto_programt &dest, const irep_idt &mode)
bool is_true() const
Return whether the expression is a constant representing true.
side_effect_exprt & to_side_effect_expr(exprt &expr)
Expression to hold a symbol (variable)
symbolt & new_tmp_symbol(const typet &type, const std::string &suffix, goto_programt &dest, const source_locationt &, const irep_idt &mode)
bool is_false() const
Return whether the expression is a constant representing false.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
typet & type()
Return the type of the expression.
struct goto_convertt::targetst targets
void add(const codet &destructor)
Adds a destructor to the current stack, attaching itself to the current node.
mstreamt & result() const
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define forall_operands(it, expr)
void rewrite_boolean(exprt &dest)
re-write boolean operators into ?:
#define PRECONDITION(CONDITION)
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
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.
bool simplify(exprt &expr, const namespacet &ns)
symbol_exprt make_compound_literal(const exprt &expr, goto_programt &dest, const irep_idt &mode)
const irep_idt & id() const
std::vector< exprt > operandst
The Boolean constant false.
A goto_instruction_codet representing the removal of a local variable going out of scope.
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
Deprecated expression utility functions.
exprt value
Initial value of symbol.
destructor_treet destructor_stack
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
#define PRECONDITION_WITH_DIAGNOSTICS(CONDITION,...)
A generic container class for the GOTO intermediate representation of one function.
void remove_side_effect(side_effect_exprt &expr, goto_programt &dest, const irep_idt &mode, bool result_is_used, bool address_taken)
symbol_table_baset & symbol_table
static bool assignment_lhs_needs_temporary(const exprt &lhs)
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Operator to return the address of an object.
source_locationt & add_source_location()
Semantic type conversion.
A goto_instruction_codet representing an assignment in the program.
The Boolean constant true.
bool is_boolean() const
Return whether the expression represents a Boolean.
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 ...
codet representation of an expression statement.