Skip to content

Commit b95e229

Browse files
authored
Merge pull request #6378 from diffblue/is_lvalue
rename is_lvalue -> is_assignable
2 parents 01505ec + b29a6db commit b95e229

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

src/analyses/variable-sensitivity/abstract_environment.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,14 +711,14 @@ exprt assume_eq_unbounded(
711711
const left_and_right_valuest &operands,
712712
const namespacet &ns)
713713
{
714-
if(operands.left->is_top() && is_lvalue(operands.lhs))
714+
if(operands.left->is_top() && is_assignable(operands.lhs))
715715
{
716716
// TOP == x
717717
auto constrained = std::make_shared<interval_abstract_valuet>(
718718
operands.right_interval(), env, ns);
719719
prune_assign(env, operands.left, operands.lhs, constrained, ns);
720720
}
721-
if(operands.right->is_top() && is_lvalue(operands.rhs))
721+
if(operands.right->is_top() && is_assignable(operands.rhs))
722722
{
723723
// x == TOP
724724
auto constrained = std::make_shared<interval_abstract_valuet>(
@@ -746,9 +746,9 @@ exprt assume_eq(
746746
if(meet->is_bottom())
747747
return false_exprt();
748748

749-
if(is_lvalue(operands.lhs))
749+
if(is_assignable(operands.lhs))
750750
prune_assign(env, operands.left, operands.lhs, meet, ns);
751-
if(is_lvalue(operands.rhs))
751+
if(is_assignable(operands.rhs))
752752
prune_assign(env, operands.right, operands.rhs, meet, ns);
753753
return true_exprt();
754754
}
@@ -781,7 +781,7 @@ exprt assume_less_than_unbounded(
781781
const left_and_right_valuest &operands,
782782
const namespacet &ns)
783783
{
784-
if(operands.left->is_top() && is_lvalue(operands.lhs))
784+
if(operands.left->is_top() && is_assignable(operands.lhs))
785785
{
786786
// TOP < x, so prune range is min->right.upper
787787
auto pruned_expr = constant_interval_exprt(
@@ -792,7 +792,7 @@ exprt assume_less_than_unbounded(
792792
std::make_shared<interval_abstract_valuet>(pruned_expr, env, ns);
793793
prune_assign(env, operands.left, operands.lhs, constrained, ns);
794794
}
795-
if(operands.right->is_top() && is_lvalue(operands.rhs))
795+
if(operands.right->is_top() && is_assignable(operands.rhs))
796796
{
797797
// x < TOP, so prune range is left.lower->max
798798
auto pruned_expr = constant_interval_exprt(
@@ -830,15 +830,15 @@ exprt assume_less_than(
830830
auto result = env.eval(reduced_le_expr, ns)->to_constant();
831831
if(result.is_true())
832832
{
833-
if(is_lvalue(operands.lhs))
833+
if(is_assignable(operands.lhs))
834834
{
835835
auto pruned_upper = constant_interval_exprt::get_min(
836836
left_interval.get_upper(), right_upper);
837837
auto constrained =
838838
as_value(operands.left)->constrain(left_lower, pruned_upper);
839839
prune_assign(env, operands.left, operands.lhs, constrained, ns);
840840
}
841-
if(is_lvalue(operands.rhs))
841+
if(is_assignable(operands.rhs))
842842
{
843843
auto pruned_lower = constant_interval_exprt::get_max(
844844
left_lower, right_interval.get_lower());

src/goto-programs/builtin_functions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ exprt make_va_list(const exprt &expr)
597597
if(result.id() == ID_address_of)
598598
{
599599
const auto &address_of_expr = to_address_of_expr(result);
600-
if(is_lvalue(address_of_expr.object()))
600+
if(is_assignable(address_of_expr.object()))
601601
result = address_of_expr.object();
602602
}
603603

@@ -1156,7 +1156,7 @@ void goto_convertt::do_function_call_symbol(
11561156
exprt dest_expr=make_va_list(arguments[0]);
11571157
const typecast_exprt src_expr(arguments[1], dest_expr.type());
11581158

1159-
if(!is_lvalue(dest_expr))
1159+
if(!is_assignable(dest_expr))
11601160
{
11611161
error().source_location=dest_expr.find_source_location();
11621162
error() << "va_copy argument expected to be lvalue" << eom;
@@ -1179,7 +1179,7 @@ void goto_convertt::do_function_call_symbol(
11791179

11801180
exprt dest_expr=make_va_list(arguments[0]);
11811181

1182-
if(!is_lvalue(dest_expr))
1182+
if(!is_assignable(dest_expr))
11831183
{
11841184
error().source_location=dest_expr.find_source_location();
11851185
error() << "va_start argument expected to be lvalue" << eom;
@@ -1214,7 +1214,7 @@ void goto_convertt::do_function_call_symbol(
12141214

12151215
exprt dest_expr=make_va_list(arguments[0]);
12161216

1217-
if(!is_lvalue(dest_expr))
1217+
if(!is_assignable(dest_expr))
12181218
{
12191219
error().source_location=dest_expr.find_source_location();
12201220
error() << "va_end argument expected to be lvalue" << eom;

src/util/expr_util.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@ Author: Daniel Kroening, [email protected]
1818
#include "pointer_expr.h"
1919
#include "std_expr.h"
2020

21-
bool is_lvalue(const exprt &expr)
21+
bool is_assignable(const exprt &expr)
2222
{
2323
if(expr.id() == ID_index)
24-
return is_lvalue(to_index_expr(expr).array());
24+
return is_assignable(to_index_expr(expr).array());
2525
else if(expr.id() == ID_member)
26-
return is_lvalue(to_member_expr(expr).compound());
26+
return is_assignable(to_member_expr(expr).compound());
2727
else if(expr.id() == ID_dereference)
2828
return true;
2929
else if(expr.id() == ID_symbol)
3030
return true;
3131
else
3232
return false;
3333
}
34+
3435
exprt make_binary(const exprt &expr)
3536
{
3637
const exprt::operandst &operands=expr.operands();

src/util/expr_util.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ class if_exprt;
2929
class typet;
3030
class namespacet;
3131

32-
/// Returns true iff the argument is (syntactically) an lvalue.
33-
bool is_lvalue(const exprt &expr);
32+
/// Returns true iff the argument is one of the following:
33+
/// * a symbol
34+
/// * a dereference
35+
/// * an array element
36+
/// * a struct member
37+
bool is_assignable(const exprt &);
3438

3539
/// splits an expression with >=3 operands into nested binary expressions
3640
exprt make_binary(const exprt &);

src/util/replace_symbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool address_of_aware_replace_symbolt::replace_symbol_expr(
335335
if(unchecked_replace_symbolt::replace_symbol_expr(s_copy))
336336
return true;
337337

338-
if(require_lvalue && !is_lvalue(s_copy))
338+
if(require_lvalue && !is_assignable(s_copy))
339339
return true;
340340

341341
// Note s_copy is no longer a symbol_exprt due to the replace operation,

0 commit comments

Comments
 (0)