12 #include <unordered_set> 25 if(expr.
id() == ID_index)
27 else if(expr.
id() == ID_member)
29 else if(expr.
id() == ID_dereference)
31 else if(expr.
id() == ID_symbol)
40 if(operands.size()<=2)
46 exprt previous=operands.front();
49 for(exprt::operandst::const_iterator
50 it=++operands.begin();
58 tmp.operands().resize(2);
79 if(it->id()==ID_index_designator)
83 else if(it->id()==ID_member_designator)
107 const typet &src_type=
108 src.
type().
id()==ID_c_enum_tag?
112 if(src_type.
id()==ID_bool)
116 src_type.
id()==ID_floatbv?ID_ieee_float_notequal:ID_notequal;
124 return std::move(comparison);
129 if(src.
id() == ID_not)
141 const std::function<
bool(
const exprt &)> &pred)
150 src, [&](
const exprt &subexpr) {
return subexpr.
id() == id; });
155 const std::function<
bool(
const typet &)> &pred,
158 std::vector<std::reference_wrapper<const typet>>
stack;
159 std::unordered_set<typet, irep_hash> visited;
161 const auto push_if_not_visited = [&](
const typet &t) {
162 if(visited.insert(t).second)
163 stack.emplace_back(t);
166 push_if_not_visited(type);
167 while(!
stack.empty())
174 else if(top.
id() == ID_symbol)
175 push_if_not_visited(ns.
follow(top));
176 else if(top.
id() == ID_c_enum_tag)
178 else if(top.
id() == ID_struct || top.
id() == ID_union)
181 push_if_not_visited(comp.type());
186 push_if_not_visited(subtype);
196 type, [&](
const typet &subtype) {
return subtype.
id() == id; }, ns);
205 const exprt true_case=if_expr.true_case();
206 const exprt false_case=if_expr.false_case();
209 result.
cond()=if_expr.cond();
221 if(expr.
id()!=ID_typecast)
234 if(expr.
id() == ID_address_of)
239 expr.
id() == ID_typecast || expr.
id() == ID_array_of ||
240 expr.
id() == ID_plus || expr.
id() == ID_mult || expr.
id() == ID_array ||
241 expr.
id() == ID_with || expr.
id() == ID_struct || expr.
id() == ID_union ||
243 expr.
id() == ID_byte_update_big_endian ||
244 expr.
id() == ID_byte_update_little_endian)
258 if(expr.
id() == ID_symbol)
262 else if(expr.
id() == ID_index)
269 else if(expr.
id() == ID_member)
273 else if(expr.
id() == ID_string_constant)
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
The type of an expression, extends irept.
const type_with_subtypest & to_type_with_subtypes(const typet &type)
Operator to update elements in structs and arrays.
bool has_subtype(const typet &type, const std::function< bool(const typet &)> &pred, const namespacet &ns)
returns true if any of the contained types satisfies pred
Deprecated expression utility functions.
#define forall_expr(it, expr)
exprt::operandst & designator()
bool is_false() const
Return whether the expression is a constant representing false.
const componentst & components() const
The trinary if-then-else operator.
bool is_true() const
Return whether the expression is a constant representing true.
typet & type()
Return the type of the expression.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
depth_iteratort depth_begin()
#define CHECK_RETURN(CONDITION)
Forward depth-first search iterators These iterators' copy operations are expensive,...
const typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
bool is_lvalue(const exprt &expr)
Returns true iff the argument is (syntactically) an lvalue.
const exprt & compound() const
const irep_idt & id() const
virtual bool is_constant(const exprt &) const
This function determines what expressions are to be propagated as "constants".
The Boolean constant true.
exprt is_not_zero(const exprt &src, const namespacet &ns)
converts a scalar/float expression to C/C++ Booleans
A base class for binary expressions.
virtual bool is_constant_address_of(const exprt &) const
this function determines which reference-typed expressions are constant
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
API to expression classes.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
with_exprt make_with_expr(const update_exprt &src)
converts an update expr into a (possibly nested) with expression
#define PRECONDITION(CONDITION)
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const index_designatort & to_index_designator(const exprt &expr)
Cast an exprt to an index_designatort.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
const exprt & index() const
The Boolean constant false.
bool is_constant() const
Return whether the expression is a constant.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
std::vector< exprt > operandst
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
if_exprt lift_if(const exprt &src, std::size_t operand_number)
lift up an if_exprt one level
Base class for all expressions.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
Operator to update elements in structs and arrays.
const source_locationt & source_location() const
#define UNREACHABLE
This should be used to mark dead code.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
depth_iteratort depth_end()
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
exprt make_binary(const exprt &expr)
splits an expression with >=3 operands into nested binary expressions