Skip to content

Commit 01eff0f

Browse files
Replace guardt by exprt::operandst in rw_set
This was not making really use of guardt, since no guardt specific operations where performed, but instead just represents a conjunction. We replace that by a list of expressions and do the conjunction when needed. This avoids dependencies on guardt.
1 parent 560f0df commit 01eff0f

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

src/goto-instrument/rw_set.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ void _rw_set_loct::compute()
7979
void _rw_set_loct::assign(const exprt &lhs, const exprt &rhs)
8080
{
8181
read(rhs);
82-
read_write_rec(lhs, false, true, "", guardt(true_exprt()));
82+
read_write_rec(lhs, false, true, "", exprt::operandst());
8383
}
8484

8585
void _rw_set_loct::read_write_rec(
8686
const exprt &expr,
87-
bool r, bool w,
87+
bool r,
88+
bool w,
8889
const std::string &suffix,
89-
const guardt &guard)
90+
const exprt::operandst &guard_conjuncts)
9091
{
9192
if(expr.id()==ID_symbol)
9293
{
@@ -96,16 +97,16 @@ void _rw_set_loct::read_write_rec(
9697

9798
if(r)
9899
{
99-
const auto &entry =
100-
r_entries.emplace(object, entryt(symbol_expr, object, guard.as_expr()));
100+
const auto &entry = r_entries.emplace(
101+
object, entryt(symbol_expr, object, conjunction(guard_conjuncts)));
101102

102103
track_deref(entry.first->second, true);
103104
}
104105

105106
if(w)
106107
{
107-
const auto &entry =
108-
w_entries.emplace(object, entryt(symbol_expr, object, guard.as_expr()));
108+
const auto &entry = w_entries.emplace(
109+
object, entryt(symbol_expr, object, conjunction(guard_conjuncts)));
109110

110111
track_deref(entry.first->second, false);
111112
}
@@ -114,20 +115,20 @@ void _rw_set_loct::read_write_rec(
114115
{
115116
assert(expr.operands().size()==1);
116117
const std::string &component_name=expr.get_string(ID_component_name);
117-
read_write_rec(expr.op0(), r, w, "."+component_name+suffix, guard);
118+
read_write_rec(expr.op0(), r, w, "."+component_name+suffix, guard_conjuncts);
118119
}
119120
else if(expr.id()==ID_index)
120121
{
121122
// we don't distinguish the array elements for now
122123
assert(expr.operands().size()==2);
123-
read_write_rec(expr.op0(), r, w, "[]"+suffix, guard);
124-
read(expr.op1(), guard);
124+
read_write_rec(expr.op0(), r, w, "[]"+suffix, guard_conjuncts);
125+
read(expr.op1(), guard_conjuncts);
125126
}
126127
else if(expr.id()==ID_dereference)
127128
{
128129
assert(expr.operands().size()==1);
129130
set_track_deref();
130-
read(expr.op0(), guard);
131+
read(expr.op0(), guard_conjuncts);
131132

132133
exprt tmp=expr;
133134
#ifdef LOCAL_MAY
@@ -147,25 +148,25 @@ void _rw_set_loct::read_write_rec(
147148
entryt &entry=r_entries[object];
148149
entry.object=object;
149150
entry.symbol_expr=symbol_exprt(ID_unknown);
150-
entry.guard=guard.as_expr(); // should 'OR'
151+
entry.guard=conjunction(guard_conjuncts); // should 'OR'
151152

152153
continue;
153154
}
154155
#endif
155-
read_write_rec(*it, r, w, suffix, guard);
156+
read_write_rec(*it, r, w, suffix, guard_conjuncts);
156157
}
157158
#else
158159
dereference(function_id, target, tmp, ns, value_sets);
159160

160-
read_write_rec(tmp, r, w, suffix, guard);
161+
read_write_rec(tmp, r, w, suffix, guard_conjuncts);
161162
#endif
162163

163164
reset_track_deref();
164165
}
165166
else if(expr.id()==ID_typecast)
166167
{
167168
assert(expr.operands().size()==1);
168-
read_write_rec(expr.op0(), r, w, suffix, guard);
169+
read_write_rec(expr.op0(), r, w, suffix, guard_conjuncts);
169170
}
170171
else if(expr.id()==ID_address_of)
171172
{
@@ -174,20 +175,20 @@ void _rw_set_loct::read_write_rec(
174175
else if(expr.id()==ID_if)
175176
{
176177
assert(expr.operands().size()==3);
177-
read(expr.op0(), guard);
178+
read(expr.op0(), guard_conjuncts);
178179

179-
guardt true_guard(guard);
180-
true_guard.add(expr.op0());
180+
exprt::operandst true_guard = guard_conjuncts;
181+
true_guard.push_back(expr.op0());
181182
read_write_rec(expr.op1(), r, w, suffix, true_guard);
182183

183-
guardt false_guard(guard);
184-
false_guard.add(not_exprt(expr.op0()));
184+
exprt::operandst false_guard = guard_conjuncts;
185+
false_guard.push_back(not_exprt(expr.op0()));
185186
read_write_rec(expr.op2(), r, w, suffix, false_guard);
186187
}
187188
else
188189
{
189190
forall_operands(it, expr)
190-
read_write_rec(*it, r, w, suffix, guard);
191+
read_write_rec(*it, r, w, suffix, guard_conjuncts);
191192
}
192193
}
193194

src/goto-instrument/rw_set.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Date: February 2006
1818
#include <vector>
1919
#include <set>
2020

21-
#include <util/guard.h>
2221
#include <util/std_expr.h>
2322

2423
#include <goto-programs/goto_model.h>
@@ -158,17 +157,17 @@ class _rw_set_loct:public rw_set_baset
158157

159158
void read(const exprt &expr)
160159
{
161-
read_write_rec(expr, true, false, "", guardt(true_exprt()));
160+
read_write_rec(expr, true, false, "", exprt::operandst());
162161
}
163162

164-
void read(const exprt &expr, const guardt &guard)
163+
void read(const exprt &expr, const exprt::operandst &guard_conjuncts)
165164
{
166-
read_write_rec(expr, true, false, "", guard);
165+
read_write_rec(expr, true, false, "", guard_conjuncts);
167166
}
168167

169168
void write(const exprt &expr)
170169
{
171-
read_write_rec(expr, false, true, "", guardt(true_exprt()));
170+
read_write_rec(expr, false, true, "", exprt::operandst());
172171
}
173172

174173
void compute();
@@ -177,9 +176,10 @@ class _rw_set_loct:public rw_set_baset
177176

178177
void read_write_rec(
179178
const exprt &expr,
180-
bool r, bool w,
179+
bool r,
180+
bool w,
181181
const std::string &suffix,
182-
const guardt &guard);
182+
const exprt::operandst &guard_conjuncts);
183183
};
184184

185185
class rw_set_loct:public _rw_set_loct

0 commit comments

Comments
 (0)