1212#include < string>
1313#include < utility>
1414
15- TEST_CASE (" find_object_base_expression" , " [core][smt2_incremental]" )
16- {
17- const typet base_type = pointer_typet{unsignedbv_typet{8 }, 18 };
18- const symbol_exprt object_base{" base" , base_type};
19- const symbol_exprt index{" index" , base_type};
20- const pointer_typet pointer_type{base_type, 12 };
21- std::string description;
22- optionalt<address_of_exprt> address_of;
23- using rowt = std::pair<std::string, address_of_exprt>;
24- std::tie (description, address_of) = GENERATE_REF (
25- rowt{" Address of symbol" , {object_base, pointer_type}},
26- rowt{" Address of index" , {index_exprt{object_base, index}, pointer_type}},
27- rowt{
28- " Address of struct member" ,
29- {member_exprt{object_base, " baz" , unsignedbv_typet{8 }}, pointer_type}},
30- rowt{
31- " Address of index of struct member" ,
32- {index_exprt{member_exprt{object_base, " baz" , base_type}, index},
33- pointer_type}},
34- rowt{
35- " Address of struct member at index" ,
36- {member_exprt{
37- index_exprt{object_base, index}, " baz" , unsignedbv_typet{8 }},
38- pointer_type}});
39- SECTION (description)
40- {
41- CHECK (find_object_base_expression (*address_of) == object_base);
42- }
43- }
44-
4515TEST_CASE (" Tracking object base expressions" , " [core][smt2_incremental]" )
4616{
4717 const typet base_type = pointer_typet{signedbv_typet{16 }, 18 };
4818 const symbol_exprt foo{" foo" , base_type};
4919 const symbol_exprt bar{" bar" , base_type};
20+ const symbol_exprt qux{" qux" , struct_typet{}};
5021 const symbol_exprt index{" index" , base_type};
5122 const pointer_typet pointer_type{base_type, 32 };
5223 const exprt bar_address = address_of_exprt{bar, pointer_type};
@@ -55,15 +26,15 @@ TEST_CASE("Tracking object base expressions", "[core][smt2_incremental]")
5526 address_of_exprt{index_exprt{foo, index}, pointer_type}, bar_address},
5627 notequal_exprt{
5728 address_of_exprt{
58- member_exprt{foo , " baz" , unsignedbv_typet{8 }} , pointer_type},
29+ member_exprt (qux , " baz" , unsignedbv_typet{8 }) , pointer_type},
5930 bar_address}};
6031 SECTION (" Find base expressions" )
6132 {
6233 std::vector<exprt> expressions;
6334 find_object_base_expressions (compound_expression, [&](const exprt &expr) {
6435 expressions.push_back (expr);
6536 });
66- CHECK (expressions == std::vector<exprt>{bar, foo , bar, foo});
37+ CHECK (expressions == std::vector<exprt>{bar, qux , bar, foo});
6738 }
6839 smt_object_mapt object_map = initial_smt_object_map ();
6940 SECTION (" Check initial object map has null pointer" )
@@ -83,11 +54,11 @@ TEST_CASE("Tracking object base expressions", "[core][smt2_incremental]")
8354 track_expression_objects (compound_expression, ns, object_map);
8455 SECTION (" Tracking expression objects" )
8556 {
86- CHECK (object_map.size () == 3 );
57+ CHECK (object_map.size () == 4 );
8758 const auto foo_object = object_map.find (foo);
8859 REQUIRE (foo_object != object_map.end ());
8960 CHECK (foo_object->second .base_expression == foo);
90- CHECK (foo_object->second .unique_id == 2 );
61+ CHECK (foo_object->second .unique_id == 3 );
9162 const auto bar_object = object_map.find (bar);
9263 REQUIRE (bar_object != object_map.end ());
9364 CHECK (bar_object->second .base_expression == bar);
0 commit comments