@@ -18,6 +18,38 @@ Date: November 2011
18
18
19
19
#include < linking/static_lifetime_init.h>
20
20
21
+ // / Returns true if the symbol expression holds a static symbol that can be
22
+ // / nondeterministically initialized, false otherwise.
23
+ // / \param sym The symbol expression to analyze.
24
+ // / \param ns Namespace for resolving type information
25
+ bool is_nondet_initializable_static (
26
+ const symbol_exprt &sym,
27
+ const namespacet &ns)
28
+ {
29
+ const irep_idt &id = sym.get_identifier ();
30
+
31
+ // is it a __CPROVER_* variable?
32
+ if (has_prefix (id2string (id), CPROVER_PREFIX))
33
+ return false ;
34
+
35
+ // variable not in symbol table such as symex variable?
36
+ if (!ns.get_symbol_table ().has_symbol (id))
37
+ return false ;
38
+
39
+ // any other internal variable such as Java specific?
40
+ if (ns.lookup (id).type .get_bool (ID_C_no_nondet_initialization))
41
+ return false ;
42
+
43
+ // static lifetime?
44
+ if (!ns.lookup (id).is_static_lifetime )
45
+ return false ;
46
+
47
+ // constant?
48
+ return !is_constant_or_has_constant_components (sym.type (), ns) &&
49
+ !is_constant_or_has_constant_components (ns.lookup (id).type , ns);
50
+ }
51
+
52
+
21
53
void nondet_static (
22
54
const namespacet &ns,
23
55
goto_functionst &goto_functions,
@@ -38,34 +70,17 @@ void nondet_static(
38
70
const symbol_exprt &sym=to_symbol_expr (
39
71
to_code_assign (instruction.code ).lhs ());
40
72
41
- // is it a __CPROVER_* variable?
42
- if (has_prefix (id2string (sym.get_identifier ()), CPROVER_PREFIX))
43
- continue ;
44
-
45
- // any other internal variable such as Java specific?
46
- if (
47
- ns.lookup (sym.get_identifier ())
48
- .type .get_bool (ID_C_no_nondet_initialization))
73
+ if (is_nondet_initializable_static (sym, ns))
49
74
{
50
- continue ;
75
+ const goto_programt::instructiont original_instruction = instruction;
76
+ i_it->make_assignment ();
77
+ i_it->code = code_assignt (
78
+ sym,
79
+ side_effect_expr_nondett (
80
+ sym.type (), original_instruction.source_location ));
81
+ i_it->source_location = original_instruction.source_location ;
82
+ i_it->function = original_instruction.function ;
51
83
}
52
-
53
- // static lifetime?
54
- if (!ns.lookup (sym.get_identifier ()).is_static_lifetime )
55
- continue ;
56
-
57
- // constant?
58
- if (is_constant_or_has_constant_components (sym.type (), ns))
59
- continue ;
60
-
61
- const goto_programt::instructiont original_instruction = instruction;
62
- i_it->make_assignment ();
63
- i_it->code = code_assignt (
64
- sym,
65
- side_effect_expr_nondett (
66
- sym.type (), original_instruction.source_location ));
67
- i_it->source_location = original_instruction.source_location ;
68
- i_it->function = original_instruction.function ;
69
84
}
70
85
else if (instruction.is_function_call ())
71
86
{
0 commit comments