11
11
12
12
#include " symex_assign.h"
13
13
14
- #include " expr_skeleton.h"
15
- #include " goto_symex_state.h"
16
14
#include < util/byte_operators.h>
17
15
#include < util/config.h>
18
16
#include < util/expr_util.h>
19
17
#include < util/pointer_expr.h>
20
18
#include < util/range.h>
21
19
20
+ #include " arith_tools.h"
21
+ #include " c_types.h"
22
+ #include " expr_skeleton.h"
23
+ #include " goto_symex_state.h"
22
24
#include " symex_config.h"
23
25
24
26
// We can either use with_exprt or update_exprt when building expressions that
@@ -35,6 +37,28 @@ constexpr bool use_update()
35
37
#endif
36
38
}
37
39
40
+ // / Determine whether the RHS expression is a string constant initialization
41
+ // / \param rhs The RHS expression
42
+ // / \return True if the expression points to the first character of a string 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
+
38
62
void symex_assignt::assign_rec (
39
63
const exprt &lhs,
40
64
const expr_skeletont &full_lhs,
@@ -44,6 +68,18 @@ void symex_assignt::assign_rec(
44
68
if (is_ssa_expr (lhs))
45
69
{
46
70
assign_symbol (to_ssa_expr (lhs), full_lhs, rhs, guard);
71
+
72
+ // Allocate shadow memory
73
+ bool is_string_constant_init = is_string_constant_initialization (rhs);
74
+ if (is_string_constant_init)
75
+ {
76
+ shadow_memory.symex_field_static_init_string_constant (
77
+ state, to_ssa_expr (lhs), rhs);
78
+ }
79
+ else
80
+ {
81
+ shadow_memory.symex_field_static_init (state, to_ssa_expr (lhs));
82
+ }
47
83
}
48
84
else if (lhs.id () == ID_index)
49
85
assign_array<use_update ()>(to_index_expr (lhs), full_lhs, rhs, guard);
0 commit comments