@@ -13,6 +13,7 @@ Author: Daniel Kroening, kroening@kroening.com
1313
1414#include < util/byte_operators.h>
1515#include < util/expr_util.h>
16+ #include < util/pointer_expr.h>
1617#include < util/range.h>
1718
1819#include " expr_skeleton.h"
@@ -33,6 +34,27 @@ constexpr bool use_update()
3334#endif
3435}
3536
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+
3658void symex_assignt::assign_rec (
3759 const exprt &lhs,
3860 const expr_skeletont &full_lhs,
@@ -42,6 +64,21 @@ void symex_assignt::assign_rec(
4264 if (is_ssa_expr (lhs))
4365 {
4466 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+ }
4582 }
4683 else if (lhs.id () == ID_index)
4784 assign_array<use_update ()>(to_index_expr (lhs), full_lhs, rhs, guard);
0 commit comments