12
12
#include < string>
13
13
#include < utility>
14
14
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
-
45
15
TEST_CASE (" Tracking object base expressions" , " [core][smt2_incremental]" )
46
16
{
47
17
const typet base_type = pointer_typet{signedbv_typet{16 }, 18 };
48
18
const symbol_exprt foo{" foo" , base_type};
49
19
const symbol_exprt bar{" bar" , base_type};
20
+ const symbol_exprt qux{" qux" , struct_typet{}};
50
21
const symbol_exprt index{" index" , base_type};
51
22
const pointer_typet pointer_type{base_type, 32 };
52
23
const exprt bar_address = address_of_exprt{bar, pointer_type};
@@ -55,15 +26,15 @@ TEST_CASE("Tracking object base expressions", "[core][smt2_incremental]")
55
26
address_of_exprt{index_exprt{foo, index}, pointer_type}, bar_address},
56
27
notequal_exprt{
57
28
address_of_exprt{
58
- member_exprt{foo , " baz" , unsignedbv_typet{8 }} , pointer_type},
29
+ member_exprt (qux , " baz" , unsignedbv_typet{8 }) , pointer_type},
59
30
bar_address}};
60
31
SECTION (" Find base expressions" )
61
32
{
62
33
std::vector<exprt> expressions;
63
34
find_object_base_expressions (compound_expression, [&](const exprt &expr) {
64
35
expressions.push_back (expr);
65
36
});
66
- CHECK (expressions == std::vector<exprt>{bar, foo , bar, foo});
37
+ CHECK (expressions == std::vector<exprt>{bar, qux , bar, foo});
67
38
}
68
39
smt_object_mapt object_map = initial_smt_object_map ();
69
40
SECTION (" Check initial object map has null pointer" )
@@ -83,11 +54,11 @@ TEST_CASE("Tracking object base expressions", "[core][smt2_incremental]")
83
54
track_expression_objects (compound_expression, ns, object_map);
84
55
SECTION (" Tracking expression objects" )
85
56
{
86
- CHECK (object_map.size () == 3 );
57
+ CHECK (object_map.size () == 4 );
87
58
const auto foo_object = object_map.find (foo);
88
59
REQUIRE (foo_object != object_map.end ());
89
60
CHECK (foo_object->second .base_expression == foo);
90
- CHECK (foo_object->second .unique_id == 2 );
61
+ CHECK (foo_object->second .unique_id == 3 );
91
62
const auto bar_object = object_map.find (bar);
92
63
REQUIRE (bar_object != object_map.end ());
93
64
CHECK (bar_object->second .base_expression == bar);
0 commit comments