CBMC
|
There are different ways of handling arrays, structures, unions and pointers. More...
#include <iosfwd>
#include <memory>
#include <analyses/ai_domain.h>
#include <analyses/variable-sensitivity/abstract_environment.h>
#include <analyses/variable-sensitivity/variable_sensitivity_configuration.h>
Go to the source code of this file.
Classes | |
class | variable_sensitivity_domaint |
class | variable_sensitivity_domain_factoryt |
Macros | |
#define | OPT_VSD |
#define | HELP_VSD |
#define | PARSE_OPTIONS_VSD(cmdline, options) |
There are different ways of handling arrays, structures, unions and pointers.
interval_domaint and constant_propagator_domaint basically ignores them which is imprecise at best and out-right wrong at worst. For one project we needed to do better. We could have implemented a particular way of handling them in an existing domain, created a new one with it, etc. This would work but it means duplicate code and it is is inflexible when the same person / the next person comes along and says "actually, we really care about the pointer precision but less so the array so could you just ...". Thus the idea was to do this properly:
This is implemented in three parts:
abstract_objectt : The base / interface for abstractions of a single variable. The interface for these is effectively create (as top, bottom, from a constant or copy), transform, merge, convert to constant if possible. Child classes add additional bits of interface, for example array abstractions need a "read element" and a "write element" method, structures need a "read field" and "write field", etc. These objects are intended to be immutable and thus operations tend to produce pointers. This is so that we can easily produce copy-on-write maps of them which we need for scaling and performance. There are also children of these for the constant abstraction of one value, the interval abstraction of one value (to be implemented), etc.
abstract_environment : This contains the map from variable names for abstract_objectt's (the "non-relational" part of the domain). The map itself if copy-on-write for performance and scalability but this is all wrapped up nicely in danpoe's sharing_map. The interface here is evaluate (exprt -> abstract_objectt*), assign (name, abstract_objectt* -> bool), assume (exprt -> bool) and merge. It has a factory to build abstract_objectt* from types or constants but apart from that, doesn't know anything about which actual abstract_objectt's are being used. As long as program variables that are arrays have an abstract_objectt which has the array interface, and so on for structs, unions, etc. then the abstractions used for values can be freely mixed and matched in any way the user can get the factory to build.
variable_sensitivity_domaint : Implements the ai_domain_baset interface using an abstract_environment. The only real code here is the 'transform' method which looks at the instruction type and converts that into calls to eval, assume, assign and merge.
Definition in file variable_sensitivity_domain.h.
#define HELP_VSD |
Definition at line 85 of file variable_sensitivity_domain.h.
#define OPT_VSD |
Definition at line 74 of file variable_sensitivity_domain.h.
#define PARSE_OPTIONS_VSD | ( | cmdline, | |
options | |||
) |
Definition at line 103 of file variable_sensitivity_domain.h.