Skip to content

Commit 663be93

Browse files
committed
Remove unnecessary use of make_not
The application of make_not on a not_exprt would just yield the operand. As a desirable side effect, this also avoids modifying operations on expressions.
1 parent c8c8594 commit 663be93

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/goto-instrument/cover_instrument_mcdc.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,24 @@ std::set<signed> sign_of_expr(const exprt &e, const exprt &E)
281281
// In the general case, we analyze each operand of ''E''.
282282
std::vector<exprt> ops;
283283
collect_operands(E, ops);
284-
for(auto &x : ops)
284+
for(const auto &x : ops)
285285
{
286-
exprt y(x);
287-
if(y == e)
286+
if(x == e)
288287
signs.insert(+1);
289-
else if(y.id() == ID_not)
288+
else if(x.id() == ID_not)
290289
{
291-
y.make_not();
292-
if(y == e)
290+
const exprt &x_op = to_not_expr(x).op();
291+
if(x_op == e)
293292
signs.insert(-1);
294-
if(!is_condition(y))
293+
if(!is_condition(x_op))
295294
{
296-
std::set<signed> re = sign_of_expr(e, y);
295+
std::set<signed> re = sign_of_expr(e, x_op);
297296
signs.insert(re.begin(), re.end());
298297
}
299298
}
300-
else if(!is_condition(y))
299+
else if(!is_condition(x))
301300
{
302-
std::set<signed> re = sign_of_expr(e, y);
301+
std::set<signed> re = sign_of_expr(e, x);
303302
signs.insert(re.begin(), re.end());
304303
}
305304
}
@@ -422,9 +421,7 @@ bool eval_expr(const std::map<exprt, signed> &atomic_exprs, const exprt &src)
422421
// src is NOT
423422
else if(src.id() == ID_not)
424423
{
425-
exprt no_op(src);
426-
no_op.make_not();
427-
return !eval_expr(atomic_exprs, no_op);
424+
return !eval_expr(atomic_exprs, to_not_expr(src).op());
428425
}
429426
else // if(is_condition(src))
430427
{

0 commit comments

Comments
 (0)