Skip to content

Commit dad59ca

Browse files
Norbert Mantheynmanthey
authored andcommitted
rw_set: handle return and other
When calculating the set of touched symbols, also consider the symbols that are passed to return statements. Furthermore, continue with reading symbols that are in code labelled with "other". Added a check to test whether return statements have at most one argument.
1 parent a354513 commit dad59ca

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/goto-instrument/rw_set.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ void _rw_set_loct::compute()
5151
assert(target->code.operands().size()==2);
5252
assign(target->code.op0(), target->code.op1());
5353
}
54+
else if(target->is_return())
55+
{
56+
read(to_code_return(target->code));
57+
}
5458
else if(target->is_goto() ||
5559
target->is_assume() ||
5660
target->is_assert())
@@ -74,6 +78,10 @@ void _rw_set_loct::compute()
7478
if(code_function_call.lhs().is_not_nil())
7579
write(code_function_call.lhs());
7680
}
81+
else if(target->is_other())
82+
{
83+
read(target->code);
84+
}
7785
}
7886

7987
void _rw_set_loct::assign(const exprt &lhs, const exprt &rhs)

src/util/std_code.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,12 +933,18 @@ template<> inline bool can_cast_expr<code_returnt>(const exprt &base)
933933
inline const code_returnt &to_code_return(const codet &code)
934934
{
935935
assert(code.get_statement()==ID_return);
936+
assert(
937+
code.operands().size() <= 1 &&
938+
"there should be at most one operand in an return statement");
936939
return static_cast<const code_returnt &>(code);
937940
}
938941

939942
inline code_returnt &to_code_return(codet &code)
940943
{
941944
assert(code.get_statement()==ID_return);
945+
assert(
946+
code.operands().size() <= 1 &&
947+
"there should be at most one operand in an return statement");
942948
return static_cast<code_returnt &>(code);
943949
}
944950

0 commit comments

Comments
 (0)