CBMC
two_value_pointer_abstract_object.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3  Module: analyses variable-sensitivity
4 
5  Author: Jez Higgins
6 
7 \*******************************************************************/
8 
11 
12 #include <util/pointer_expr.h>
13 
15  const typet &type)
17 {
18 }
19 
21  const typet &type,
22  bool top,
23  bool bottom)
24  : abstract_pointer_objectt(type, top, bottom)
25 {
26 }
27 
29  const exprt &expr,
30  const abstract_environmentt &environment,
31  const namespacet &ns)
32  : abstract_pointer_objectt(expr, environment, ns)
33 {
34 }
35 
37  const abstract_environmentt &env,
38  const namespacet &ns) const
39 {
41  const typet &pointed_to_type = pointer_type.base_type();
42 
43  return env.abstract_object_factory(pointed_to_type, ns, true, false);
44 }
45 
48  const namespacet &ns,
49  const std::stack<exprt> &stack,
50  const abstract_object_pointert &value,
51  bool merging_write) const
52 {
53  if(is_top() || is_bottom())
54  {
55  env.havoc("Writing to a 2value pointer");
56  return shared_from_this();
57  }
58 
59  return std::make_shared<two_value_pointer_abstract_objectt>(
60  type(), true, false);
61 }
62 
64  const typet &new_type,
65  const abstract_environmentt &environment,
66  const namespacet &ns) const
67 {
68  INVARIANT(is_void_pointer(type()), "Only allow pointer casting from void*");
69  return std::make_shared<two_value_pointer_abstract_objectt>(
70  new_type, is_top(), is_bottom());
71 }
72 
74  const exprt &expr,
75  const std::vector<abstract_object_pointert> &operands,
76  const abstract_environmentt &environment,
77  const namespacet &ns) const
78 {
79  return environment.eval(nil_exprt(), ns);
80 }
81 
83  const exprt &expr,
84  const std::vector<abstract_object_pointert> &operands,
85  const abstract_environmentt &environment,
86  const namespacet &ns) const
87 {
88  return nil_exprt();
89 }
abstract_object_pointert
sharing_ptrt< class abstract_objectt > abstract_object_pointert
Definition: abstract_object.h:69
abstract_objectt::is_top
virtual bool is_top() const
Find out if the abstract object is top.
Definition: abstract_object.cpp:155
typet
The type of an expression, extends irept.
Definition: type.h:28
abstract_objectt::type
virtual const typet & type() const
Get the real type of the variable this abstract object is representing.
Definition: abstract_object.cpp:47
two_value_pointer_abstract_objectt::ptr_diff
abstract_object_pointert ptr_diff(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const override
Definition: two_value_pointer_abstract_object.cpp:73
abstract_pointer_objectt
Definition: abstract_pointer_object.h:20
abstract_environmentt
Definition: abstract_environment.h:40
exprt
Base class for all expressions.
Definition: expr.h:55
two_value_pointer_abstract_objectt::two_value_pointer_abstract_objectt
two_value_pointer_abstract_objectt(const typet &type)
Definition: two_value_pointer_abstract_object.cpp:14
abstract_environmentt::havoc
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...
Definition: abstract_environment.cpp:379
two_value_pointer_abstract_objectt::write_dereference
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
Evaluate writing to a pointer's value.
Definition: two_value_pointer_abstract_object.cpp:46
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
two_value_pointer_abstract_object.h
abstract_environmentt::abstract_object_factory
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.
Definition: abstract_environment.cpp:312
nil_exprt
The NIL expression.
Definition: std_expr.h:3025
two_value_pointer_abstract_objectt::read_dereference
abstract_object_pointert read_dereference(const abstract_environmentt &env, const namespacet &ns) const override
A helper function to read elements from an array.
Definition: two_value_pointer_abstract_object.cpp:36
pointer_expr.h
abstract_environment.h
to_pointer_type
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition: pointer_expr.h:79
pointer_type
pointer_typet pointer_type(const typet &subtype)
Definition: c_types.cpp:253
abstract_environmentt::eval
virtual abstract_object_pointert eval(const exprt &expr, const namespacet &ns) const
These three are really the heart of the method.
Definition: abstract_environment.cpp:94
two_value_pointer_abstract_objectt::typecast
abstract_object_pointert typecast(const typet &new_type, const abstract_environmentt &environment, const namespacet &ns) const override
Definition: two_value_pointer_abstract_object.cpp:63
pointer_typet::base_type
const typet & base_type() const
The type of the data what we point to.
Definition: pointer_expr.h:35
two_value_pointer_abstract_objectt::ptr_comparison_expr
exprt ptr_comparison_expr(const exprt &expr, const std::vector< abstract_object_pointert > &operands, const abstract_environmentt &environment, const namespacet &ns) const override
Definition: two_value_pointer_abstract_object.cpp:82
is_void_pointer
bool is_void_pointer(const typet &type)
This method tests, if the given typet is a pointer of type void.
Definition: pointer_expr.h:96
abstract_objectt::is_bottom
virtual bool is_bottom() const
Find out if the abstract object is bottom.
Definition: abstract_object.cpp:160
pointer_typet
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: pointer_expr.h:23
validation_modet::INVARIANT
@ INVARIANT