File tree 5 files changed +21
-8
lines changed
5 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ trace_malloc1.c
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^Trace for main\.assertion\.1:$
7
- ^ 5 main::\$tmp::return_value_malloc := ❝ heap-1❞ $
7
+ ^ 5 main::\$tmp::return_value_malloc := address_of\( heap-1\) $
8
8
^ 5 main::1::p := cast\(❝heap-1❞, signedbv\[32\]\*\)$
9
9
^ 7 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 10\] := 1$
10
10
^ 8 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 20\] := 2$
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ trace_pointer2.c
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^Trace for main\.assertion\.1:$
7
- ^ 6 main::1::x := element_address\(❝ main::1::array❞, 0 \)$
7
+ ^ 6 main::1::x := address_of\( main::1::array\[0\] \)$
8
8
^ 7 main::1::array\[2\] := 123$
9
9
--
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ trace_pointer3.c
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^Trace for main\.assertion\.1:$
7
- ^ 8 main::1::p := ❝x❞ $
7
+ ^ 8 main::1::p := address_of\(x\) $
8
8
^ 9 x\.b := 123$
9
9
--
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ trace_struct1.c
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^Trace for main\.assertion\.1:$
7
- ^ 10 main::1::p := ❝x❞\.❝c❞ $
7
+ ^ 10 main::1::p := address_of\(x\.c\) $
8
8
^ 11 x\.c := 789$
9
9
--
Original file line number Diff line number Diff line change @@ -61,6 +61,15 @@ optionalt<exprt> address_to_lvalue(exprt src)
61
61
return {};
62
62
}
63
63
64
+ static exprt use_address_of (exprt src)
65
+ {
66
+ auto src_lvalue_opt = address_to_lvalue (src);
67
+ if (src_lvalue_opt.has_value ())
68
+ return address_of_exprt (*src_lvalue_opt);
69
+ else
70
+ return src;
71
+ }
72
+
64
73
void show_trace (
65
74
const std::vector<framet> &frames,
66
75
const propertyt &property,
@@ -123,13 +132,17 @@ void show_trace(
123
132
consolet::out () << std::setw (4 ) << ' ' ;
124
133
}
125
134
126
- auto lvalue_opt = address_to_lvalue (update.address );
127
- if (lvalue_opt.has_value ())
128
- consolet::out () << format (*lvalue_opt);
135
+ // use an l-value expression for better readability, if possible
136
+ auto lhs_lvalue_opt = address_to_lvalue (update.address );
137
+ if (lhs_lvalue_opt.has_value ())
138
+ consolet::out () << format (*lhs_lvalue_opt);
129
139
else
130
140
consolet::out () << ' [' << format (update.address ) << ' ]' ;
131
141
132
- consolet::out () << " := " << format (update.value );
142
+ // use address_of for better readability
143
+ auto value_with_address_of = use_address_of (update.value );
144
+
145
+ consolet::out () << " := " << format (value_with_address_of);
133
146
consolet::out () << ' \n ' ;
134
147
}
135
148
}
You can’t perform that action at this time.
0 commit comments