Skip to content

Commit 69c13b1

Browse files
author
Norbert Manthey
committed
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 c2d7554 commit 69c13b1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/goto-instrument/rw_set.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ void _rw_set_loct::compute()
7272
assert(target->code.operands().size()==2);
7373
assign(target->code.op0(), target->code.op1());
7474
}
75+
else if(target->is_return())
76+
{
77+
read(to_code_return(target->code));
78+
}
7579
else if(target->is_goto() ||
7680
target->is_assume() ||
7781
target->is_assert())
@@ -95,6 +99,10 @@ void _rw_set_loct::compute()
9599
if(code_function_call.lhs().is_not_nil())
96100
write(code_function_call.lhs());
97101
}
102+
else if(target->is_other())
103+
{
104+
read(target->code);
105+
}
98106
}
99107

100108
/*******************************************************************\
@@ -219,7 +227,6 @@ void _rw_set_loct::read_write_rec(
219227
else if(expr.id()==ID_address_of)
220228
{
221229
assert(expr.operands().size()==1);
222-
223230
}
224231
else if(expr.id()==ID_if)
225232
{

src/util/std_code.h

+6
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,18 @@ class code_returnt:public codet
751751
static inline const code_returnt &to_code_return(const codet &code)
752752
{
753753
assert(code.get_statement()==ID_return);
754+
assert(
755+
code.operands().size()<=1 &&
756+
"there should be at most one operand in an return statement");
754757
return static_cast<const code_returnt &>(code);
755758
}
756759

757760
static inline code_returnt &to_code_return(codet &code)
758761
{
759762
assert(code.get_statement()==ID_return);
763+
assert(
764+
code.operands().size()<=1 &&
765+
"there should be at most one operand in an return statement");
760766
return static_cast<code_returnt &>(code);
761767
}
762768

0 commit comments

Comments
 (0)