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