11
11
12
12
#include " symex_assign.h"
13
13
14
+ #include < util/arith_tools.h>
14
15
#include < util/byte_operators.h>
16
+ #include < util/c_types.h>
15
17
#include < util/expr_util.h>
18
+ #include < util/pointer_expr.h>
16
19
#include < util/range.h>
17
20
18
21
#include " expr_skeleton.h"
@@ -33,6 +36,29 @@ constexpr bool use_update()
33
36
#endif
34
37
}
35
38
39
+ // / Determine whether the RHS expression is a string constant initialization
40
+ // / \param rhs The RHS expression
41
+ // / \return True if the expression points to the first character of a string
42
+ // / constant
43
+ static bool is_string_constant_initialization (const exprt &rhs)
44
+ {
45
+ if (rhs.id () == ID_address_of)
46
+ {
47
+ const address_of_exprt &address_of = to_address_of_expr (rhs);
48
+ if (address_of.object ().id () == ID_index)
49
+ {
50
+ const index_exprt &index = to_index_expr (address_of.object ());
51
+ if (
52
+ index .array ().id () == ID_string_constant &&
53
+ index .index () == from_integer (0 , c_index_type ()))
54
+ {
55
+ return true ;
56
+ }
57
+ }
58
+ }
59
+ return false ;
60
+ }
61
+
36
62
void symex_assignt::assign_rec (
37
63
const exprt &lhs,
38
64
const expr_skeletont &full_lhs,
@@ -42,6 +68,21 @@ void symex_assignt::assign_rec(
42
68
if (is_ssa_expr (lhs))
43
69
{
44
70
assign_symbol (to_ssa_expr (lhs), full_lhs, rhs, guard);
71
+
72
+ // Allocate shadow memory
73
+ if (shadow_memory.has_value ())
74
+ {
75
+ bool is_string_constant_init = is_string_constant_initialization (rhs);
76
+ if (is_string_constant_init)
77
+ {
78
+ shadow_memory->symex_field_static_init_string_constant (
79
+ state, to_ssa_expr (lhs), rhs);
80
+ }
81
+ else
82
+ {
83
+ shadow_memory->symex_field_static_init (state, to_ssa_expr (lhs));
84
+ }
85
+ }
45
86
}
46
87
else if (lhs.id () == ID_index)
47
88
assign_array<use_update ()>(to_index_expr (lhs), full_lhs, rhs, guard);
0 commit comments