Go to the documentation of this file.
38 const typet &new_type,
41 value_stack(old.value_stack)
50 value_stack(expr, environment, ns)
68 std::dynamic_pointer_cast<const constant_pointer_abstract_objectt>(other);
79 std::dynamic_pointer_cast<const constant_pointer_abstract_objectt>(other);
90 cast_other->value_stack.target_expression(d))
107 std::dynamic_pointer_cast<const constant_pointer_abstract_objectt>(other);
114 cast_other->value_stack.offset_expression());
123 return std::make_shared<constant_pointer_abstract_objectt>(*other);
125 bool matching_pointers =
128 if(matching_pointers)
129 return shared_from_this();
161 if(value.
id() == ID_address_of)
164 if(addressee.id() == ID_symbol)
170 else if(addressee.id() == ID_dynamic_object)
172 out << addressee.get(ID_identifier);
174 else if(addressee.id() == ID_index)
177 auto const &array = array_index.array();
178 if(array.id() == ID_symbol)
181 out << array_symbol.get_identifier() <<
"[";
182 if(array_index.index().id() == ID_constant)
216 const std::stack<exprt> &stack,
218 bool merging_write)
const
222 environment.
havoc(
"Writing to a 2value pointer");
223 return shared_from_this();
227 return std::make_shared<constant_pointer_abstract_objectt>(
228 type(),
true,
false);
244 environment.
assign(value, merged_value, ns);
248 environment.
assign(value, new_value, ns);
256 environment.
write(pointed_value, new_value, stack, ns, merging_write);
257 environment.
assign(value, modified_value, ns);
261 return shared_from_this();
265 const typet &new_type,
273 if(value.
id() == ID_dynamic_object)
277 auto heap_array_type =
281 auto heap_symbol =
symbol_exprt(value.
get(ID_identifier), heap_array_type);
282 env.assign(heap_symbol, array_object, ns);
285 auto new_pointer = std::make_shared<constant_pointer_abstract_objectt>(
286 heap_address, env, ns);
290 return std::make_shared<constant_pointer_abstract_objectt>(new_type, *
this);
310 const std::vector<abstract_object_pointert> &operands,
314 auto &rhs = operands.back();
320 expr, operands, environment, ns);
340 if(
id == ID_notequal)
355 if(
id == ID_notequal)
362 const std::vector<abstract_object_pointert> &operands,
366 auto rhs = std::dynamic_pointer_cast<const constant_pointer_abstract_objectt>(
369 if(
is_top() || rhs->is_top())
374 auto lhs_offset =
offset();
375 auto rhs_offset = rhs->offset();
377 if(lhs_offset.id() == ID_member)
379 expr.
id(), lhs_offset, rhs_offset);
380 if(lhs_offset.id() == ID_symbol)
387 if(expr.
id() == ID_equal)
389 if(expr.
id() == ID_notequal)
395 const exprt &name)
const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
void output(std::ostream &out, const ai_baset &ai, const namespacet &ns) const override
Print the value of the pointer.
bool is_top_value() const
Is the stack representing an unknown value and hence can't be written to or read from.
sharing_ptrt< class abstract_objectt > abstract_object_pointert
virtual bool is_top() const
Find out if the abstract object is top.
virtual void output(std::ostream &out, const class ai_baset &ai, const namespacet &ns) const
Print the value of the abstract object.
virtual abstract_object_pointert write(const abstract_object_pointert &lhs, const abstract_object_pointert &rhs, std::stack< exprt > remaining_stack, const namespacet &ns, bool merge_write)
Used within assign to do the actual dispatch.
The type of an expression, extends irept.
abstract_object_pointert ptr_diff(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const override
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
virtual const typet & type() const
Get the real type of the variable this abstract object is representing.
abstract_object_pointert write_dereference(abstract_environmentt &environment, const namespacet &ns, const std::stack< exprt > &stack, const abstract_object_pointert &value, bool merging_write) const override
A helper function to evaluate writing to a pointers value.
virtual bool assign(const exprt &expr, const abstract_object_pointert &value, const namespacet &ns)
Assign a value to an expression.
Base class for all expressions.
exprt symbol_ptr_comparison_expr(irep_idt const &id, exprt const &lhs, exprt const &rhs)
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...
abstract_object_pointert merge_constant_pointers(const constant_pointer_abstract_pointert &other, const widen_modet &widen_mode) const
Merges two constant pointers.
Expression to hold a symbol (variable)
exprt struct_member_ptr_comparison_expr(irep_idt const &id, exprt const &lhs, exprt const &rhs)
const irep_idt & get(const irep_idt &name) const
void get_statistics(abstract_object_statisticst &statistics, abstract_object_visitedt &visited, const abstract_environmentt &env, const namespacet &ns) const override
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
sharing_ptrt< constant_pointer_abstract_objectt > constant_pointer_abstract_pointert
bool same_target(abstract_object_pointert other) const
typet & type()
Return the type of the expression.
abstract_object_pointert typecast(const typet &new_type, const abstract_environmentt &environment, const namespacet &ns) const override
static combine_result merge(const abstract_object_pointert &op1, const abstract_object_pointert &op2, const locationt &merge_location, const widen_modet &widen_mode)
abstract_object_pointert read_dereference(const abstract_environmentt &env, const namespacet &ns) const override
A helper function to dereference a value from a pointer.
abstract_object_pointert merge(const abstract_object_pointert &op1, const widen_modet &widen_mode) const override
Set this abstract object to be the result of merging this abstract object.
exprt target_expression(size_t depth) const
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.
static exprt to_bool_expr(bool v)
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
signedbv_typet signed_size_type()
virtual exprt to_constant() const
Converts to a constant expression if possible.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
exprt to_constant() const override
To try and find a constant expression for this abstract object.
virtual abstract_object_pointert eval(const exprt &expr, const namespacet &ns) const
These three are really the heart of the method.
const irep_idt & id() const
The Boolean constant false.
std::set< abstract_object_pointert > abstract_object_visitedt
constant_pointer_abstract_objectt(const typet &type)
exprt offset_expression() const
exprt offset_from(abstract_object_pointert other) const
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
exprt to_predicate_internal(const exprt &name) const override
to_predicate implementation - derived classes will override
A base class for relations, i.e., binary predicates whose two operands have the same type.
memory_sizet objects_memory_usage
An underestimation of the memory usage of the abstract objects.
This is the basic interface of the abstract interpreter with default implementations of the core func...
void get_statistics(abstract_object_statisticst &statistics, abstract_object_visitedt &visited, const abstract_environmentt &env, const namespacet &ns) const override
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
irep_idt get_component_name() const
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
bool is_void_pointer(const typet &type)
This method tests, if the given typet is a pointer of type void.
Operator to return the address of an object.
virtual bool is_bottom() const
Find out if the abstract object is bottom.
abstract_object_pointert object
The Boolean constant true.
exprt to_expression() const
Convert the stack to an expression that can be used to write to.
const irep_idt & get_value() const
static memory_sizet from_bytes(std::size_t bytes)
exprt ptr_comparison_expr(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const override
virtual abstract_object_pointert expression_transform(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const
Interface for transforms.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.