CBMC: /home/runner/work/cbmc/cbmc/src/util/expr_iterator.h Source File
9#ifndef CPROVER_UTIL_EXPR_ITERATOR_H
10#define CPROVER_UTIL_EXPR_ITERATOR_H
67template<typename depth_iterator_t>
77 template <typename other_depth_iterator_t>
80 template <typename other_depth_iterator_t>
87 template <typename other_depth_iterator_t>
101 if(m_stack.back().op_idx == m_stack.back().expr.get().operands().size())
109 m_stack.back().expr.get().operands()[m_stack.back().op_idx]))
166 { m_stack=std::move(other.m_stack); }
189 for(auto &state : m_stack)
195 if(!(state == m_stack.back()))
196 expr = &expr->operands()[state.op_idx];
300 bool push_expr(const exprt &expr)
302 const bool inserted=this->m_traversed.insert(expr).second;
387 if(m_stack.back().op_idx < m_stack.back().expr.get().operands().size())
390 m_stack.back().expr.get().operands()[m_stack.back().op_idx]);
426 const exprt *current = &expr;
429 m_stack.emplace_back(*current);
430 if(current->operands().empty())
432 current = ¤t->operands().front();
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
An adapter to yield a range (expected to satisfy C++20 std::ranges::range) of const_depth_iteratort.
const_depth_iteratort begin() const
const_depth_iteratort end() const
const_depth_iterator_range_adaptert(const exprt &_root)
const_depth_iteratort(const exprt &expr)
Create iterator starting at the supplied node (root)
const_depth_iteratort()=default
Create an end iterator.
An adapter to yield a range of const_post_depth_iteratort.
const_post_depth_iteratort end() const
const_post_depth_iterator_range_adaptert(const exprt &_root)
const_post_depth_iteratort begin() const
Post-order depth-first-search iterator.
bool operator!=(const const_post_depth_iteratort &other) const
void descend_to_leftmost_leaf(const exprt &expr)
Descend from the given expression to its leftmost leaf, pushing all nodes along the path onto the sta...
const exprt & operator*() const
Dereference operator Dereferencing end() iterator is undefined behaviour.
const_post_depth_iteratort & operator++()
Preincrement operator Do not call on the end() iterator.
const_post_depth_iteratort operator++(int)
Post-increment operator Expensive copy.
std::deque< depth_iterator_expr_statet > m_stack
const_post_depth_iteratort(const exprt &expr)
Create iterator starting at the supplied node (root).
const_post_depth_iteratort()=default
Create an end iterator.
const exprt * operator->() const
Dereference operator (member access) Dereferencing end() iterator is undefined behaviour.
bool operator==(const const_post_depth_iteratort &other) const
std::forward_iterator_tag iterator_category
friend depth_iterator_baset
const_unique_depth_iteratort()=default
Create an end iterator.
bool push_expr(const exprt &expr)
Push expression onto the stack and add to the set of traversed exprts.
std::set< exprt > m_traversed
const_unique_depth_iteratort(const exprt &expr)
Create iterator starting at the supplied node (root)
Depth first search iterator base - iterates over supplied expression and all its operands recursively...
depth_iterator_t & next_sibling_or_parent()
depth_iterator_t & operator++()
Preincrement operator Do not call on the end() iterator.
depth_iterator_baset(const depth_iterator_baset &)=default
exprt & mutate()
Obtain non-const exprt reference.
std::deque< depth_iterator_expr_statet > m_stack
depth_iterator_baset & operator=(const depth_iterator_baset &)=default
const exprt * operator->() const
Dereference operator (member access) Dereferencing end() iterator is undefined behaviour.
depth_iterator_baset(const exprt &root)
Create begin iterator, starting at the supplied node.
const exprt & operator*() const
Dereference operator Dereferencing end() iterator is undefined behaviour.
depth_iterator_baset(depth_iterator_baset &&other)
bool operator!=(const depth_iterator_baset< other_depth_iterator_t > &other) const
bool push_expr(const exprt &expr)
Pushes expression onto the stack If overridden, this function should be called from the inheriting cl...
bool operator==(const depth_iterator_baset< other_depth_iterator_t > &other) const
depth_iterator_t operator++(int)
Post-increment operator Expensive copy.
std::forward_iterator_tag iterator_category
depth_iterator_t & downcast()
depth_iterator_baset & operator=(depth_iterator_baset &&other)
~depth_iterator_baset()=default
Destructor Protected to discourage upcasting.
depth_iterator_baset()=default
Create end iterator.
depth_iteratort(const exprt &expr, std::function< exprt &()> mutate_root)
Create iterator starting at the supplied node (root) If mutations of the child nodes are required the...
depth_iteratort(exprt &expr)
Create iterator starting at the supplied node (root) All mutations of the child nodes will be reflect...
exprt & mutate()
Obtain non-const reference to the exprt instance currently pointed to by the iterator.
depth_iteratort()=default
Create an end iterator.
std::function< exprt &()> mutate_root
If this is non-empty then the root is currently const and this function must be called before any mut...
Base class for all expressions.
static const_depth_iterator_range_adaptert pre_traversal(const exprt &root)
bool operator==(const depth_iterator_expr_statet &left, const depth_iterator_expr_statet &right)
static const_post_depth_iterator_range_adaptert post_traversal(const exprt &root)
int __CPROVER_ID java::java io InputStream read
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Helper class for depth_iterator_baset.
std::reference_wrapper< const exprt > expr
depth_iterator_expr_statet(const exprt &expr)
exprt::operandst::const_iterator operands_iteratort