-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathlocal_bitvector_analysis.h
215 lines (169 loc) · 3.97 KB
/
local_bitvector_analysis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*******************************************************************\
Module: Field-insensitive, location-sensitive bitvector analysis
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// Field-insensitive, location-sensitive bitvector analysis
#ifndef CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H
#define CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H
#include <util/expanding_vector.h>
#include <util/numbering.h>
#include "locals.h"
#include "dirty.h"
#include "local_cfg.h"
class local_bitvector_analysist
{
public:
typedef goto_functionst::goto_functiont goto_functiont;
local_bitvector_analysist(
const goto_functiont &_goto_function,
const namespacet &ns)
: dirty(_goto_function),
locals(_goto_function),
cfg(_goto_function.body),
ns(ns)
{
build();
}
void output(
std::ostream &out,
const goto_functiont &goto_function,
const namespacet &ns) const;
dirtyt dirty;
localst locals;
local_cfgt cfg;
// categories of things one can point to
struct flagst
{
flagst():bits(0)
{
}
void clear()
{
bits=0;
}
// the bits for the "bitvector analysis"
enum bitst
{
B_unknown=1<<0,
B_uninitialized=1<<1,
B_uses_offset=1<<2,
B_dynamic_local=1<<3,
B_dynamic_heap=1<<4,
B_null=1<<5,
B_static_lifetime=1<<6,
B_integer_address=1<<7
};
explicit flagst(const bitst _bits):bits(_bits)
{
}
unsigned bits;
bool merge(const flagst &other)
{
unsigned old=bits;
bits|=other.bits; // bit-wise or
return old!=bits;
}
static flagst mk_unknown()
{
return flagst(B_unknown);
}
bool is_unknown() const
{
return (bits&B_unknown)!=0;
}
static flagst mk_uninitialized()
{
return flagst(B_uninitialized);
}
bool is_uninitialized() const
{
return (bits&B_uninitialized)!=0;
}
static flagst mk_uses_offset()
{
return flagst(B_uses_offset);
}
bool is_uses_offset() const
{
return (bits&B_uses_offset)!=0;
}
static flagst mk_dynamic_local()
{
return flagst(B_dynamic_local);
}
bool is_dynamic_local() const
{
return (bits&B_dynamic_local)!=0;
}
static flagst mk_dynamic_heap()
{
return flagst(B_dynamic_heap);
}
bool is_dynamic_heap() const
{
return (bits&B_dynamic_heap)!=0;
}
static flagst mk_null()
{
return flagst(B_null);
}
bool is_null() const
{
return (bits&B_null)!=0;
}
static flagst mk_static_lifetime()
{
return flagst(B_static_lifetime);
}
bool is_static_lifetime() const
{
return (bits&B_static_lifetime)!=0;
}
static flagst mk_integer_address()
{
return flagst(B_integer_address);
}
bool is_integer_address() const
{
return (bits&B_integer_address)!=0;
}
void print(std::ostream &) const;
flagst operator|(const flagst other) const
{
flagst result(*this);
result.bits|=other.bits;
return result;
}
};
flagst get(
const goto_programt::const_targett t,
const exprt &src);
protected:
const namespacet &ns;
void build();
numberingt<irep_idt> pointers;
// pointers -> flagst
// This is a vector, so it's fast.
typedef expanding_vectort<flagst> points_tot;
static bool merge(points_tot &a, points_tot &b);
typedef std::vector<points_tot> loc_infost;
loc_infost loc_infos;
void assign_lhs(
const exprt &lhs,
const exprt &rhs,
points_tot &loc_info_src,
points_tot &loc_info_dest);
flagst get_rec(
const exprt &rhs,
points_tot &loc_info_src);
bool is_tracked(const irep_idt &identifier);
};
inline std::ostream &operator<<(
std::ostream &out,
const local_bitvector_analysist::flagst &flags)
{
flags.print(out);
return out;
}
#endif // CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H