Skip to content

Commit f0223d9

Browse files
committed
find_symbols kindt: clarify enum entries
"F_BOTH" is not a good fit when there are three (and not two) other entries. While at it, also add support to selectively choose current or next expression symbols.
1 parent b117933 commit f0223d9

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

src/ansi-c/goto_check_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void goto_check_ct::invalidate(const exprt &lhs)
466466
for(auto it = assertions.begin(); it != assertions.end();)
467467
{
468468
if(
469-
has_symbol(it->second, lhs_id, kindt::F_EXPR) ||
469+
has_symbol(it->second, lhs_id, kindt::F_EXPR_CURRENT) ||
470470
has_subexpr(it->second, ID_dereference))
471471
{
472472
it = assertions.erase(it);

src/goto-symex/postcondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ bool postconditiont::is_used(
167167
for(const exprt &e :
168168
value_set.get_value_set(to_dereference_expr(expr).pointer(), ns))
169169
{
170-
if(has_symbol(get_original_name(e), identifier, kindt::F_BOTH))
170+
if(has_symbol(get_original_name(e), identifier, kindt::F_EXPR_BOTH))
171171
{
172172
return true;
173173
}

src/goto-symex/precondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void preconditiont::compute_rec(exprt &dest)
117117
for(const exprt &e : value_sets.get_values(
118118
SSA_step.source.function_id, target, deref_expr.pointer()))
119119
{
120-
if(has_symbol(e, lhs_identifier, kindt::F_BOTH))
120+
if(has_symbol(e, lhs_identifier, kindt::F_EXPR_BOTH))
121121
{
122122
may_alias = true;
123123
break;

src/util/find_symbols.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,19 @@ void find_symbols(kindt kind, const exprt &src, find_symbols_sett &dest)
9595

9696
find_symbols(kind, src.type(), dest);
9797

98-
if(kind==kindt::F_BOTH || kind==kindt::F_EXPR)
98+
if(
99+
kind == kindt::F_ALL || kind == kindt::F_EXPR_CURRENT ||
100+
kind == kindt::F_EXPR_BOTH)
99101
{
100102
if(src.id() == ID_symbol)
101103
dest.insert(to_symbol_expr(src).get_identifier());
102-
else if(src.id() == ID_next_symbol)
104+
}
105+
106+
if(
107+
kind == kindt::F_ALL || kind == kindt::F_EXPR_NEXT ||
108+
kind == kindt::F_EXPR_BOTH)
109+
{
110+
if(src.id() == ID_next_symbol)
103111
dest.insert(src.get(ID_identifier));
104112
}
105113

@@ -146,10 +154,6 @@ void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest)
146154
for(const auto &p : code_type.parameters())
147155
{
148156
find_symbols(kind, p, dest);
149-
150-
// irep_idt identifier=it->get_identifier();
151-
// if(!identifier.empty() && (kind==F_TYPE || kind==F_BOTH))
152-
// dest.insert(identifier);
153157
}
154158
}
155159
else if(src.id()==ID_array)
@@ -204,10 +208,10 @@ void find_non_pointer_type_symbols(
204208

205209
void find_type_and_expr_symbols(const exprt &src, find_symbols_sett &dest)
206210
{
207-
find_symbols(kindt::F_BOTH, src, dest);
211+
find_symbols(kindt::F_ALL, src, dest);
208212
}
209213

210214
void find_type_and_expr_symbols(const typet &src, find_symbols_sett &dest)
211215
{
212-
find_symbols(kindt::F_BOTH, src, dest);
216+
find_symbols(kindt::F_ALL, src, dest);
213217
}

src/util/find_symbols.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ enum class kindt
3232
/// pointer.
3333
F_TYPE_NON_PTR,
3434
/// Symbol expressions.
35-
F_EXPR,
35+
F_EXPR_CURRENT,
36+
/// Next-state symbol expressions.
37+
F_EXPR_NEXT,
3638
/// Current or next-state symbol expressions.
37-
F_BOTH,
39+
F_EXPR_BOTH,
40+
/// All of the above.
41+
F_ALL
3842
};
3943

4044
/// Returns true if one of the symbols in \p src with identifier \p identifier

0 commit comments

Comments
 (0)