Skip to content

Commit f0b12e9

Browse files
committed
Contracts instrumentation: hide unhelpful "no body" warnings
Contracts instrumentation using inlining and has facilities to inspect warnings to ensure no unexpected warnings arise. The expected ones, however, should not be forwarded to the user as they cannot do anything about them. Closes: #8639
1 parent 4a1a325 commit f0b12e9

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

regression/contracts-dfcc/loop_assigns-slice-upto-fail/test.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ main.c
1919
^EXIT=10$
2020
^SIGNAL=0$
2121
--
22+
no body for function '__CPROVER
2223
--
2324
This test shows that __CPROVER_object_upto is supported in loop contracts.

src/goto-instrument/contracts/contracts.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,9 @@ void code_contractst::apply_loop_contract(
848848
return;
849849

850850
inlining_decoratort decorated(log.get_message_handler());
851-
goto_function_inline(
852-
goto_functions, function_name, ns, log.get_message_handler());
851+
goto_function_inline(goto_functions, function_name, ns, decorated);
853852

854-
INVARIANT(
855-
decorated.get_recursive_call_set().size() == 0,
856-
"Recursive functions found during inlining");
853+
decorated.throw_on_recursive_calls(log, 0);
857854

858855
// restore internal invariants
859856
goto_functions.update();

src/goto-instrument/contracts/dynamic-frames/dfcc_contract_clauses_codegen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,16 @@ void dfcc_contract_clauses_codegent::inline_and_check_warnings(
265265
std::set<irep_idt> recursive_call;
266266
std::set<irep_idt> not_enough_arguments;
267267

268+
// we inspect all warnings ourselves, no need to surface them
269+
null_message_handlert null_message_handler;
268270
dfcc_utilst::inline_program(
269271
goto_model,
270272
goto_program,
271273
no_body,
272274
recursive_call,
273275
missing_function,
274276
not_enough_arguments,
275-
message_handler);
277+
null_message_handler);
276278

277279
// check that the only no body / missing functions are the cprover builtins
278280
for(const auto &id : no_body)

src/goto-instrument/contracts/dynamic-frames/dfcc_infer_loop_assigns.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,11 @@ void dfcc_infer_loop_assigns_for_function(
339339
auto malloc_body = goto_functions.function_map.extract(irep_idt("malloc"));
340340
auto free_body = goto_functions.function_map.extract(irep_idt("free"));
341341

342-
// Inline all function calls in goto_function_copy.
342+
// Inline all function calls in goto_function_copy; this is best-effort
343+
// inlining, we can safely ignore warnings here.
344+
null_message_handlert null_message_handler;
343345
goto_program_inline(
344-
goto_functions, goto_function_copy.body, ns, log.get_message_handler());
346+
goto_functions, goto_function_copy.body, ns, null_message_handler);
345347
// Update the body to make sure all goto correctly jump to valid targets.
346348
goto_function_copy.body.update();
347349
// Build the loop graph after inlining.

0 commit comments

Comments
 (0)