@@ -19,14 +19,49 @@ Date: March 2013
19
19
void dirtyt::build (const goto_functiont &goto_function)
20
20
{
21
21
for (const auto &i : goto_function.body .instructions )
22
- i.apply ([this ](const exprt &e) { find_dirty (e); });
22
+ {
23
+ if (i.is_other ())
24
+ {
25
+ search_other (i);
26
+ }
27
+ else
28
+ {
29
+ i.apply ([this ](const exprt &e) { find_dirty (e); });
30
+ }
31
+ }
32
+ }
33
+
34
+ void dirtyt::search_other (const goto_programt::instructiont &instruction)
35
+ {
36
+ INVARIANT (instruction.is_other (), " instruction type must be OTHER" );
37
+ if (instruction.get_other ().id () == ID_code)
38
+ {
39
+ const codet &code = instruction.get_other ();
40
+ const irep_idt &statement = code.get_statement ();
41
+ if (
42
+ statement == ID_expression || statement == ID_array_set ||
43
+ statement == ID_array_equal || statement == ID_array_copy ||
44
+ statement == ID_array_replace || statement == ID_havoc_object ||
45
+ statement == ID_input || statement == ID_output)
46
+ {
47
+ forall_operands (it, code)
48
+ find_dirty (*it);
49
+ }
50
+ // other possible cases according to goto_programt::instructiont::output
51
+ // and goto_symext::symex_other:
52
+ // statement == ID_fence ||
53
+ // statement == ID_user_specified_predicate ||
54
+ // statement == ID_user_specified_parameter_predicates ||
55
+ // statement == ID_user_specified_return_predicates ||
56
+ // statement == ID_decl || statement == ID_nondet || statement == ID_asm)
57
+ }
23
58
}
24
59
25
60
void dirtyt::find_dirty (const exprt &expr)
26
61
{
27
- if (expr.id ()== ID_address_of)
62
+ if (expr.id () == ID_address_of)
28
63
{
29
- const address_of_exprt &address_of_expr= to_address_of_expr (expr);
64
+ const address_of_exprt &address_of_expr = to_address_of_expr (expr);
30
65
find_dirty_address_of (address_of_expr.object ());
31
66
return ;
32
67
}
@@ -37,27 +72,26 @@ void dirtyt::find_dirty(const exprt &expr)
37
72
38
73
void dirtyt::find_dirty_address_of (const exprt &expr)
39
74
{
40
- if (expr.id ()== ID_symbol)
75
+ if (expr.id () == ID_symbol)
41
76
{
42
- const irep_idt &identifier=
43
- to_symbol_expr (expr).get_identifier ();
77
+ const irep_idt &identifier = to_symbol_expr (expr).get_identifier ();
44
78
45
79
dirty.insert (identifier);
46
80
}
47
- else if (expr.id ()== ID_member)
81
+ else if (expr.id () == ID_member)
48
82
{
49
83
find_dirty_address_of (to_member_expr (expr).struct_op ());
50
84
}
51
- else if (expr.id ()== ID_index)
85
+ else if (expr.id () == ID_index)
52
86
{
53
87
find_dirty_address_of (to_index_expr (expr).array ());
54
88
find_dirty (to_index_expr (expr).index ());
55
89
}
56
- else if (expr.id ()== ID_dereference)
90
+ else if (expr.id () == ID_dereference)
57
91
{
58
92
find_dirty (to_dereference_expr (expr).pointer ());
59
93
}
60
- else if (expr.id ()== ID_if)
94
+ else if (expr.id () == ID_if)
61
95
{
62
96
find_dirty_address_of (to_if_expr (expr).true_case ());
63
97
find_dirty_address_of (to_if_expr (expr).false_case ());
@@ -76,7 +110,8 @@ void dirtyt::output(std::ostream &out) const
76
110
// / \param id: function id to analyse
77
111
// / \param function: function to analyse
78
112
void incremental_dirtyt::populate_dirty_for_function (
79
- const irep_idt &id, const goto_functionst::goto_functiont &function)
113
+ const irep_idt &id,
114
+ const goto_functionst::goto_functiont &function)
80
115
{
81
116
auto insert_result = dirty_processed_functions.insert (id);
82
117
if (insert_result.second )
0 commit comments