Skip to content

Commit f931965

Browse files
committed
Document and refactor invalidate
Using the initializer-list constructor for sets and and standard idiom for erase_if.
1 parent 2662f2b commit f931965

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/analyses/goto_check.cpp

+9-12
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ class goto_checkt
188188
typedef std::set<exprt> assertionst;
189189
assertionst assertions;
190190

191+
/// Remove all assertions containing the symbol in \p lhs as well as all
192+
/// assertions containing dereference.
193+
/// \param lhs: the left-hand-side expression whose symbol should be
194+
/// invalidated
191195
void invalidate(const exprt &lhs);
192196

193197
bool enable_bounds_check;
@@ -261,21 +265,14 @@ void goto_checkt::invalidate(const exprt &lhs)
261265
else if(lhs.id()==ID_symbol)
262266
{
263267
// clear all assertions about 'symbol'
264-
find_symbols_sett find_symbols_set;
265-
find_symbols_set.insert(to_symbol_expr(lhs).get_identifier());
268+
find_symbols_sett find_symbols_set{to_symbol_expr(lhs).get_identifier()};
266269

267-
for(assertionst::iterator
268-
it=assertions.begin();
269-
it!=assertions.end();
270-
) // no it++
270+
for(auto it = assertions.begin(); it != assertions.end();)
271271
{
272-
assertionst::iterator next=it;
273-
next++;
274-
275272
if(has_symbol(*it, find_symbols_set) || has_subexpr(*it, ID_dereference))
276-
assertions.erase(it);
277-
278-
it=next;
273+
it = assertions.erase(it);
274+
else
275+
++it;
279276
}
280277
}
281278
else

0 commit comments

Comments
 (0)