CBMC
Loading...
Searching...
No Matches
find_variables.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Find Variables
4
5Author: Daniel Kroening, dkr@amazon.com
6
7\*******************************************************************/
8
11
12#include "find_variables.h"
13
14#include <util/pointer_expr.h>
15
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
29std::unordered_set<symbol_exprt, irep_hash>
30find_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}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Base class for all expressions.
Definition expr.h:56
operandst & operands()
Definition expr.h:94
const irep_idt & id() const
Definition irep.h:388
static void find_variables_rec(const exprt &src, std::unordered_set< symbol_exprt, irep_hash > &result)
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...
Find Variables.
API to expression classes for Pointers.
const object_address_exprt & to_object_address_expr(const exprt &expr)
Cast an exprt to an object_address_exprt.