Skip to content

Commit 58f8101

Browse files
committed
Add goto_trace_constant_pointer_exprt
These are derivatives of constant_exprt which give a pointer's numerical address in the usual constant value slot, but which also have an operand giving its symbolic value (e.g. "0xabcd0004" vs. "&some_object + 4"
1 parent 744671a commit 58f8101

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/goto-programs/goto_trace.h

+24
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,28 @@ void show_goto_trace(
292292
if(cmdline.isset("stack-trace")) \
293293
options.set_option("stack-trace", true);
294294

295+
/// Variety of constant expression only used in the context of a GOTO trace, to
296+
/// give both the numeric value and the symbolic value of a pointer.
297+
class goto_trace_constant_pointer_exprt : public constant_exprt
298+
{
299+
public:
300+
const exprt &symbolic_pointer() const
301+
{
302+
return static_cast<const exprt &>(operands()[0]);
303+
}
304+
};
305+
306+
template <>
307+
inline bool can_cast_expr<goto_trace_constant_pointer_exprt>(const exprt &base)
308+
{
309+
return can_cast_expr<constant_exprt>(base) && base.operands().size() == 1;
310+
}
311+
312+
inline const goto_trace_constant_pointer_exprt &
313+
to_goto_trace_constant_pointer_expr(const exprt &expr)
314+
{
315+
PRECONDITION(can_cast_expr<goto_trace_constant_pointer_exprt>(expr));
316+
return static_cast<const goto_trace_constant_pointer_exprt &>(expr);
317+
}
318+
295319
#endif // CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H

0 commit comments

Comments
 (0)