Skip to content

Commit cf4b84a

Browse files
committed
weaken goto_convertt::needs_cleaning
1 parent 2367c35 commit cf4b84a

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/goto-programs/goto_clean_expr.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,17 @@ symbol_exprt goto_convertt::make_compound_literal(
5959
return result;
6060
}
6161

62+
/// Returns 'true' for expressions that may change the program
63+
/// state.
64+
/// Expressions that may trigger undefined behavior
65+
/// (e.g., dereference, index, division) are deliberately not
66+
/// included.
6267
bool goto_convertt::needs_cleaning(const exprt &expr)
6368
{
64-
if(expr.id()==ID_dereference ||
65-
expr.id()==ID_side_effect ||
66-
expr.id()==ID_compound_literal ||
67-
expr.id()==ID_comma)
68-
return true;
69-
70-
if(expr.id()==ID_index)
69+
if(
70+
expr.id() == ID_side_effect || expr.id() == ID_compound_literal ||
71+
expr.id() == ID_comma)
7172
{
72-
// Will usually clean index expressions because of possible
73-
// memory violation in case of out-of-bounds indices.
74-
// We do an exception for "string-lit"[0], which is safe.
75-
if(to_index_expr(expr).array().id()==ID_string_constant &&
76-
to_index_expr(expr).index().is_zero())
77-
return false;
78-
7973
return true;
8074
}
8175

0 commit comments

Comments
 (0)