CBMC
|
Data structures and algorithms used by smt2_incremental_decision_proceduret to track data about the objects which pointers point to. More...
Go to the source code of this file.
Classes | |
struct | decision_procedure_objectt |
Information the decision procedure holds about each object. More... | |
Typedefs | |
using | smt_object_mapt = std::unordered_map< exprt, decision_procedure_objectt, irep_hash > |
Mapping from an object's base expression to the set of information about it which we track. More... | |
Functions | |
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. More... | |
template<typename output_object_functiont > | |
void | find_object_base_expressions (const exprt &expression, const output_object_functiont &output_object) |
Arbitrary expressions passed to the decision procedure may have multiple address of operations as its sub expressions. More... | |
smt_object_mapt | initial_smt_object_map () |
Constructs an initial object map containing the null object. More... | |
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 where the map does not contain them already. More... | |
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 object map. More... | |
exprt | make_invalid_pointer_expr () |
Create the invalid pointer constant. More... | |
Data structures and algorithms used by smt2_incremental_decision_proceduret to track data about the objects which pointers point to.
An object here is the whole of an allocated block of memory. Objects in this sense have no sub objects; only offsets. Valid examples of objects include -
int foo;
.int *sam;
.struct bart{int eggs, int ham} bar;
int green[20];
malloc(20)
. Examples of things / expressions which are not objects -&foo
or &sam
. The value of these pointers encodes the combination of the unique object identifier of foo
/ sam
objects and a (zero) offset, but these pointer values / memory addresses are not in themselves objects, although the values may be stored in another object. This is a distinction between values and the objects which contain them.bar.ham
from the previous example. A pointer to this field is an offset into the base bar
object.&(green[5])
. A pointer to an element in this example is an offset into the base int green[20]
object. Definition in file object_tracking.h.
using smt_object_mapt = std::unordered_map<exprt, decision_procedure_objectt, irep_hash> |
Mapping from an object's base expression to the set of information about it which we track.
Definition at line 90 of file object_tracking.h.
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.
In order to encode the offset identifiers we need to assign unique identifiers to the objects. This function finds the base object expression in an address of expression for which a unique identifier needs to be assigned.
Definition at line 18 of file object_tracking.cpp.
void find_object_base_expressions | ( | const exprt & | expression, |
const output_object_functiont & | output_object | ||
) |
Arbitrary expressions passed to the decision procedure may have multiple address of operations as its sub expressions.
This means the overall expression may contain multiple base objects which need to be assigned unique identifiers.
expression | The expression within which to find base objects. |
output_object | This function is called with each of the base object expressions found, as they are found. |
The found objects are returned through an output function in order to separate the implementation of the storage and deduplication of the results from finding the object expressions. The type of output_object
is a template parameter in order to eliminate potential performance overheads of using std::function
.
Definition at line 76 of file object_tracking.h.
smt_object_mapt initial_smt_object_map | ( | ) |
Constructs an initial object map containing the null object.
The null object must be added at construction in order to ensure it is allocated a unique identifier of 0.
Definition at line 69 of file object_tracking.cpp.
exprt make_invalid_pointer_expr | ( | ) |
Create the invalid pointer constant.
Definition at line 13 of file object_tracking.cpp.
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 object map.
This supports writing invariants on the base object expressions already being tracked in the map in contexts where the map is const.
Definition at line 120 of file object_tracking.cpp.
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 where the map does not contain them already.
expression | The expression within which to find and base object expressions. |
ns | The namespace used to look up the size of object types. |
object_map | The map into which any new tracking information should be inserted. |
Definition at line 99 of file object_tracking.cpp.