Skip to content

Commit cb6f737

Browse files
committed
More constant propagation
This also fixes a previously expected-to-fail regression test. Constant propagation now yields different right-hand sides in a test.
1 parent 77193b0 commit cb6f737

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
CORE
22
TestClass.class
33
--function TestClass.f --cover location --unwind 2
4-
Source GOTO statement: .*
5-
(^ exception: Can't convert byte_extraction|Nested exception printing not supported on Windows)
6-
^EXIT=6$
7-
--
8-
--
9-
The exception thrown in this test is the symptom of a bug; the purpose of this
10-
test is the validate the output of that exception
4+
^EXIT=0$
5+
^SIGNAL=0$

regression/jbmc-strings/long_string/test_abort.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test.class
33
--refine-strings --function Test.checkAbort --trace
44
^EXIT=10$
55
^SIGNAL=0$
6-
dynamic_object[0-9]*=\(assignment removed\)
6+
dynamic_object[0-9]*=.*\?.*
77
--
88
--
99
This tests that the object does not appear in the trace, because concretizing

src/goto-symex/goto_symex_state.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void goto_symex_statet::level1t::operator()(ssa_exprt &ssa_expr)
8383
/// "constants"
8484
bool goto_symex_statet::constant_propagation(const exprt &expr) const
8585
{
86-
if(expr.is_constant())
86+
if(expr.is_constant() || expr.id() == ID_nondet_symbol)
8787
return true;
8888

8989
if(expr.id()==ID_address_of)
@@ -187,13 +187,16 @@ bool goto_symex_statet::constant_propagation_reference(const exprt &expr) const
187187
}
188188
else if(expr.id()==ID_member)
189189
{
190-
if(expr.operands().size()!=1)
191-
throw "member expects one operand";
190+
const member_exprt &member_expr = to_member_expr(expr);
192191

193-
return constant_propagation_reference(expr.op0());
192+
return constant_propagation_reference(member_expr.struct_op());
194193
}
195-
else if(expr.id()==ID_string_constant)
194+
else if(
195+
expr.id() == ID_string_constant || expr.id() == ID_array ||
196+
expr.id() == ID_struct || expr.id() == ID_union)
197+
{
196198
return true;
199+
}
197200

198201
return false;
199202
}

0 commit comments

Comments
 (0)