9 #ifndef CPROVER_UTIL_EXPR_H
10 #define CPROVER_UTIL_EXPR_H
20 #define forall_operands(it, expr) \
21 for(exprt::operandst::const_iterator \
22 it = as_const(expr).operands().begin(), \
23 it##_end = as_const(expr).operands().end(); \
27 #define Forall_operands(it, expr) \
28 if((expr).has_operands()) \
29 for(exprt::operandst::iterator it=(expr).operands().begin(); \
30 it!=(expr).operands().end(); ++it)
32 #define forall_expr(it, expr) \
33 for(exprt::operandst::const_iterator it=(expr).begin(); \
34 it!=(expr).end(); ++it)
36 #define Forall_expr(it, expr) \
37 for(exprt::operandst::iterator it=(expr).begin(); \
38 it!=(expr).end(); ++it)
65 :
irept(std::move(_id), {{ID_type, std::move(_type)}}, {})
72 {{ID_type, std::move(_type)}},
87 return static_cast<const typet &
>(
find(ID_type));
103 if(location.is_not_nil())
111 if(location.is_not_nil())
113 return std::move(*
this);
119 if(other.source_location().is_not_nil())
127 if(other.source_location().is_not_nil())
129 return std::move(*
this);
179 operands().push_back(std::move(expr));
189 op.reserve(op.size() + 2);
191 op.push_back(std::move(e1));
192 op.push_back(std::move(e2));
203 op.reserve(op.size() + 3);
205 op.push_back(std::move(e1));
206 op.push_back(std::move(e2));
207 op.push_back(std::move(e3));
214 return id() == ID_constant;
226 return type().
id() == ID_bool;
243 remove(ID_C_source_location);
304 return static_cast<exprt &
>(
add(name));
309 return static_cast<const exprt &
>(
find(name));
348 :
exprt(std::move(_id), std::move(_type))
353 :
exprt(std::move(_id), std::move(_type), std::move(_operands))
void validate_expr(const shuffle_vector_exprt &value)
virtual void operator()(const exprt &)
virtual ~const_expr_visitort()
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
expr_protectedt(irep_idt _id, typet _type)
expr_protectedt(irep_idt _id, typet _type, operandst _operands)
virtual void operator()(exprt &)
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).
std::vector< exprt > operandst
bool is_one() const
Return whether the expression is a constant representing 1.
exprt & with_source_location(source_locationt location) &
Add the source location from location, if it is non-nil.
bool has_operands() const
Return true if there is at least one operand.
const exprt & op3() const
void add_to_operands(exprt &&e1, exprt &&e2, exprt &&e3)
Add the given arguments to the end of exprt's operands.
bool is_true() const
Return whether the expression is a constant representing true.
exprt && with_source_location(const exprt &other) &&
Add the source location from other, if it has any.
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Check that the expression is well-formed, assuming that its subexpressions and type have all ready be...
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
exprt & add_expr(const irep_idt &name)
const typet & type() const
depth_iteratort depth_end()
const_depth_iteratort depth_cend() const
source_locationt & add_source_location()
const_unique_depth_iteratort unique_depth_end() const
bool is_boolean() const
Return whether the expression represents a Boolean.
depth_iteratort depth_begin()
const source_locationt & source_location() const
const_unique_depth_iteratort unique_depth_cend() const
exprt && with_source_location(source_locationt location) &&
Add the source location from location, if it is non-nil.
void visit(class expr_visitort &visitor)
These are pre-order traversal visitors, i.e., the visitor is executed on a node before its children h...
bool is_false() const
Return whether the expression is a constant representing false.
void reserve_operands(operandst::size_type n)
static void check(const exprt &, const validation_modet)
Check that the expression is well-formed (shallow checks only, i.e., subexpressions and its type are ...
bool is_zero() const
Return whether the expression is a constant representing 0.
const exprt & op2() const
void visit_pre(std::function< void(exprt &)>)
typet & type()
Return the type of the expression.
static void validate_full(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Check that the expression is well-formed (full check, including checks of all subexpressions and the ...
exprt(irep_idt _id, typet _type)
exprt(irep_idt _id, typet _type, operandst &&_operands)
bool is_constant() const
Return whether the expression is a constant.
const exprt & op0() const
exprt(const irep_idt &_id)
const_depth_iteratort depth_cbegin() const
const operandst & operands() const
void visit_post(std::function< void(exprt &)>)
These are post-order traversal visitors, i.e., the visitor is executed on a node after its children h...
const exprt & find_expr(const irep_idt &name) const
void add_to_operands(exprt &&e1, exprt &&e2)
Add the given arguments to the end of exprt's operands.
void add_to_operands(exprt &&expr)
Add the given argument to the end of exprt's operands.
exprt(const irep_idt &id, typet type, source_locationt loc)
exprt & with_source_location(const exprt &other) &
Add the source location from other, if it has any.
void drop_source_location()
const_unique_depth_iteratort unique_depth_cbegin() const
const exprt & op1() const
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
const_unique_depth_iteratort unique_depth_begin() const
There are a large number of kinds of tree structured or tree-like data in CPROVER.
const irept & find(const irep_idt &name) const
void remove(const irep_idt &name)
const irep_idt & id() const
irept & add(const irep_idt &name)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The type of an expression, extends irept.
Defines typet, type_with_subtypet and type_with_subtypest.
void check_expr(const exprt &expr, const validation_modet vm)
Check that the given expression is well-formed (shallow checks only, i.e., subexpressions and its typ...
void validate_full_expr(const exprt &expr, const namespacet &ns, const validation_modet vm)
Check that the given expression is well-formed (full check, including checks of all subexpressions an...
void validate_full_type(const typet &type, const namespacet &ns, const validation_modet vm)
Check that the given type is well-formed (full check, including checks of subtypes)