File tree Expand file tree Collapse file tree 5 files changed +21
-8
lines changed
Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ trace_malloc1.c
44^EXIT=10$
55^SIGNAL=0$
66^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\) $
88^ 5 main::1::p := cast\(❝heap-1❞, signedbv\[32\]\*\)$
99^ 7 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 10\] := 1$
1010^ 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
44^EXIT=10$
55^SIGNAL=0$
66^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\] \)$
88^ 7 main::1::array\[2\] := 123$
99--
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ trace_pointer3.c
44^EXIT=10$
55^SIGNAL=0$
66^Trace for main\.assertion\.1:$
7- ^ 8 main::1::p := ❝x❞ $
7+ ^ 8 main::1::p := address_of\(x\) $
88^ 9 x\.b := 123$
99--
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ trace_struct1.c
44^EXIT=10$
55^SIGNAL=0$
66^Trace for main\.assertion\.1:$
7- ^ 10 main::1::p := ❝x❞\.❝c❞ $
7+ ^ 10 main::1::p := address_of\(x\.c\) $
88^ 11 x\.c := 789$
99--
Original file line number Diff line number Diff line change @@ -61,6 +61,15 @@ optionalt<exprt> address_to_lvalue(exprt src)
6161 return {};
6262}
6363
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+
6473void show_trace (
6574 const std::vector<framet> &frames,
6675 const propertyt &property,
@@ -123,13 +132,17 @@ void show_trace(
123132 consolet::out () << std::setw (4 ) << ' ' ;
124133 }
125134
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);
129139 else
130140 consolet::out () << ' [' << format (update.address ) << ' ]' ;
131141
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);
133146 consolet::out () << ' \n ' ;
134147 }
135148 }
You can’t perform that action at this time.
0 commit comments