Skip to content

Commit 2b5c3e0

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 2b5c3e0

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

src/goto-instrument/rw_set.cpp

Lines changed: 24 additions & 22 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,21 @@ 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(
119+
expr.op0(), r, w, "." + component_name + suffix, guard_conjuncts);
118120
}
119121
else if(expr.id()==ID_index)
120122
{
121123
// we don't distinguish the array elements for now
122124
assert(expr.operands().size()==2);
123-
read_write_rec(expr.op0(), r, w, "[]"+suffix, guard);
124-
read(expr.op1(), guard);
125+
read_write_rec(expr.op0(), r, w, "[]" + suffix, guard_conjuncts);
126+
read(expr.op1(), guard_conjuncts);
125127
}
126128
else if(expr.id()==ID_dereference)
127129
{
128130
assert(expr.operands().size()==1);
129131
set_track_deref();
130-
read(expr.op0(), guard);
132+
read(expr.op0(), guard_conjuncts);
131133

132134
exprt tmp=expr;
133135
#ifdef LOCAL_MAY
@@ -147,25 +149,25 @@ void _rw_set_loct::read_write_rec(
147149
entryt &entry=r_entries[object];
148150
entry.object=object;
149151
entry.symbol_expr=symbol_exprt(ID_unknown);
150-
entry.guard=guard.as_expr(); // should 'OR'
152+
entry.guard = conjunction(guard_conjuncts); // should 'OR'
151153

152154
continue;
153155
}
154156
#endif
155-
read_write_rec(*it, r, w, suffix, guard);
157+
read_write_rec(*it, r, w, suffix, guard_conjuncts);
156158
}
157159
#else
158160
dereference(function_id, target, tmp, ns, value_sets);
159161

160-
read_write_rec(tmp, r, w, suffix, guard);
161-
#endif
162+
read_write_rec(tmp, r, w, suffix, guard_conjuncts);
163+
#endif
162164

163165
reset_track_deref();
164166
}
165167
else if(expr.id()==ID_typecast)
166168
{
167169
assert(expr.operands().size()==1);
168-
read_write_rec(expr.op0(), r, w, suffix, guard);
170+
read_write_rec(expr.op0(), r, w, suffix, guard_conjuncts);
169171
}
170172
else if(expr.id()==ID_address_of)
171173
{
@@ -174,20 +176,20 @@ void _rw_set_loct::read_write_rec(
174176
else if(expr.id()==ID_if)
175177
{
176178
assert(expr.operands().size()==3);
177-
read(expr.op0(), guard);
179+
read(expr.op0(), guard_conjuncts);
178180

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

183-
guardt false_guard(guard);
184-
false_guard.add(not_exprt(expr.op0()));
185+
exprt::operandst false_guard = guard_conjuncts;
186+
false_guard.push_back(not_exprt(expr.op0()));
185187
read_write_rec(expr.op2(), r, w, suffix, false_guard);
186188
}
187189
else
188190
{
189191
forall_operands(it, expr)
190-
read_write_rec(*it, r, w, suffix, guard);
192+
read_write_rec(*it, r, w, suffix, guard_conjuncts);
191193
}
192194
}
193195

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)