Skip to content

Commit de7aa25

Browse files
committed
Restrict has_symbol to symbol expressions and rename it to has_symbol_expr
With the removal of support for ID_next_symbol all uses of `has_symbol` searched for symbol expressions only.
1 parent aa3d52b commit de7aa25

File tree

5 files changed

+25
-28
lines changed

5 files changed

+25
-28
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, symbol_kindt::F_EXPR) ||
469+
has_symbol_expr(it->second, lhs_id) ||
470470
has_subexpr(it->second, ID_dereference))
471471
{
472472
it = assertions.erase(it);

src/goto-symex/postcondition.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,8 @@ 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, symbol_kindt::F_EXPR))
171-
{
170+
if(has_symbol_expr(get_original_name(e), identifier))
172171
return true;
173-
}
174172
}
175173

176174
return false;

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, symbol_kindt::F_EXPR))
120+
if(has_symbol_expr(e, lhs_identifier))
121121
{
122122
may_alias = true;
123123
break;

src/util/find_symbols.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ Author: Daniel Kroening, [email protected]
1313
#include "range.h"
1414
#include "std_expr.h"
1515

16+
/// Kinds of symbols to be considered by \ref has_symbol or \ref find_symbols.
17+
enum class symbol_kindt
18+
{
19+
/// Struct, union, or enum tag symbols.
20+
F_TYPE,
21+
/// Struct, union, or enum tag symbols when the expression using them is not a
22+
/// pointer.
23+
F_TYPE_NON_PTR,
24+
/// Symbol expressions.
25+
F_EXPR,
26+
/// Symbol expressions, but excluding bindings.
27+
F_EXPR_NOT_BOUND,
28+
/// All of the above.
29+
F_ALL
30+
};
31+
1632
bool has_symbol(const exprt &src, const find_symbols_sett &symbols)
1733
{
1834
if(src.id() == ID_symbol)
@@ -164,9 +180,9 @@ void find_symbols(const exprt &src, std::set<symbol_exprt> &dest)
164180
});
165181
}
166182

167-
bool has_symbol(const exprt &src, const irep_idt &identifier, symbol_kindt kind)
183+
bool has_symbol_expr(const exprt &src, const irep_idt &identifier)
168184
{
169-
return !find_symbols(kind, src, [&identifier](const symbol_exprt &e) {
185+
return !find_symbols(symbol_kindt::F_EXPR, src, [&identifier](const symbol_exprt &e) {
170186
return e.get_identifier() != identifier;
171187
});
172188
}

src/util/find_symbols.h

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,9 @@ class typet;
2323

2424
typedef std::unordered_set<irep_idt> find_symbols_sett;
2525

26-
/// Kinds of symbols to be considered by \ref has_symbol or \ref find_symbols.
27-
enum class symbol_kindt
28-
{
29-
/// Struct, union, or enum tag symbols.
30-
F_TYPE,
31-
/// Struct, union, or enum tag symbols when the expression using them is not a
32-
/// pointer.
33-
F_TYPE_NON_PTR,
34-
/// Symbol expressions.
35-
F_EXPR,
36-
/// All of the above.
37-
F_ALL
38-
};
39-
40-
/// Returns true if one of the symbols in \p src with identifier \p identifier
41-
/// is of kind \p kind.
42-
bool has_symbol(
43-
const exprt &src,
44-
const irep_idt &identifier,
45-
symbol_kindt kind);
26+
/// Returns true if one of the symbol expressions in \p src has identifier
27+
/// \p identifier.
28+
bool has_symbol_expr(const exprt &src, const irep_idt &identifier);
4629

4730
DEPRECATED(SINCE(2022, 3, 14, "use find_symbols"))
4831
/// Add to the set \p dest the sub-expressions of \p src with id ID_symbol or
@@ -87,7 +70,7 @@ inline find_symbols_sett find_symbol_identifiers(const exprt &src)
8770
return identifiers;
8871
}
8972

90-
DEPRECATED(SINCE(2022, 3, 14, "use has_symbol(exprt, irep_idt, symbol_kindt)"))
73+
DEPRECATED(SINCE(2022, 3, 14, "use has_symbol_expr(exprt, irep_idt, bool)"))
9174
/// \return true if one of the symbols in \p src is present in \p symbols
9275
bool has_symbol(
9376
const exprt &src,

0 commit comments

Comments
 (0)