CBMC
object_tracking.h
Go to the documentation of this file.
1 // Author: Diffblue Ltd.
2 
30 
31 #ifndef CPROVER_SOLVERS_SMT2_INCREMENTAL_OBJECT_TRACKING_H
32 #define CPROVER_SOLVERS_SMT2_INCREMENTAL_OBJECT_TRACKING_H
33 
34 #include <util/expr.h>
35 #include <util/pointer_expr.h>
36 
37 #include <unordered_map>
38 
41 {
46  std::size_t unique_id;
49 };
50 
57 
73 template <typename output_object_functiont>
75  const exprt &expression,
76  const output_object_functiont &output_object)
77 {
78  expression.visit_pre([&](const exprt &node) {
79  if(const auto address_of = expr_try_dynamic_cast<address_of_exprt>(node))
80  {
81  output_object(find_object_base_expression(*address_of));
82  }
83  });
84 }
85 
88 using smt_object_mapt =
89  std::unordered_map<exprt, decision_procedure_objectt, irep_hash>;
90 
95 
106  const exprt &expression,
107  const namespacet &ns,
108  smt_object_mapt &object_map);
109 
115  const exprt &expression,
116  const smt_object_mapt &object_map);
117 
120 
121 #endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_OBJECT_TRACKING_H
objects_are_already_tracked
bool objects_are_already_tracked(const exprt &expression, const smt_object_mapt &object_map)
Finds whether all base object expressions in the given expression are already tracked in the given ob...
Definition: object_tracking.cpp:100
decision_procedure_objectt
Information the decision procedure holds about each object.
Definition: object_tracking.h:40
exprt
Base class for all expressions.
Definition: expr.h:55
find_object_base_expression
exprt find_object_base_expression(const address_of_exprt &address_of)
The model of addresses we use consists of a unique object identifier and an offset.
Definition: object_tracking.cpp:17
expr.h
track_expression_objects
void track_expression_objects(const exprt &expression, const namespacet &ns, smt_object_mapt &object_map)
Finds all the object expressions in the given expression and adds them to the object map for cases wh...
Definition: object_tracking.cpp:80
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
make_invalid_pointer_expr
exprt make_invalid_pointer_expr()
Create the invalid pointer constant.
Definition: object_tracking.cpp:12
pointer_expr.h
initial_smt_object_map
smt_object_mapt initial_smt_object_map()
Constructs an initial object map containing the null object.
Definition: object_tracking.cpp:66
decision_procedure_objectt::base_expression
exprt base_expression
The expression for the root of the object.
Definition: object_tracking.h:44
decision_procedure_objectt::unique_id
std::size_t unique_id
Number which uniquely identifies this particular object.
Definition: object_tracking.h:46
smt_object_mapt
std::unordered_map< exprt, decision_procedure_objectt, irep_hash > smt_object_mapt
Mapping from an object's base expression to the set of information about it which we track.
Definition: object_tracking.h:89
exprt::visit_pre
void visit_pre(std::function< void(exprt &)>)
Definition: expr.cpp:245
decision_procedure_objectt::size
exprt size
Expression which evaluates to the size of the object in bytes.
Definition: object_tracking.h:48
address_of_exprt
Operator to return the address of an object.
Definition: pointer_expr.h:370
find_object_base_expressions
void find_object_base_expressions(const exprt &expression, const output_object_functiont &output_object)
Arbitary expressions passed to the decision procedure may have multiple address of operations as its ...
Definition: object_tracking.h:74