Skip to content

Commit 577b0ec

Browse files
committed
Generate-function-bodies: generate a meaningful assertion
When using --generate-function-body with "assert-false" or "assert-false-assume-false" make sure we produce a more meaningful description than "assertion false." Instead, make the comment say "undefined function should be unreachable." Fixes: #6393
1 parent 8bf3ea6 commit 577b0ec

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

regression/goto-instrument/generate-function-body-assert-false-assume-false/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ main.c
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
^\[main.assertion.1\] .* assertion 0: SUCCESS$
8-
^\[crashes_program.assertion.1\] .* assertion false: FAILURE$
8+
^\[crashes_program.assertion.1\] .* undefined function should be unreachable: FAILURE$

regression/goto-instrument/generate-function-body-assert-false/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ main.c
33
--generate-function-body do_not_call_this --generate-function-body-options assert-false
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[do_not_call_this.assertion.1\] .* assertion false: FAILURE$
6+
^\[do_not_call_this.assertion.1\] .* undefined function should be unreachable: FAILURE$
77
--
88
^warning: ignoring

regression/goto-instrument/generate-function-body/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ main.c
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
^\[main.assertion.1\] .* assertion does_not_get_reached: SUCCESS$
8-
^\[should_be_generated.assertion.1\] .* assertion false: FAILURE$
8+
^\[should_be_generated.assertion.1\] .* undefined function should be unreachable: FAILURE$

src/goto-instrument/generate_function_bodies.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,8 @@ class assert_false_generate_function_bodiest : public generate_function_bodiest
105105
};
106106
auto assert_instruction =
107107
add_instruction(goto_programt::make_assertion(false_exprt()));
108-
const namespacet ns(symbol_table);
109-
std::ostringstream comment_stream;
110-
comment_stream << id2string(ID_assertion) << " "
111-
<< format(assert_instruction->condition());
112108
assert_instruction->source_location_nonconst().set_comment(
113-
comment_stream.str());
109+
"undefined function should be unreachable");
114110
assert_instruction->source_location_nonconst().set_property_class(
115111
ID_assertion);
116112
add_instruction(goto_programt::make_end_function());
@@ -136,12 +132,8 @@ class assert_false_then_assume_false_generate_function_bodiest
136132
};
137133
auto assert_instruction =
138134
add_instruction(goto_programt::make_assertion(false_exprt()));
139-
const namespacet ns(symbol_table);
140-
std::ostringstream comment_stream;
141-
comment_stream << id2string(ID_assertion) << " "
142-
<< format(assert_instruction->condition());
143135
assert_instruction->source_location_nonconst().set_comment(
144-
comment_stream.str());
136+
"undefined function should be unreachable");
145137
assert_instruction->source_location_nonconst().set_property_class(
146138
ID_assertion);
147139
add_instruction(goto_programt::make_assumption(false_exprt()));

0 commit comments

Comments
 (0)