Skip to content

Commit c8c8594

Browse files
committed
Replace uses of exprt::make_not by boolean_negate
exprt::make_not is deprecated, and boolean_negate also performs additional type checking.
1 parent 34df81a commit c8c8594

21 files changed

+76
-103
lines changed

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "custom_bitvector_analysis.h"
1313

14-
#include <util/xml_expr.h>
14+
#include <util/expr_util.h>
1515
#include <util/simplify_expr.h>
16+
#include <util/xml_expr.h>
1617

1718
#include <langapi/language_util.h>
1819

@@ -527,7 +528,7 @@ void custom_bitvector_domaint::transform(
527528
// Comparing iterators is safe as the target must be within the same list
528529
// of instructions because this is a GOTO.
529530
if(to!=from->get_target())
530-
guard.make_not();
531+
guard = boolean_negate(guard);
531532

532533
exprt result=eval(guard, cba);
533534
exprt result2=simplify_expr(result, ns);

src/analyses/flow_insensitive_analysis.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <cassert>
1616

17-
#include <util/std_expr.h>
17+
#include <util/expr_util.h>
1818
#include <util/std_code.h>
19+
#include <util/std_expr.h>
1920

2021
exprt flow_insensitive_abstract_domain_baset::get_guard(
2122
locationt from,
@@ -28,11 +29,7 @@ exprt flow_insensitive_abstract_domain_baset::get_guard(
2829
next++;
2930

3031
if(next==to)
31-
{
32-
exprt tmp(from->guard);
33-
tmp.make_not();
34-
return tmp;
35-
}
32+
return boolean_negate(from->guard);
3633

3734
return from->guard;
3835
}

src/analyses/goto_check.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,9 @@ void goto_checkt::nan_check(
861861
else
862862
UNREACHABLE;
863863

864-
isnan.make_not();
865-
866864
add_guarded_claim(
867-
isnan,
868-
"NaN on "+expr.id_string(),
865+
boolean_negate(isnan),
866+
"NaN on " + expr.id_string(),
869867
"NaN",
870868
expr.find_source_location(),
871869
expr,

src/analyses/invariant_set.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <iostream>
1515

16+
#include <util/arith_tools.h>
1617
#include <util/base_exceptions.h>
17-
#include <util/symbol_table.h>
18+
#include <util/base_type.h>
19+
#include <util/c_types.h>
20+
#include <util/expr_util.h>
1821
#include <util/namespace.h>
19-
#include <util/arith_tools.h>
20-
#include <util/std_expr.h>
2122
#include <util/simplify_expr.h>
22-
#include <util/base_type.h>
23+
#include <util/std_expr.h>
2324
#include <util/std_types.h>
25+
#include <util/symbol_table.h>
2426

25-
#include <util/c_types.h>
2627
#include <langapi/language_util.h>
2728

2829
void inv_object_storet::output(std::ostream &out) const
@@ -758,10 +759,9 @@ void invariant_sett::nnf(exprt &expr, bool negate)
758759
nnf(tmp, !negate);
759760
expr.swap(tmp);
760761
}
761-
else
762+
else if(negate)
762763
{
763-
if(negate)
764-
expr.make_not();
764+
expr = boolean_negate(expr);
765765
}
766766
}
767767
else if(expr.id()==ID_le)
@@ -812,10 +812,9 @@ void invariant_sett::nnf(exprt &expr, bool negate)
812812
if(negate)
813813
expr.id(ID_equal);
814814
}
815-
else
815+
else if(negate)
816816
{
817-
if(negate)
818-
expr.make_not();
817+
expr = boolean_negate(expr);
819818
}
820819
}
821820

src/analyses/invariant_set_domain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "invariant_set_domain.h"
1313

14+
#include <util/expr_util.h>
1415
#include <util/simplify_expr.h>
1516

1617
void invariant_set_domaint::transform(
@@ -32,7 +33,7 @@ void invariant_set_domaint::transform(
3233
goto_programt::const_targett next=from_l;
3334
next++;
3435
if(next==to_l)
35-
tmp.make_not();
36+
tmp = boolean_negate(from_l->guard);
3637

3738
simplify(tmp, ns);
3839
invariant_set.strengthen(tmp);

src/analyses/static_analysis.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Author: Daniel Kroening, [email protected]
1515
#include <cassert>
1616
#include <memory>
1717

18-
#include <util/std_expr.h>
18+
#include <util/expr_util.h>
1919
#include <util/std_code.h>
20+
#include <util/std_expr.h>
2021

2122
#include "is_threaded.h"
2223

@@ -31,11 +32,7 @@ exprt static_analysis_baset::get_guard(
3132
next++;
3233

3334
if(next==to)
34-
{
35-
exprt tmp(from->guard);
36-
tmp.make_not();
37-
return tmp;
38-
}
35+
return boolean_negate(from->guard);
3936

4037
return from->guard;
4138
}

src/goto-instrument/branch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected]
1212
#include "branch.h"
1313

1414
#include <util/cprover_prefix.h>
15+
#include <util/expr_util.h>
1516
#include <util/prefix.h>
1617

1718
#include "function.h"
@@ -48,7 +49,7 @@ void branch(
4849
!i_it->guard.is_constant())
4950
{
5051
// negate condition
51-
i_it->guard.make_not();
52+
i_it->guard = boolean_negate(i_it->guard);
5253

5354
goto_programt::targett t1=body.insert_after(i_it);
5455
t1->make_function_call(

src/goto-instrument/code_contracts.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Date: February 2016
1313

1414
#include "code_contracts.h"
1515

16+
#include <util/expr_util.h>
1617
#include <util/fresh_symbol.h>
1718
#include <util/replace_symbol.h>
1819

@@ -158,7 +159,7 @@ static void check_apply_invariants(
158159
if(loop_head->is_goto())
159160
loop_end->guard.make_false();
160161
else
161-
loop_end->guard.make_not();
162+
loop_end->guard = boolean_negate(loop_end->guard);
162163
}
163164

164165
void code_contractst::apply_contract(

src/goto-instrument/cover_instrument_mcdc.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Author: Daniel Kroening
1111

1212
#include "cover_instrument.h"
1313

14+
#include <util/expr_util.h>
15+
1416
#include <langapi/language_util.h>
1517

1618
#include <algorithm>
@@ -73,7 +75,7 @@ void collect_mcdc_controlling_rec(
7375
new_conditions.push_back(conjunction(o));
7476
result.insert(conjunction(new_conditions));
7577

76-
o[i].make_not();
78+
o[i] = boolean_negate(op);
7779
new_conditions.back() = conjunction(o);
7880
result.insert(conjunction(new_conditions));
7981
}

src/goto-instrument/unwind.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ Author: Daniel Kroening, [email protected]
1616
#include <iostream>
1717
#endif
1818

19+
#include <util/expr_util.h>
1920
#include <util/std_expr.h>
2021
#include <util/string_utils.h>
22+
2123
#include <goto-programs/goto_functions.h>
2224

2325
#include "loop_utils.h"
@@ -127,8 +129,7 @@ void goto_unwindt::unwind(
127129

128130
if(!t->guard.is_true()) // cond in backedge
129131
{
130-
exit_cond=t->guard;
131-
exit_cond.make_not();
132+
exit_cond = boolean_negate(t->guard);
132133
}
133134
else if(loop_head->is_goto())
134135
{

src/goto-programs/goto_convert.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,7 @@ void goto_convertt::convert_for(
980980

981981
// v: if(!c) goto z;
982982
v->make_goto(z);
983-
v->guard=cond;
984-
v->guard.make_not();
983+
v->guard = boolean_negate(cond);
985984
v->source_location=cond.source_location();
986985

987986
// do the w label

src/goto-programs/goto_convert_function_call.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ Author: Daniel Kroening, [email protected]
1212
#include "goto_convert_class.h"
1313

1414

15-
#include <util/replace_expr.h>
16-
#include <util/source_location.h>
1715
#include <util/cprover_prefix.h>
16+
#include <util/expr_util.h>
1817
#include <util/prefix.h>
18+
#include <util/replace_expr.h>
19+
#include <util/source_location.h>
1920
#include <util/std_expr.h>
2021

2122
#include <util/c_types.h>
@@ -135,8 +136,7 @@ void goto_convertt::do_function_call_if(
135136

136137
// v: if(!c) goto y;
137138
v->make_goto(y);
138-
v->guard=function.cond();
139-
v->guard.make_not();
139+
v->guard = boolean_negate(function.cond());
140140
v->source_location=function.cond().source_location();
141141

142142
// w: f();

src/goto-programs/string_abstraction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/arith_tools.h>
1717
#include <util/c_types.h>
1818
#include <util/exception_utils.h>
19+
#include <util/expr_util.h>
1920
#include <util/pointer_predicates.h>
2021
#include <util/type_eq.h>
2122

@@ -1273,8 +1274,7 @@ goto_programt::targett string_abstractiont::value_assignments_if(
12731274

12741275
goto_else->function=target->function;
12751276
goto_else->source_location=target->source_location;
1276-
goto_else->make_goto(else_target, rhs.cond());
1277-
goto_else->guard.make_not();
1277+
goto_else->make_goto(else_target, boolean_negate(rhs.cond()));
12781278

12791279
goto_out->function=target->function;
12801280
goto_out->source_location=target->source_location;

src/goto-symex/slice_by_trace.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ void symex_slice_by_tracet::slice_by_trace(
8888

8989
if(g_copy.id()==ID_symbol || g_copy.id() == ID_not)
9090
{
91-
g_copy.make_not();
92-
simplify(g_copy, ns);
91+
g_copy = simplify_expr(boolean_negate(g_copy), ns);
9392
implications.insert(g_copy);
9493
}
9594
else if(g_copy.id()==ID_and)
9695
{
97-
exprt copy_last(g_copy.operands().back());
98-
copy_last.make_not();
96+
exprt copy_last = boolean_negate(g_copy.operands().back());
9997
simplify(copy_last, ns);
10098
implications.insert(copy_last);
10199
}
@@ -408,8 +406,7 @@ void symex_slice_by_tracet::slice_SSA_steps(
408406

409407
if((guard.id()==ID_symbol) || (guard.id() == ID_not))
410408
{
411-
guard.make_not();
412-
simplify(guard, ns);
409+
guard = simplify_expr(boolean_negate(guard), ns);
413410

414411
if(implications.count(guard)!=0)
415412
{
@@ -426,8 +423,7 @@ void symex_slice_by_tracet::slice_SSA_steps(
426423
{
427424
Forall_operands(git, guard)
428425
{
429-
exprt neg_expr=*git;
430-
neg_expr.make_not();
426+
exprt neg_expr = boolean_negate(*git);
431427
simplify(neg_expr, ns);
432428

433429
if(implications.count(neg_expr)!=0)
@@ -466,8 +462,7 @@ void symex_slice_by_tracet::slice_SSA_steps(
466462
}
467463
else
468464
{
469-
cond_copy.make_not();
470-
simplify(cond_copy, ns);
465+
cond_copy = simplify_expr(boolean_negate(cond_copy), ns);
471466
if(implications.count(cond_copy)!=0)
472467
{
473468
sliced_conds++;
@@ -622,8 +617,7 @@ bool symex_slice_by_tracet::implies_false(const exprt e)
622617
i=imps.begin();
623618
i!=imps.end(); i++)
624619
{
625-
exprt i_copy(*i);
626-
i_copy.make_not();
620+
exprt i_copy = boolean_negate(*i);
627621
simplify(i_copy, ns);
628622
if(imps.count(i_copy)!=0)
629623
return true;

src/goto-symex/symex_goto.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <algorithm>
1515

1616
#include <util/exception_utils.h>
17+
#include <util/expr_util.h>
1718
#include <util/invariant.h>
1819
#include <util/pointer_offset_size.h>
1920
#include <util/range.h>
@@ -242,8 +243,7 @@ void goto_symext::symex_goto(statet &state)
242243
{
243244
symbol_exprt guard_symbol_expr=
244245
symbol_exprt(guard_identifier, bool_typet());
245-
exprt new_rhs=new_guard;
246-
new_rhs.make_not();
246+
exprt new_rhs = boolean_negate(new_guard);
247247

248248
ssa_exprt new_lhs(guard_symbol_expr);
249249
state.rename(new_lhs, ns, goto_symex_statet::L1);
@@ -266,8 +266,7 @@ void goto_symext::symex_goto(statet &state)
266266
original_source,
267267
symex_targett::assignment_typet::GUARD);
268268

269-
guard_expr=guard_symbol_expr;
270-
guard_expr.make_not();
269+
guard_expr = boolean_negate(guard_symbol_expr);
271270
state.rename(guard_expr, ns);
272271
}
273272

@@ -276,25 +275,20 @@ void goto_symext::symex_goto(statet &state)
276275
if(!backward)
277276
state.guard.add(guard_expr);
278277
else
279-
{
280-
guard_expr.make_not();
281-
state.guard.add(guard_expr);
282-
}
278+
state.guard.add(boolean_negate(guard_expr));
283279
}
284280
else
285281
{
286282
statet::goto_statet &new_state = goto_state_list.back();
287283
if(!backward)
288284
{
289285
new_state.guard.add(guard_expr);
290-
guard_expr.make_not();
291-
state.guard.add(guard_expr);
286+
state.guard.add(boolean_negate(guard_expr));
292287
}
293288
else
294289
{
295290
state.guard.add(guard_expr);
296-
guard_expr.make_not();
297-
new_state.guard.add(guard_expr);
291+
new_state.guard.add(boolean_negate(guard_expr));
298292
}
299293
}
300294
}

0 commit comments

Comments
 (0)