Skip to content

Commit 3e42990

Browse files
authored
Merge pull request #5034 from smowton/smowton/cleanup/constant-pointer-expr
Add goto_trace_constant_pointer_exprt
2 parents 82b08f8 + 58f8101 commit 3e42990

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: 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)