34 const typet &new_type,
49 std::make_shared<constant_pointer_abstract_objectt>(
type,
top,
bottom));
59 std::make_shared<constant_pointer_abstract_objectt>(expr, environment, ns));
76 std::dynamic_pointer_cast<const abstract_pointer_objectt>(value);
77 results.
insert(pointer->read_dereference(env, ns));
80 return results.
first();
86 const std::stack<exprt> &stack,
88 bool merging_write)
const
92 environment.
havoc(
"Writing to a 2value pointer");
93 return shared_from_this();
99 std::dynamic_pointer_cast<const abstract_pointer_objectt>(value);
100 pointer->write_dereference(
101 environment, ns, stack, new_value, merging_write);
104 return shared_from_this();
108 const typet &new_type,
120 std::dynamic_pointer_cast<const abstract_pointer_objectt>(value);
121 new_values.
insert(pointer->typecast(new_type, environment, ns));
123 return std::make_shared<value_set_pointer_abstract_objectt>(
129 const std::vector<abstract_object_pointert> &operands,
134 std::dynamic_pointer_cast<const value_set_pointer_abstract_objectt>(
137 auto differences = std::vector<abstract_object_pointert>{};
141 auto lhsp = std::dynamic_pointer_cast<const abstract_pointer_objectt>(lhsv);
142 for(
auto const &rhsp : rhs->values)
144 auto ops = std::vector<abstract_object_pointert>{lhsp, rhsp};
145 differences.push_back(lhsp->ptr_diff(expr, ops, environment, ns));
149 return std::accumulate(
150 differences.cbegin(),
156 return abstract_objectt::merge(lhs, rhs, widen_modet::no).object;
162 const std::vector<abstract_object_pointert> &operands,
167 std::dynamic_pointer_cast<const value_set_pointer_abstract_objectt>(
170 auto comparisons = std::set<exprt>{};
174 auto lhsp = std::dynamic_pointer_cast<const abstract_pointer_objectt>(lhsv);
175 for(
auto const &rhsp : rhs->values)
177 auto ops = std::vector<abstract_object_pointert>{lhsp, rhsp};
178 auto comparison = lhsp->ptr_comparison_expr(expr, ops, environment, ns);
180 comparisons.insert(result);
184 if(comparisons.size() > 1)
186 return *comparisons.cbegin();
195 return shared_from_this();
199 auto result = std::dynamic_pointer_cast<value_set_pointer_abstract_objectt>(
208 result->set_values(unwrapped_values);
217 auto cast_other = std::dynamic_pointer_cast<const value_set_tag>(other);
220 auto union_values =
values;
221 union_values.
insert(cast_other->get_values());
229 const exprt &name)
const
238 std::back_inserter(all_predicates),
240 return value->to_predicate(name);
242 std::sort(all_predicates.begin(), all_predicates.end());
270 out <<
"value-set-begin: ";
274 out <<
" :value-set-end";
282 for(
auto const &value : values)
287 return unwrapped_values;
293 auto const &value_as_set = std::dynamic_pointer_cast<const value_set_tag>(
294 maybe_singleton->unwrap_context());
298 PRECONDITION(!std::dynamic_pointer_cast<const context_abstract_objectt>(
299 value_as_set->get_values().first()));
301 return value_as_set->get_values().first();
304 return maybe_singleton;
An abstract version of a program environment.
sharing_ptrt< class abstract_objectt > abstract_object_pointert
static abstract_object_pointert transform(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns)
virtual void havoc(const std::string &havoc_string)
This should be used as a default case / everything else has failed The string is so that I can easily...
virtual abstract_object_pointert abstract_object_factory(const typet &type, const namespacet &ns, bool top, bool bottom) const
Look at the configuration for the sensitivity and create an appropriate abstract_object.
const_iterator begin() const
value_sett::size_type size() const
void output(std::ostream &out, const ai_baset &ai, const namespacet &ns) const
void insert(const abstract_object_pointert &o)
abstract_object_pointert first() const
const_iterator end() const
virtual bool is_top() const
Find out if the abstract object is top.
virtual bool is_bottom() const
Find out if the abstract object is bottom.
static combine_result merge(const abstract_object_pointert &op1, const abstract_object_pointert &op2, const locationt &merge_location, const widen_modet &widen_mode)
virtual const typet & type() const
Get the real type of the variable this abstract object is representing.
This is the basic interface of the abstract interpreter with default implementations of the core func...
Base class for all expressions.
std::vector< exprt > operandst
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.
abstract_object_sett values
abstract_object_pointert resolve_values(const abstract_object_sett &new_values) const
Update the set of stored values to new_values.
abstract_object_pointert ptr_diff(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const override
internal_abstract_object_pointert mutable_clone() const override
exprt to_predicate_internal(const exprt &name) const override
to_predicate implementation - derived classes will override
abstract_object_pointert merge(const abstract_object_pointert &other, const widen_modet &widen_mode) const override
static const size_t max_value_set_size
The threshold size for value-sets: past this threshold the object is either converted to interval or ...
void set_values(const abstract_object_sett &other_values)
Setter for updating the stored values.
void output(std::ostream &out, const ai_baset &ai, const namespacet &ns) const override
abstract_object_pointert read_dereference(const abstract_environmentt &env, const namespacet &ns) const override
A helper function to read elements from an array.
abstract_object_pointert typecast(const typet &new_type, const abstract_environmentt &environment, const namespacet &ns) const override
value_set_pointer_abstract_objectt(const typet &new_type, bool top, bool bottom, const abstract_object_sett &new_values)
abstract_object_pointert write_dereference(abstract_environmentt &environment, const namespacet &ns, const std::stack< exprt > &stack, const abstract_object_pointert &new_value, bool merging_write) const override
Evaluate writing to a pointer's value.
exprt ptr_comparison_expr(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const override
An abstraction of a pointer that tracks a single pointer.
General implementation of a an abstract_objectt which can track side information in the form of a 'co...
API to expression classes for Pointers.
bool is_void_pointer(const typet &type)
This method tests, if the given typet is a pointer of type void.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
exprt simplify_expr(exprt src, const namespacet &ns)
#define PRECONDITION(CONDITION)
static abstract_object_pointert maybe_extract_single_value(const abstract_object_pointert &maybe_singleton)
Helper for converting singleton value sets into its only value.
static abstract_object_sett unwrap_and_extract_values(const abstract_object_sett &values)
Value Set of Pointer Abstract Object.