Skip to content

Add goto_trace_constant_pointer_exprt #5034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/goto-programs/goto_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,28 @@ void show_goto_trace(
if(cmdline.isset("stack-trace")) \
options.set_option("stack-trace", true);

/// Variety of constant expression only used in the context of a GOTO trace, to
/// give both the numeric value and the symbolic value of a pointer.
class goto_trace_constant_pointer_exprt : public constant_exprt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this clarifies some things. But could you add what you put in the PR description as a documentation here to make it even clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
public:
const exprt &symbolic_pointer() const
{
return static_cast<const exprt &>(operands()[0]);
}
};

template <>
inline bool can_cast_expr<goto_trace_constant_pointer_exprt>(const exprt &base)
{
return can_cast_expr<constant_exprt>(base) && base.operands().size() == 1;
}

inline const goto_trace_constant_pointer_exprt &
to_goto_trace_constant_pointer_expr(const exprt &expr)
{
PRECONDITION(can_cast_expr<goto_trace_constant_pointer_exprt>(expr));
return static_cast<const goto_trace_constant_pointer_exprt &>(expr);
}

#endif // CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H