12 #include <unordered_set> 26 if(operands.size()<=2)
32 exprt previous=operands.front();
35 for(exprt::operandst::const_iterator
36 it=++operands.begin();
44 tmp.operands().resize(2);
45 tmp.op0().swap(previous);
65 if(it->id()==ID_index_designator)
69 else if(it->id()==ID_member_designator)
93 const typet &src_type=
94 src.
type().
id()==ID_c_enum_tag?
98 if(src_type.
id()==ID_bool)
102 src_type.
id()==ID_floatbv?ID_ieee_float_notequal:ID_notequal;
115 if(src.
id()==ID_not && src.
operands().size()==1)
127 const std::function<
bool(
const exprt &)> &pred)
136 src, [&](
const exprt &subexpr) {
return subexpr.
id() == id; });
141 const std::function<
bool(
const typet &)> &pred,
144 std::vector<std::reference_wrapper<const typet>>
stack;
145 std::unordered_set<typet, irep_hash> visited;
147 const auto push_if_not_visited = [&](
const typet &t) {
148 if(visited.insert(t).second)
149 stack.emplace_back(t);
152 push_if_not_visited(type);
153 while(!
stack.empty())
160 else if(top.
id() == ID_symbol)
161 push_if_not_visited(ns.
follow(top));
162 else if(top.
id() == ID_c_enum_tag)
164 else if(top.
id() == ID_struct || top.
id() == ID_union)
167 push_if_not_visited(comp.type());
171 for(
const auto &subtype : top.
subtypes())
172 push_if_not_visited(subtype);
182 type, [&](
const typet &subtype) {
return subtype.
id() == id; }, ns);
191 const exprt true_case=if_expr.true_case();
192 const exprt false_case=if_expr.false_case();
195 result.
cond()=if_expr.cond();
const if_exprt & to_if_expr(const exprt &expr)
Cast a generic exprt to an if_exprt.
The type of an expression.
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()
const componentst & components() const
The trinary if-then-else operator.
depth_iteratort depth_begin()
#define CHECK_RETURN(CONDITION)
const typet & follow_tag(const union_tag_typet &) const
const irep_idt & id() const
The boolean constant true.
exprt is_not_zero(const exprt &src, const namespacet &ns)
converts a scalar/float expression to C/C++ Booleans
A generic base class for binary expressions.
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.
with_exprt make_with_expr(const update_exprt &src)
converts an update expr into a (possibly nested) with expression
#define PRECONDITION(CONDITION)
const typet & follow(const typet &) const
const index_designatort & to_index_designator(const exprt &expr)
Cast a generic exprt to an index_designatort.
const exprt & index() const
The boolean constant false.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a generic typet to a c_enum_tag_typet.
std::vector< exprt > operandst
const with_exprt & to_with_expr(const exprt &expr)
Cast a generic 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 generic typet to a struct_union_typet.
Operator to update elements in structs and arrays.
const source_locationt & source_location() const
depth_iteratort depth_end()
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true ...
exprt make_binary(const exprt &expr)
splits an expression with >=3 operands into nested binary expressions