Skip to content

Commit 5377c2c

Browse files
authored
Merge pull request diffblue#4301 from romainbrenguier/refactor/simplify_expr_copy
Make simplify_expr take copy instead of reference
2 parents f61d33d + 94b2145 commit 5377c2c

File tree

8 files changed

+18
-20
lines changed

8 files changed

+18
-20
lines changed

src/analyses/ai_domain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bool ai_domain_baset::ai_simplify_lhs(exprt &condition, const namespacet &ns)
4848
index_exprt ie = to_index_expr(condition);
4949
bool no_simplification = ai_simplify(ie.index(), ns);
5050
if(!no_simplification)
51-
condition = simplify_expr(ie, ns);
51+
condition = simplify_expr(std::move(ie), ns);
5252

5353
return no_simplification;
5454
}
@@ -57,7 +57,7 @@ bool ai_domain_baset::ai_simplify_lhs(exprt &condition, const namespacet &ns)
5757
dereference_exprt de = to_dereference_expr(condition);
5858
bool no_simplification = ai_simplify(de.pointer(), ns);
5959
if(!no_simplification)
60-
condition = simplify_expr(de, ns); // So *(&x) -> x
60+
condition = simplify_expr(std::move(de), ns); // So *(&x) -> x
6161

6262
return no_simplification;
6363
}
@@ -70,7 +70,7 @@ bool ai_domain_baset::ai_simplify_lhs(exprt &condition, const namespacet &ns)
7070
// must also be addressable
7171
bool no_simplification = ai_simplify_lhs(me.compound(), ns);
7272
if(!no_simplification)
73-
condition = simplify_expr(me, ns);
73+
condition = simplify_expr(std::move(me), ns);
7474

7575
return no_simplification;
7676
}

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,7 @@ void custom_bitvector_domaint::transform(
529529
if(to!=from->get_target())
530530
guard = boolean_negate(guard);
531531

532-
exprt result=eval(guard, cba);
533-
exprt result2=simplify_expr(result, ns);
532+
const exprt result2 = simplify_expr(eval(guard, cba), ns);
534533

535534
if(result2.is_false())
536535
make_bottom();
@@ -787,7 +786,7 @@ void custom_bitvector_analysist::check(
787786

788787
exprt tmp = eval(i_it->get_condition(), i_it);
789788
const namespacet ns(goto_model.symbol_table);
790-
result=simplify_expr(tmp, ns);
789+
result = simplify_expr(std::move(tmp), ns);
791790

792791
description=i_it->source_location.get_comment();
793792
}

src/goto-analyzer/taint_analysis.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,7 @@ bool taint_analysist::operator()(
343343

344344
exprt result =
345345
custom_bitvector_analysis.eval(i_it->get_condition(), i_it);
346-
exprt result2=simplify_expr(result, ns);
347-
348-
if(result2.is_true())
346+
if(simplify_expr(std::move(result), ns).is_true())
349347
continue;
350348

351349
if(first)

src/goto-instrument/accelerate/acceleration_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,13 +1120,13 @@ bool acceleration_utilst::assign_array(
11201120
{
11211121
replace_expr(
11221122
loop_counter, from_integer(0, loop_counter.type()), lower_bound);
1123-
simplify_expr(lower_bound, ns);
1123+
lower_bound = simplify_expr(std::move(lower_bound), ns);
11241124
}
11251125
else
11261126
{
11271127
replace_expr(
11281128
loop_counter, from_integer(0, loop_counter.type()), upper_bound);
1129-
simplify_expr(upper_bound, ns);
1129+
upper_bound = simplify_expr(std::move(upper_bound), ns);
11301130
}
11311131

11321132
if(stride==0)

src/solvers/lowering/byte_operators.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ exprt lower_byte_extract(const byte_extract_exprt &src, const namespacet &ns)
10121012
}
10131013

10141014
if(!failed)
1015-
return simplify_expr(s, ns);
1015+
return simplify_expr(std::move(s), ns);
10161016
}
10171017
else if(src.type().id() == ID_union || src.type().id() == ID_union_tag)
10181018
{
@@ -1183,7 +1183,7 @@ static exprt lower_byte_update_byte_array_vector(
11831183
result.add_to_operands(where, update_value);
11841184
}
11851185

1186-
return simplify_expr(result, ns);
1186+
return simplify_expr(std::move(result), ns);
11871187
}
11881188

11891189
/// Apply a byte update \p src to an array/vector typed operand, using the byte
@@ -1328,7 +1328,7 @@ static exprt lower_byte_update_array_vector_non_const(
13281328
result.add_to_operands(std::move(where), std::move(element));
13291329
}
13301330

1331-
return simplify_expr(result, ns);
1331+
return simplify_expr(std::move(result), ns);
13321332
}
13331333

13341334
/// Apply a byte update \p src to an array/vector typed operand using the byte

src/util/simplify_expr.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,9 +2574,8 @@ bool simplify(exprt &expr, const namespacet &ns)
25742574
return simplify_exprt(ns).simplify(expr);
25752575
}
25762576

2577-
exprt simplify_expr(const exprt &src, const namespacet &ns)
2577+
exprt simplify_expr(exprt src, const namespacet &ns)
25782578
{
2579-
exprt tmp=src;
2580-
simplify_exprt(ns).simplify(tmp);
2581-
return tmp;
2579+
simplify_exprt(ns).simplify(src);
2580+
return src;
25822581
}

src/util/simplify_expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ bool simplify(
2525
const namespacet &ns);
2626

2727
// this is the preferred interface
28-
exprt simplify_expr(const exprt &src, const namespacet &ns);
28+
exprt simplify_expr(exprt src, const namespacet &ns);
2929

3030
#endif // CPROVER_UTIL_SIMPLIFY_EXPR_H

unit/solvers/strings/string_constraint_generator_valueof/is_digit_with_radix.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ static exprt actual(
2929
const namespacet ns(symtab);
3030

3131
return simplify_expr(
32-
is_digit_with_radix(chr, strict_formatting, radix_as_char, radix_ul), ns);
32+
is_digit_with_radix(
33+
std::move(chr), strict_formatting, radix_as_char, radix_ul),
34+
ns);
3335
}
3436

3537
/// Get the simplified return value of is_digit_with_radix called with a radix

0 commit comments

Comments
 (0)