Skip to content

Commit 2a3f8c5

Browse files
author
klaas
committed
Moves is_lvalue to expr_util.c
This change exposes is_lvalue for use outside of goto-programs/builtin_functions.cpp.
1 parent 7c56091 commit 2a3f8c5

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/goto-programs/builtin_functions.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717
#include <util/c_types.h>
1818
#include <util/cprover_prefix.h>
1919
#include <util/expr_initializer.h>
20+
#include <util/expr_util.h>
2021
#include <util/pointer_offset_size.h>
2122
#include <util/rational.h>
2223
#include <util/rational_tools.h>
@@ -615,20 +616,6 @@ void goto_convertt::do_array_op(
615616
copy(array_op_statement, OTHER, dest);
616617
}
617618

618-
bool is_lvalue(const exprt &expr)
619-
{
620-
if(expr.id()==ID_index)
621-
return is_lvalue(to_index_expr(expr).op0());
622-
else if(expr.id()==ID_member)
623-
return is_lvalue(to_member_expr(expr).op0());
624-
else if(expr.id()==ID_dereference)
625-
return true;
626-
else if(expr.id()==ID_symbol)
627-
return true;
628-
else
629-
return false;
630-
}
631-
632619
exprt make_va_list(const exprt &expr)
633620
{
634621
// we first strip any typecast

src/util/expr_util.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ Author: Daniel Kroening, [email protected]
1919
#include "namespace.h"
2020
#include "arith_tools.h"
2121

22+
bool is_lvalue(const exprt &expr)
23+
{
24+
if(expr.id()==ID_index)
25+
return is_lvalue(to_index_expr(expr).op0());
26+
else if(expr.id()==ID_member)
27+
return is_lvalue(to_member_expr(expr).op0());
28+
else if(expr.id()==ID_dereference)
29+
return true;
30+
else if(expr.id()==ID_symbol)
31+
return true;
32+
else
33+
return false;
34+
}
2235
exprt make_binary(const exprt &expr)
2336
{
2437
const exprt::operandst &operands=expr.operands();

src/util/expr_util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class symbolt;
3030
class typet;
3131
class namespacet;
3232

33+
/// Returns true iff the argument is (syntactically) an lvalue.
34+
bool is_lvalue(const exprt &expr);
35+
3336
/// splits an expression with >=3 operands into nested binary expressions
3437
exprt make_binary(const exprt &);
3538

0 commit comments

Comments
 (0)