@@ -156,22 +156,50 @@ TEST_CASE("ssa_exprt::get_object_name", "[unit][util][ssa_expr]")
156
156
157
157
TEST_CASE (" ssa_exprt::get_l1_object" , " [unit][util][ssa_expr]" )
158
158
{
159
+ const signedbv_typet int_type{32 };
160
+ const array_typet array_type{int_type, from_integer (10 , int_type)};
161
+
162
+ GIVEN (" An ssa_exprt obtained from a symbol" )
163
+ {
164
+ const symbol_exprt symbol{" sym" , int_type};
165
+ ssa_exprt ssa{symbol};
166
+ ssa.set_level_0 (1 );
167
+ ssa.set_level_1 (3 );
168
+ ssa.set_level_2 (7 );
169
+
170
+ // Check we have constructed the desired SSA expression
171
+ REQUIRE (ssa.get_identifier () == " sym!1@3#7" );
172
+
173
+ WHEN (" get_l1_object is called on the SSA expression" )
174
+ {
175
+ const ssa_exprt l1_object = ssa.get_l1_object ();
176
+ THEN (" level 0 and level 1 are the same, l2 is removed" )
177
+ {
178
+ REQUIRE (l1_object.get_level_0 () == " 1" );
179
+ REQUIRE (l1_object.get_level_1 () == " 3" );
180
+ REQUIRE (l1_object.get_level_2 () == irep_idt{});
181
+ REQUIRE (l1_object.get_identifier () == " sym!1@3" );
182
+ }
183
+ }
184
+ }
185
+
159
186
GIVEN (" An ssa_exprt containing member access, array access and a symbol" )
160
187
{
161
- const signedbv_typet int_type{32 };
162
- const array_typet array_type{int_type, from_integer (10 , int_type)};
163
188
std::vector<struct_typet::componentt> components;
164
189
components.emplace_back (" array_field" , array_type);
165
190
const struct_typet struct_type{components};
166
191
const symbol_exprt symbol{" sym" , struct_type};
167
192
const index_exprt index {member_exprt{symbol, components.back ()},
168
193
from_integer (9 , int_type)};
169
- ssa_exprt ssa{symbol };
194
+ ssa_exprt ssa{index };
170
195
ssa.set_level_0 (1 );
171
196
ssa.set_level_1 (3 );
172
197
ssa.set_level_2 (7 );
173
198
174
- WHEN (" get_l1_object is called" )
199
+ // Check we have constructed the desired SSA expression
200
+ REQUIRE (ssa.get_identifier () == " sym!1@3#7..array_field[[9]]" );
201
+
202
+ WHEN (" get_l1_object is called on the SSA expression" )
175
203
{
176
204
const ssa_exprt l1_object = ssa.get_l1_object ();
177
205
THEN (" level 0 and level 1 are the same, l2 is removed" )
0 commit comments