Skip to content

Commit 631e1d3

Browse files
Define a find_symbol_identifiers function
This compute a similar set to the find_symbols(const exprt &, find_symbols_sett &, bool, bool) function but returns the computed set.
1 parent 0a96ac9 commit 631e1d3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/goto-instrument/concurrency.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ void concurrency_instrumentationt::instrument(
131131

132132
void concurrency_instrumentationt::collect(const exprt &expr)
133133
{
134-
for(const auto &symbol_expr : find_symbols(expr))
134+
for(const auto &identifier : find_symbol_identifiers(expr))
135135
{
136-
const irep_idt &identifier = symbol_expr.get_identifier();
137-
138136
namespacet ns(symbol_table);
139137
const symbolt &symbol = ns.lookup(identifier);
140138

src/util/find_symbols.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ std::set<symbol_exprt> find_symbols(const exprt &src)
8888
.map([](const exprt &e) { return to_symbol_expr(e); });
8989
}
9090

91+
std::unordered_set<irep_idt> find_symbol_identifiers(const exprt &src)
92+
{
93+
std::unordered_set<irep_idt> result;
94+
src.visit_pre([&](const exprt &e) {
95+
if(e.id() == ID_symbol)
96+
result.insert(to_symbol_expr(e).get_identifier());
97+
});
98+
return result;
99+
}
100+
91101
void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest);
92102

93103
void find_symbols(kindt kind, const exprt &src, find_symbols_sett &dest)

src/util/find_symbols.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ void find_symbols(
6363
/// Find sub expressions with id ID_symbol
6464
std::set<symbol_exprt> find_symbols(const exprt &src);
6565

66+
/// Find identifiers of the sub expressions with id ID_symbol
67+
std::unordered_set<irep_idt> find_symbol_identifiers(const exprt &src);
68+
6669
/// \return true if one of the symbols in \p src is present in \p symbols
6770
bool has_symbol(
6871
const exprt &src,

0 commit comments

Comments
 (0)