Skip to content

Commit 160d41b

Browse files
committed
Reorganised pointer representation hierarchy
Introduce new base class, abstract_pointer_objectt. It should be, but is not yet, an abstract (in C++ terms) class as it's not intended to be directly instantiable. pointer_abstract_object now renamed two_value_pointer_abstract_objectt. constant_pointer_abstract_objectt and two_value_pointer_abstract_objectt are now peers. Deleted the unused value_set_pointer_abstract_objectt in anticipation of reintroducing a more functional value-set pointer representation shortly.
1 parent 268f886 commit 160d41b

15 files changed

+114
-186
lines changed

scripts/expected_doxygen_warnings.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ warning: Included by graph for 'pointer_expr.h' not generated, too many nodes (1
9797
warning: Included by graph for 'prefix.h' not generated, too many nodes (86), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9898
warning: Included by graph for 'simplify_expr.h' not generated, too many nodes (77), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9999
warning: Included by graph for 'std_code.h' not generated, too many nodes (78), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
100-
warning: Included by graph for 'std_expr.h' not generated, too many nodes (245), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
101-
warning: Included by graph for 'std_types.h' not generated, too many nodes (122), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
100+
warning: Included by graph for 'std_expr.h' not generated, too many nodes (244), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
101+
warning: Included by graph for 'std_types.h' not generated, too many nodes (121), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
102102
warning: Included by graph for 'symbol_table.h' not generated, too many nodes (95), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.

src/analyses/Makefile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,27 @@ SRC = ai.cpp \
3333
static_analysis.cpp \
3434
uncaught_exceptions_analysis.cpp \
3535
uninitialized_domain.cpp \
36-
variable-sensitivity/abstract_object.cpp \
3736
variable-sensitivity/abstract_environment.cpp \
37+
variable-sensitivity/abstract_object.cpp \
38+
variable-sensitivity/abstract_pointer_object.cpp \
3839
variable-sensitivity/abstract_value_object.cpp \
3940
variable-sensitivity/constant_abstract_value.cpp \
4041
variable-sensitivity/constant_pointer_abstract_object.cpp \
4142
variable-sensitivity/context_abstract_object.cpp \
42-
variable-sensitivity/write_location_context.cpp \
43-
variable-sensitivity/pointer_abstract_object.cpp \
44-
variable-sensitivity/variable_sensitivity_domain.cpp \
45-
variable-sensitivity/variable_sensitivity_object_factory.cpp \
46-
variable-sensitivity/full_struct_abstract_object.cpp \
47-
variable-sensitivity/full_array_abstract_object.cpp \
48-
variable-sensitivity/write_stack.cpp \
49-
variable-sensitivity/write_stack_entry.cpp \
5043
variable-sensitivity/data_dependency_context.cpp \
51-
variable-sensitivity/value_set_abstract_object.cpp \
52-
variable-sensitivity/variable_sensitivity_dependence_graph.cpp \
44+
variable-sensitivity/full_array_abstract_object.cpp \
45+
variable-sensitivity/full_struct_abstract_object.cpp \
5346
variable-sensitivity/interval_abstract_value.cpp \
47+
variable-sensitivity/three_way_merge_abstract_interpreter.cpp \
5448
variable-sensitivity/value_set_abstract_object.cpp \
5549
variable-sensitivity/value_set_abstract_value.cpp \
56-
variable-sensitivity/value_set_pointer_abstract_object.cpp \
57-
variable-sensitivity/three_way_merge_abstract_interpreter.cpp \
5850
variable-sensitivity/variable_sensitivity_configuration.cpp \
51+
variable-sensitivity/variable_sensitivity_dependence_graph.cpp \
52+
variable-sensitivity/variable_sensitivity_domain.cpp \
53+
variable-sensitivity/variable_sensitivity_object_factory.cpp \
54+
variable-sensitivity/write_location_context.cpp \
55+
variable-sensitivity/write_stack.cpp \
56+
variable-sensitivity/write_stack_entry.cpp \
5957
# Empty last line
6058

6159
INCLUDES= -I ..

src/analyses/variable-sensitivity/abstract_environment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <analyses/variable-sensitivity/abstract_object.h>
1212
#include <analyses/variable-sensitivity/abstract_object_statistics.h>
1313
#include <analyses/variable-sensitivity/constant_abstract_value.h>
14-
#include <analyses/variable-sensitivity/pointer_abstract_object.h>
1514
#include <analyses/variable-sensitivity/two_value_array_abstract_object.h>
15+
#include <analyses/variable-sensitivity/two_value_pointer_abstract_object.h>
1616
#include <analyses/variable-sensitivity/two_value_struct_abstract_object.h>
1717
#include <analyses/variable-sensitivity/variable_sensitivity_object_factory.h>
1818
#include <util/pointer_expr.h>

src/analyses/variable-sensitivity/pointer_abstract_object.cpp renamed to src/analyses/variable-sensitivity/abstract_pointer_object.cpp

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22
33
Module: analyses variable-sensitivity
44
5-
Author: Thomas Kiley, [email protected]
5+
Author: Jez Higgins, [email protected]
66
77
\*******************************************************************/
8-
#include <util/std_expr.h>
9-
#include <util/std_types.h>
108

119
#include <analyses/variable-sensitivity/abstract_environment.h>
10+
#include <analyses/variable-sensitivity/abstract_pointer_object.h>
1211

13-
#include "pointer_abstract_object.h"
14-
15-
pointer_abstract_objectt::pointer_abstract_objectt(const typet &t)
12+
abstract_pointer_objectt::abstract_pointer_objectt(const typet &t)
1613
: abstract_objectt(t)
1714
{
1815
PRECONDITION(t.id() == ID_pointer);
1916
}
2017

21-
pointer_abstract_objectt::pointer_abstract_objectt(
18+
abstract_pointer_objectt::abstract_pointer_objectt(
2219
const typet &type,
2320
bool top,
2421
bool bottom)
@@ -27,7 +24,7 @@ pointer_abstract_objectt::pointer_abstract_objectt(
2724
PRECONDITION(type.id() == ID_pointer);
2825
}
2926

30-
pointer_abstract_objectt::pointer_abstract_objectt(
27+
abstract_pointer_objectt::abstract_pointer_objectt(
3128
const exprt &e,
3229
const abstract_environmentt &environment,
3330
const namespacet &ns)
@@ -36,22 +33,20 @@ pointer_abstract_objectt::pointer_abstract_objectt(
3633
PRECONDITION(e.type().id() == ID_pointer);
3734
}
3835

39-
abstract_object_pointert pointer_abstract_objectt::expression_transform(
36+
abstract_object_pointert abstract_pointer_objectt::expression_transform(
4037
const exprt &expr,
4138
const std::vector<abstract_object_pointert> &operands,
4239
const abstract_environmentt &environment,
4340
const namespacet &ns) const
4441
{
4542
if(expr.id() == ID_dereference)
46-
{
4743
return read_dereference(environment, ns);
48-
}
4944

5045
return abstract_objectt::expression_transform(
5146
expr, operands, environment, ns);
5247
}
5348

54-
abstract_object_pointert pointer_abstract_objectt::write(
49+
abstract_object_pointert abstract_pointer_objectt::write(
5550
abstract_environmentt &environment,
5651
const namespacet &ns,
5752
const std::stack<exprt> &stack,
@@ -62,7 +57,7 @@ abstract_object_pointert pointer_abstract_objectt::write(
6257
return write_dereference(environment, ns, stack, value, merging_write);
6358
}
6459

65-
abstract_object_pointert pointer_abstract_objectt::read_dereference(
60+
abstract_object_pointert abstract_pointer_objectt::read_dereference(
6661
const abstract_environmentt &env,
6762
const namespacet &ns) const
6863
{
@@ -72,27 +67,23 @@ abstract_object_pointert pointer_abstract_objectt::read_dereference(
7267
return env.abstract_object_factory(pointed_to_type, ns, true, false);
7368
}
7469

75-
#include <iostream>
76-
77-
abstract_object_pointert pointer_abstract_objectt::write_dereference(
78-
abstract_environmentt &environment,
70+
abstract_object_pointert abstract_pointer_objectt::write_dereference(
71+
abstract_environmentt &env,
7972
const namespacet &ns,
8073
const std::stack<exprt> &stack,
8174
const abstract_object_pointert &value,
8275
bool merging_write) const
8376
{
8477
if(is_top() || is_bottom())
8578
{
86-
environment.havoc("Writing to a 2value pointer");
79+
env.havoc("Writing to a 2value pointer");
8780
return shared_from_this();
8881
}
89-
else
90-
{
91-
return std::make_shared<pointer_abstract_objectt>(type(), true, false);
92-
}
82+
83+
return std::make_shared<abstract_pointer_objectt>(type(), true, false);
9384
}
9485

95-
void pointer_abstract_objectt::get_statistics(
86+
void abstract_pointer_objectt::get_statistics(
9687
abstract_object_statisticst &statistics,
9788
abstract_object_visitedt &visited,
9889
const abstract_environmentt &env,

src/analyses/variable-sensitivity/pointer_abstract_object.h renamed to src/analyses/variable-sensitivity/abstract_pointer_object.h

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,52 @@
22
33
Module: analyses variable-sensitivity
44
5-
Author: Thomas Kiley, [email protected]
5+
Author: Jez Higgins, [email protected]
66
77
\*******************************************************************/
88

99
/// \file
1010
/// The base of all pointer abstractions
11-
#ifndef CPROVER_ANALYSES_VARIABLE_SENSITIVITY_POINTER_ABSTRACT_OBJECT_H
12-
#define CPROVER_ANALYSES_VARIABLE_SENSITIVITY_POINTER_ABSTRACT_OBJECT_H
13-
14-
#include <stack>
11+
#ifndef CPROVER_ANALYSES_VARIABLE_SENSITIVITY_ABSTRACT_POINTER_OBJECT_H
12+
#define CPROVER_ANALYSES_VARIABLE_SENSITIVITY_ABSTRACT_POINTER_OBJECT_H
1513

1614
#include <analyses/variable-sensitivity/abstract_object.h>
1715

18-
class typet;
19-
class constant_exprt;
20-
class abstract_environmentt;
16+
class abstract_pointer_tag
17+
{
18+
};
2119

22-
class pointer_abstract_objectt : public abstract_objectt
20+
class abstract_pointer_objectt : public abstract_objectt,
21+
public abstract_pointer_tag
2322
{
2423
public:
2524
/// \param type: the type the abstract_object is representing
26-
explicit pointer_abstract_objectt(const typet &type);
25+
explicit abstract_pointer_objectt(const typet &type);
2726

2827
/// Start the abstract object at either top or bottom or neither
2928
/// Asserts if both top and bottom are true
3029
///
3130
/// \param type: the type the abstract_object is representing
3231
/// \param top: is the abstract_object starting as top
3332
/// \param bottom: is the abstract_object starting as bottom
34-
pointer_abstract_objectt(const typet &type, bool top, bool bottom);
35-
36-
/// Interface for transforms
37-
///
38-
/// \param expr: the expression to evaluate and find the result of it.
39-
/// This will be the symbol referred to be op0()
40-
/// \param operands: an abstract_object (pointer) that represent
41-
/// the possible values of each operand
42-
/// \param environment: the abstract environment in which the
43-
/// expression is being evaluated
44-
/// \param ns: the current variable namespace
45-
///
46-
/// \return Returns the abstract_object representing the result of
47-
/// this expression to the maximum precision available.
48-
///
49-
/// To try and resolve different expressions with the maximum level
50-
/// of precision available.
51-
abstract_object_pointert expression_transform(
52-
const exprt &expr,
53-
const std::vector<abstract_object_pointert> &operands,
54-
const abstract_environmentt &environment,
55-
const namespacet &ns) const override;
33+
abstract_pointer_objectt(const typet &type, bool top, bool bottom);
5634

5735
/// \param expr: the expression to use as the starting pointer for
5836
/// an abstract object
5937
/// \param environment: the environment in which the pointer is being
6038
/// created
6139
/// \param ns: the current namespace
62-
explicit pointer_abstract_objectt(
40+
explicit abstract_pointer_objectt(
6341
const exprt &expr,
6442
const abstract_environmentt &environment,
6543
const namespacet &ns);
6644

67-
/**
68-
* A helper function to evaluate writing to a component of an
69-
* abstract object. More precise abstractions may override this to
70-
* update what they are storing for a specific component.
71-
*
72-
* \param environment the abstract environment
73-
* \param ns the current namespace
74-
* \param stack the remaining stack of expressions on the LHS to evaluate
75-
* \param specifier the expression uses to access a specific component
76-
* \param value the value we are trying to write to the component
77-
* \param merging_write if true, this and all future writes will be merged
78-
* with the current value
79-
*
80-
* \return the abstract_objectt representing the result of writing
81-
* to a specific component.
82-
*/
45+
abstract_object_pointert expression_transform(
46+
const exprt &expr,
47+
const std::vector<abstract_object_pointert> &operands,
48+
const abstract_environmentt &environment,
49+
const namespacet &ns) const override;
50+
8351
abstract_object_pointert write(
8452
abstract_environmentt &environment,
8553
const namespacet &ns,
@@ -95,9 +63,7 @@ class pointer_abstract_objectt : public abstract_objectt
9563
const namespacet &ns) const override;
9664

9765
protected:
98-
CLONE
99-
100-
/// A helper function to read elements from an array. More precise
66+
/// Evaluate reading the pointer's value. More precise
10167
/// abstractions may override this to provide more precise results.
10268
///
10369
/// \param env: the environment
@@ -108,8 +74,8 @@ class pointer_abstract_objectt : public abstract_objectt
10874
const abstract_environmentt &env,
10975
const namespacet &ns) const;
11076

111-
/// A helper function to evaluate writing to a pointers value. More
112-
/// precise abstractions may override this provide more precise results.
77+
/// Evaluate writing to a pointer's value. More precise abstractions
78+
/// may override this provide more precise results.
11379
///
11480
/// \param environment: the abstract environment
11581
/// \param ns: the namespace
@@ -132,4 +98,4 @@ class pointer_abstract_objectt : public abstract_objectt
13298
bool merging_write) const;
13399
};
134100

135-
#endif // CPROVER_ANALYSES_VARIABLE_SENSITIVITY_POINTER_ABSTRACT_OBJECT_H
101+
#endif // CPROVER_ANALYSES_VARIABLE_SENSITIVITY_ABSTRACT_POINTER_OBJECT_H

src/analyses/variable-sensitivity/constant_pointer_abstract_object.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
constant_pointer_abstract_objectt::constant_pointer_abstract_objectt(
2020
const typet &type)
21-
: pointer_abstract_objectt(type)
21+
: abstract_pointer_objectt(type)
2222
{
2323
PRECONDITION(type.id() == ID_pointer);
2424
}
@@ -27,22 +27,22 @@ constant_pointer_abstract_objectt::constant_pointer_abstract_objectt(
2727
const typet &type,
2828
bool top,
2929
bool bottom)
30-
: pointer_abstract_objectt(type, top, bottom)
30+
: abstract_pointer_objectt(type, top, bottom)
3131
{
3232
PRECONDITION(type.id() == ID_pointer);
3333
}
3434

3535
constant_pointer_abstract_objectt::constant_pointer_abstract_objectt(
3636
const constant_pointer_abstract_objectt &old)
37-
: pointer_abstract_objectt(old), value_stack(old.value_stack)
37+
: abstract_pointer_objectt(old), value_stack(old.value_stack)
3838
{
3939
}
4040

4141
constant_pointer_abstract_objectt::constant_pointer_abstract_objectt(
4242
const exprt &expr,
4343
const abstract_environmentt &environment,
4444
const namespacet &ns)
45-
: pointer_abstract_objectt(expr, environment, ns),
45+
: abstract_pointer_objectt(expr, environment, ns),
4646
value_stack(expr, environment, ns)
4747
{
4848
PRECONDITION(expr.type().id() == ID_pointer);
@@ -68,13 +68,13 @@ constant_pointer_abstract_objectt::merge(abstract_object_pointert other) const
6868
else
6969
{
7070
// TODO(tkiley): How do we set the result to be toppish?
71-
return pointer_abstract_objectt::merge(other);
71+
return abstract_pointer_objectt::merge(other);
7272
}
7373
}
7474

7575
abstract_object_pointert
7676
constant_pointer_abstract_objectt::merge_constant_pointers(
77-
const constant_pointer_abstract_pointert other) const
77+
const constant_pointer_abstract_pointert &other) const
7878
{
7979
if(is_bottom())
8080
{
@@ -91,7 +91,7 @@ constant_pointer_abstract_objectt::merge_constant_pointers(
9191
}
9292
else
9393
{
94-
return pointer_abstract_objectt::merge(other);
94+
return abstract_pointer_objectt::merge(other);
9595
}
9696
}
9797
}
@@ -100,7 +100,7 @@ exprt constant_pointer_abstract_objectt::to_constant() const
100100
{
101101
if(is_top() || is_bottom())
102102
{
103-
return pointer_abstract_objectt::to_constant();
103+
return abstract_pointer_objectt::to_constant();
104104
}
105105
else
106106
{
@@ -117,7 +117,7 @@ void constant_pointer_abstract_objectt::output(
117117
{
118118
if(is_top() || is_bottom() || value_stack.is_top_value())
119119
{
120-
pointer_abstract_objectt::output(out, ai, ns);
120+
abstract_pointer_objectt::output(out, ai, ns);
121121
}
122122
else
123123
{
@@ -180,7 +180,7 @@ abstract_object_pointert constant_pointer_abstract_objectt::write_dereference(
180180
{
181181
if(is_top() || is_bottom() || value_stack.is_top_value())
182182
{
183-
return pointer_abstract_objectt::write_dereference(
183+
return abstract_pointer_objectt::write_dereference(
184184
environment, ns, stack, new_value, merging_write);
185185
}
186186
else
@@ -225,7 +225,7 @@ void constant_pointer_abstract_objectt::get_statistics(
225225
const abstract_environmentt &env,
226226
const namespacet &ns) const
227227
{
228-
pointer_abstract_objectt::get_statistics(statistics, visited, env, ns);
228+
abstract_pointer_objectt::get_statistics(statistics, visited, env, ns);
229229
// don't bother following nullptr
230230
if(!is_top() && !is_bottom() && !value_stack.is_top_value())
231231
{

0 commit comments

Comments
 (0)