Skip to content

Commit eea40db

Browse files
Define a find_symbols taking iterators
This will make it easier to accumulate the set of symbols from a range, which is often how the find_symbols function is used.
1 parent 1a48981 commit eea40db

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/find_symbols.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, [email protected]
1010
#ifndef CPROVER_UTIL_FIND_SYMBOLS_H
1111
#define CPROVER_UTIL_FIND_SYMBOLS_H
1212

13+
#include <algorithm>
1314
#include <set>
1415
#include <unordered_set>
1516

@@ -26,6 +27,19 @@ void find_symbols(
2627
const exprt &src,
2728
find_symbols_sett &dest);
2829

30+
/// \return set of sub-expressions of the expressions contained in the range
31+
/// defined by \p begin and \p end which have id ID_symbol or ID_next_symbol
32+
template <typename iteratort>
33+
find_symbols_sett find_symbols(iteratort begin, iteratort end)
34+
{
35+
static_assert(
36+
std::is_base_of<exprt, typename iteratort::value_type>::value,
37+
"find_symbols takes exprt iterators as arguments");
38+
find_symbols_sett result;
39+
std::for_each(begin, end, [&](const exprt &e){ find_symbols(e, result); });
40+
return result;
41+
}
42+
2943
void find_symbols(
3044
const exprt &src,
3145
find_symbols_sett &dest,

0 commit comments

Comments
 (0)