File tree 6 files changed +48
-2
lines changed
regression/cbmc/havoc_undefined_functions
6 files changed +48
-2
lines changed Original file line number Diff line number Diff line change
1
+ void function (int * a );
2
+
3
+ int main ()
4
+ {
5
+ int a = 0 ;
6
+ function (& a );
7
+ __CPROVER_assert (a == 0 ,"" );
8
+ return 0 ;
9
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --havoc-undefined-functions
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
165
165
cmdline.get_value (" localize-faults-method" ));
166
166
}
167
167
168
+ if (cmdline.isset (" havoc-undefined-functions" ))
169
+ options.set_option (" havoc-undefined-functions" , true );
170
+
168
171
if (cmdline.isset (" unwind" ))
169
172
options.set_option (" unwind" , cmdline.get_value (" unwind" ));
170
173
@@ -995,6 +998,9 @@ void cbmc_parse_optionst::help()
995
998
" --partial-loops permit paths with partial loops\n "
996
999
" --no-pretty-names do not simplify identifiers\n "
997
1000
" --graphml-witness filename write the witness in GraphML format to filename\n " // NOLINT(*)
1001
+ " --havoc-undefined-functions\n "
1002
+ " for any function that has no body, assign non-deterministic values to\n " // NOLINT(*)
1003
+ " any parameters passed as non-const pointers and the return value\n " // NOLINT(*)
998
1004
" \n "
999
1005
" Backend options:\n "
1000
1006
" --object-bits n number of bits used for object addresses\n "
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ class optionst;
52
52
" (show-symbol-table)(show-parse-tree)(show-vcc)" \
53
53
" (show-claims)(claim):(show-properties)" \
54
54
" (drop-unused-functions)" \
55
+ " (havoc-undefined-functions)" \
55
56
" (property):(stop-on-fail)(trace)" \
56
57
" (error-label):(verbosity):(no-library)" \
57
58
" (nondet-static)" \
Original file line number Diff line number Diff line change @@ -194,7 +194,13 @@ void symex_bmct::no_body(const irep_idt &identifier)
194
194
{
195
195
if (body_warnings.insert (identifier).second )
196
196
{
197
- warning () <<
198
- " **** WARNING: no body for function " << identifier << eom;
197
+ warning () << " **** WARNING: no body for function " << identifier;
198
+
199
+ if (options.get_bool_option (" havoc-undefined-functions" ))
200
+ {
201
+ warning ()
202
+ << " ; assigning non-deterministic values to any pointer arguments" ;
203
+ }
204
+ warning () << eom;
199
205
}
200
206
}
Original file line number Diff line number Diff line change 24
24
25
25
#include < util/c_types.h>
26
26
27
+ #include < pointer-analysis/dereference.h>
28
+
27
29
#include < analyses/dirty.h>
28
30
29
31
bool goto_symext::get_unwind_recursion (
@@ -276,6 +278,22 @@ void goto_symext::symex_function_call_code(
276
278
symex_assign_rec (state, code);
277
279
}
278
280
281
+ if (options.get_bool_option (" havoc-undefined-functions" ))
282
+ {
283
+ // assign non det to function arguments if pointers
284
+ // are not const
285
+ for (const auto &arg : call.arguments ())
286
+ {
287
+ if (arg.type ().id () == ID_pointer &&
288
+ !arg.type ().subtype ().get_bool (ID_C_constant))
289
+ {
290
+ exprt object = dereference_exprt (arg, arg.type ().subtype ());
291
+ clean_expr (object, state, true );
292
+ havoc_rec (state, guardt (), object);
293
+ }
294
+ }
295
+ }
296
+
279
297
symex_transition (state);
280
298
return ;
281
299
}
You can’t perform that action at this time.
0 commit comments