13
13
14
14
#include < util/byte_operators.h>
15
15
#include < util/expr_util.h>
16
+ #include < util/pointer_expr.h>
16
17
#include < util/range.h>
17
18
18
19
#include " expr_skeleton.h"
@@ -33,6 +34,27 @@ constexpr bool use_update()
33
34
#endif
34
35
}
35
36
37
+ // / Determine whether the RHS expression is a string constant initialization
38
+ // / \param rhs The RHS expression
39
+ // / \return True if the expression points to the first character of a string
40
+ // / constant
41
+ static bool is_string_constant_initialization (const exprt &rhs)
42
+ {
43
+ if (const auto &address_of = expr_try_dynamic_cast<address_of_exprt>(rhs))
44
+ {
45
+ if (
46
+ const auto &index =
47
+ expr_try_dynamic_cast<index_exprt>(address_of->object ()))
48
+ {
49
+ if (index ->array ().id () == ID_string_constant && index ->index ().is_zero ())
50
+ {
51
+ return true ;
52
+ }
53
+ }
54
+ }
55
+ return false ;
56
+ }
57
+
36
58
void symex_assignt::assign_rec (
37
59
const exprt &lhs,
38
60
const expr_skeletont &full_lhs,
@@ -42,6 +64,21 @@ void symex_assignt::assign_rec(
42
64
if (is_ssa_expr (lhs))
43
65
{
44
66
assign_symbol (to_ssa_expr (lhs), full_lhs, rhs, guard);
67
+
68
+ // Allocate shadow memory
69
+ if (shadow_memory.has_value ())
70
+ {
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
+ }
81
+ }
45
82
}
46
83
else if (lhs.id () == ID_index)
47
84
assign_array<use_update ()>(to_index_expr (lhs), full_lhs, rhs, guard);
0 commit comments