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,28 @@ 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 constant
42
+ static bool is_string_constant_initialization (const exprt &rhs)
43
+ {
44
+ if (rhs.id () == ID_address_of)
45
+ {
46
+ const address_of_exprt &address_of = to_address_of_expr (rhs);
47
+ if (address_of.object ().id () == ID_index)
48
+ {
49
+ const index_exprt &index = to_index_expr (address_of.object ());
50
+ if (
51
+ index .array ().id () == ID_string_constant &&
52
+ index .index () == from_integer (0 , c_index_type ()))
53
+ {
54
+ return true ;
55
+ }
56
+ }
57
+ }
58
+ return false ;
59
+ }
60
+
36
61
void symex_assignt::assign_rec (
37
62
const exprt &lhs,
38
63
const expr_skeletont &full_lhs,
@@ -42,6 +67,21 @@ void symex_assignt::assign_rec(
42
67
if (is_ssa_expr (lhs))
43
68
{
44
69
assign_symbol (to_ssa_expr (lhs), full_lhs, rhs, guard);
70
+
71
+ // Allocate shadow memory
72
+ if (shadow_memory.has_value ())
73
+ {
74
+ bool is_string_constant_init = is_string_constant_initialization (rhs);
75
+ if (is_string_constant_init)
76
+ {
77
+ shadow_memory->symex_field_static_init_string_constant (
78
+ state, to_ssa_expr (lhs), rhs);
79
+ }
80
+ else
81
+ {
82
+ shadow_memory->symex_field_static_init (state, to_ssa_expr (lhs));
83
+ }
84
+ }
45
85
}
46
86
else if (lhs.id () == ID_index)
47
87
assign_array<use_update ()>(to_index_expr (lhs), full_lhs, rhs, guard);
0 commit comments