File tree Expand file tree Collapse file tree 6 files changed +47
-18
lines changed
regression/contracts-dfcc/assigns_replace_02
goto-instrument/contracts/dynamic-frames Expand file tree Collapse file tree 6 files changed +47
-18
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ int main()
9
9
{
10
10
int n ;
11
11
int m = 4 ;
12
- bar (& n );
12
+ foo (& n );
13
13
assert (m == 4 );
14
14
15
15
return 0 ;
Original file line number Diff line number Diff line change @@ -323,10 +323,20 @@ void dfcc_instrumentt::instrument_function_body(
323
323
324
324
if (!goto_function.body_available ())
325
325
{
326
- log.warning () << " DFCC instrumentation: '" << function_id
327
- << " ' body is not available. Results may be unsound if the "
328
- " actual function has side effects."
329
- << messaget::eom;
326
+ // we interpret this as "the function should be unreachable"
327
+ // create fatal assertion code block as body
328
+ const auto &function_location =
329
+ utils.get_function_symbol (function_id).location ;
330
+ source_locationt sl;
331
+ sl.set_property_class (" reachability" );
332
+ sl.set_function (function_id);
333
+ sl.set_line (0 );
334
+ sl.set_column (0 );
335
+ sl.set_file (function_location.get_file ());
336
+ sl.set_working_directory (function_location.get_working_directory ());
337
+ sl.set_comment (
338
+ " Function " + id2string (function_id) + " should not be reachable" );
339
+ utils.gen_fatal_assertion_body (function_id, sl);
330
340
return ;
331
341
}
332
342
Original file line number Diff line number Diff line change @@ -469,9 +469,6 @@ void dfcc_libraryt::inhibit_front_end_builtins()
469
469
const auto &fid = it.first ;
470
470
if (goto_model.symbol_table .has_symbol (fid))
471
471
{
472
- // make sure parameter symbols exist
473
- utils.fix_parameters_symbols (fid);
474
-
475
472
// create fatal assertion code block as body
476
473
source_locationt sl;
477
474
sl.set_function (fid);
@@ -480,16 +477,7 @@ void dfcc_libraryt::inhibit_front_end_builtins()
480
477
sl.set_comment (
481
478
" Built-in " + id2string (fid) +
482
479
" should not be called after contracts transformation" );
483
- auto block = create_fatal_assertion (false_exprt (), sl);
484
- auto &symbol = goto_model.symbol_table .get_writeable_ref (fid);
485
- symbol.value = block;
486
-
487
- // convert the function
488
- goto_convert (
489
- fid,
490
- goto_model.symbol_table ,
491
- goto_model.goto_functions ,
492
- message_handler);
480
+ utils.gen_fatal_assertion_body (fid, sl);
493
481
}
494
482
}
495
483
}
Original file line number Diff line number Diff line change @@ -42,6 +42,28 @@ dfcc_utilst::dfcc_utilst(
42
42
{
43
43
}
44
44
45
+ void dfcc_utilst::gen_fatal_assertion_body (
46
+ const irep_idt &function_id,
47
+ const source_locationt &source_location)
48
+ {
49
+ PRECONDITION (goto_model.symbol_table .has_symbol (function_id));
50
+
51
+ // make sure parameter symbols exist
52
+ fix_parameters_symbols (function_id);
53
+
54
+ // create fatal assertion code block as body
55
+ auto block = create_fatal_assertion (false_exprt (), source_location);
56
+ auto &symbol = goto_model.symbol_table .get_writeable_ref (function_id);
57
+ symbol.value = block;
58
+
59
+ // convert the function
60
+ goto_convert (
61
+ function_id,
62
+ goto_model.symbol_table ,
63
+ goto_model.goto_functions ,
64
+ message_handler);
65
+ }
66
+
45
67
const bool dfcc_utilst::symbol_exists (
46
68
const irep_idt &name,
47
69
const bool require_has_code_type,
Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ class dfcc_utilst
35
35
namespacet ns;
36
36
37
37
public:
38
+ // / \brief Genrate a body `assert(false); assume(false);`
39
+ // / for the given \p function_id.
40
+ // / \param function_id function to generate the body for
41
+ // / \param source_location source location to use for the assertion.
42
+ // / Must define the property class, comment for the assertion, etc.
43
+ void gen_fatal_assertion_body (
44
+ const irep_idt &function_id,
45
+ const source_locationt &source_location);
46
+
38
47
// / Returns true iff the given symbol exists and satisfies requirements.
39
48
const bool symbol_exists (
40
49
const irep_idt &function_id,
You can’t perform that action at this time.
0 commit comments