Skip to content

Generate-function-bodies: generate a meaningful assertion #6898

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ main.c
^SIGNAL=0$
^VERIFICATION FAILED$
^\[main.assertion.1\] .* assertion 0: SUCCESS$
^\[crashes_program.assertion.1\] .* assertion false: FAILURE$
^\[crashes_program.assertion.1\] .* undefined function should be unreachable: FAILURE$
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ main.c
--generate-function-body do_not_call_this --generate-function-body-options assert-false
^EXIT=10$
^SIGNAL=0$
^\[do_not_call_this.assertion.1\] .* assertion false: FAILURE$
^\[do_not_call_this.assertion.1\] .* undefined function should be unreachable: FAILURE$
--
^warning: ignoring
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ main.c
^SIGNAL=0$
^VERIFICATION FAILED$
^\[main.assertion.1\] .* assertion does_not_get_reached: SUCCESS$
^\[should_be_generated.assertion.1\] .* assertion false: FAILURE$
^\[should_be_generated.assertion.1\] .* undefined function should be unreachable: FAILURE$
12 changes: 2 additions & 10 deletions src/goto-instrument/generate_function_bodies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,8 @@ class assert_false_generate_function_bodiest : public generate_function_bodiest
};
auto assert_instruction =
add_instruction(goto_programt::make_assertion(false_exprt()));
const namespacet ns(symbol_table);
std::ostringstream comment_stream;
comment_stream << id2string(ID_assertion) << " "
<< format(assert_instruction->condition());
assert_instruction->source_location_nonconst().set_comment(
comment_stream.str());
"undefined function should be unreachable");
assert_instruction->source_location_nonconst().set_property_class(
ID_assertion);
add_instruction(goto_programt::make_end_function());
Expand All @@ -136,12 +132,8 @@ class assert_false_then_assume_false_generate_function_bodiest
};
auto assert_instruction =
add_instruction(goto_programt::make_assertion(false_exprt()));
const namespacet ns(symbol_table);
std::ostringstream comment_stream;
comment_stream << id2string(ID_assertion) << " "
<< format(assert_instruction->condition());
assert_instruction->source_location_nonconst().set_comment(
comment_stream.str());
"undefined function should be unreachable");
assert_instruction->source_location_nonconst().set_property_class(
ID_assertion);
add_instruction(goto_programt::make_assumption(false_exprt()));
Expand Down