Skip to content

Pretty print havoc_object instructions #6174

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 1 commit into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions regression/goto-instrument/show-goto-functions1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int main()
{
int a[64];
__CPROVER_havoc_object(a);
}
8 changes: 8 additions & 0 deletions regression/goto-instrument/show-goto-functions1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--show-goto-functions
HAVOC_OBJECT \(void \*\)a
^SIGNAL=0$
^EXIT=0$
--
irep\("\(.* \(\\"havoc_object\\"\)\)"\)
14 changes: 13 additions & 1 deletion src/goto-programs/goto_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,20 @@ std::ostream &goto_programt::output_instruction(
out << '\n';
break;

case RETURN:
case OTHER:
if(instruction.get_other().id() == ID_code)
{
const auto &code = to_code(instruction.get_other());
if(code.get_statement() == ID_havoc_object)
{
out << "HAVOC_OBJECT " << from_expr(ns, identifier, code.op0()) << '\n';
break;
}
// fallthrough
}
// fallthrough
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ 💡 might be more readable to just repeat the line from ASSIGN and break.

Copy link
Contributor Author

@SaswatPadhi SaswatPadhi Jun 14, 2021

Choose a reason for hiding this comment

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

You are right that having:

    out << from_expr(ns, identifier, instruction.get_code()) << '\n';
    break;

in place of the two fallthrough comments above would probably be more explicit, but this would also lead to code duplication, so I am somewhat hesitant. I added the comments to make it explicit that we are going to fall into the next case.


case RETURN:
case DECL:
case DEAD:
case FUNCTION_CALL:
Expand Down