cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
find_variables.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Find Variables
4
5
Author: Daniel Kroening, dkr@amazon.com
6
7
\*******************************************************************/
8
11
12
#include "
find_variables.h
"
13
14
#include <
util/pointer_expr.h
>
15
16
static
void
find_variables_rec
(
17
const
exprt
&src,
18
std::unordered_set<symbol_exprt, irep_hash> &result)
19
{
20
if
(src.
id
() == ID_object_address)
21
result.insert(
to_object_address_expr
(src).object_expr());
22
else
23
{
24
for
(
auto
&op : src.
operands
())
25
find_variables_rec
(op, result);
26
}
27
}
28
29
std::unordered_set<symbol_exprt, irep_hash>
30
find_variables
(
const
std::vector<exprt> &src)
31
{
32
std::unordered_set<symbol_exprt, irep_hash> result;
33
34
for
(
auto
&expr : src)
35
find_variables_rec
(expr, result);
36
37
return
result;
38
}
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::operands
operandst & operands()
Definition
expr.h:95
irept::id
const irep_idt & id() const
Definition
irep.h:388
find_variables_rec
static void find_variables_rec(const exprt &src, std::unordered_set< symbol_exprt, irep_hash > &result)
Definition
find_variables.cpp:16
find_variables
std::unordered_set< symbol_exprt, irep_hash > find_variables(const std::vector< exprt > &src)
Returns the set of program variables (as identified by object_address expressions) in the given expre...
Definition
find_variables.cpp:30
find_variables.h
Find Variables.
pointer_expr.h
API to expression classes for Pointers.
to_object_address_expr
const object_address_exprt & to_object_address_expr(const exprt &expr)
Cast an exprt to an object_address_exprt.
Definition
pointer_expr.h:643
cprover
find_variables.cpp
Generated by
1.17.0