@@ -19,14 +19,49 @@ Date: March 2013
1919void dirtyt::build (const goto_functiont &goto_function)
2020{
2121 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+ }
2358}
2459
2560void dirtyt::find_dirty (const exprt &expr)
2661{
27- if (expr.id ()== ID_address_of)
62+ if (expr.id () == ID_address_of)
2863 {
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);
3065 find_dirty_address_of (address_of_expr.object ());
3166 return ;
3267 }
@@ -37,27 +72,26 @@ void dirtyt::find_dirty(const exprt &expr)
3772
3873void dirtyt::find_dirty_address_of (const exprt &expr)
3974{
40- if (expr.id ()== ID_symbol)
75+ if (expr.id () == ID_symbol)
4176 {
42- const irep_idt &identifier=
43- to_symbol_expr (expr).get_identifier ();
77+ const irep_idt &identifier = to_symbol_expr (expr).get_identifier ();
4478
4579 dirty.insert (identifier);
4680 }
47- else if (expr.id ()== ID_member)
81+ else if (expr.id () == ID_member)
4882 {
4983 find_dirty_address_of (to_member_expr (expr).struct_op ());
5084 }
51- else if (expr.id ()== ID_index)
85+ else if (expr.id () == ID_index)
5286 {
5387 find_dirty_address_of (to_index_expr (expr).array ());
5488 find_dirty (to_index_expr (expr).index ());
5589 }
56- else if (expr.id ()== ID_dereference)
90+ else if (expr.id () == ID_dereference)
5791 {
5892 find_dirty (to_dereference_expr (expr).pointer ());
5993 }
60- else if (expr.id ()== ID_if)
94+ else if (expr.id () == ID_if)
6195 {
6296 find_dirty_address_of (to_if_expr (expr).true_case ());
6397 find_dirty_address_of (to_if_expr (expr).false_case ());
@@ -76,7 +110,8 @@ void dirtyt::output(std::ostream &out) const
76110// / \param id: function id to analyse
77111// / \param function: function to analyse
78112void 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)
80115{
81116 auto insert_result = dirty_processed_functions.insert (id);
82117 if (insert_result.second )
0 commit comments