-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathaddress_taken.cpp
59 lines (48 loc) · 1.33 KB
/
address_taken.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*******************************************************************\
Module: Address Taken
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// Address Taken
#include "address_taken.h"
#include <util/pointer_expr.h>
#include "state.h"
// we look for ❝x❞ that's
// * not the argument of ς(...), i.e., evaluate
// * not the argument of enter_scope_state(?, ?)
// * not the argument of exit_scope_state(?, ?)
// * not on the lhs of [...:=...]
static void find_objects_rec(
const exprt &src,
std::unordered_set<symbol_exprt, irep_hash> &result)
{
if(src.id() == ID_object_address)
result.insert(to_object_address_expr(src).object_expr());
else if(src.id() == ID_evaluate)
{
}
else if(src.id() == ID_enter_scope_state)
{
}
else if(src.id() == ID_exit_scope_state)
{
}
else if(src.id() == ID_update_state)
{
const auto &update_state_expr = to_update_state_expr(src);
find_objects_rec(update_state_expr.new_value(), result);
}
else
{
for(auto &op : src.operands())
find_objects_rec(op, result);
}
}
std::unordered_set<symbol_exprt, irep_hash>
address_taken(const std::vector<exprt> &src)
{
std::unordered_set<symbol_exprt, irep_hash> result;
for(auto &expr : src)
find_objects_rec(expr, result);
return result;
}