Skip to content

Commit e7c87e9

Browse files
peterschrammeltautschnig
authored andcommitted
Set malloc_may_fail, malloc_failure_mode via defines
Do not fix up the value by tweaking __CPROVER_initialize. This simplifies the code and allows us to regenerate __CPROVER_initialize at any time (at least as far as __CPROVER_malloc_may_fail and __CPROVER_malloc_failure_mode are concerned). This change also avoids any cost of variables to be processed by program analysis when they are compile-time constants. This, in turn, entails updates to various goto-analyzer tests. These updates include removal of redundant patterns.
1 parent 00fef58 commit e7c87e9

File tree

39 files changed

+200
-304
lines changed

39 files changed

+200
-304
lines changed

doc/cprover-manual/properties.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,9 @@ those two options are used, CBMC will assume that `malloc` does not fail.
412412
Malloc may also fail for external reasons which are not modelled by CProver. If
413413
you want to replicate this behaviour use the option `--malloc-may-fail` in
414414
conjunction with one of the above modes of failure.
415+
416+
These malloc failure options need to be set when the C library model is added to
417+
the program. Typically this is upon invoking CBMC, but if the user has chosen to
418+
do so via `goto-instrument --add-library`, then the malloc failure mode needs to
419+
be specified with that `goto-instrument` invocation, i.e., as an option to
420+
`goto-instrument`.

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,6 @@ int jbmc_parse_optionst::get_goto_program(
721721

722722
goto_modelt &goto_model = dynamic_cast<goto_modelt &>(*goto_model_ptr);
723723

724-
// if we added the ansi-c library models here this should also call
725-
// add_malloc_may_fail_variable_initializations(goto_model);
726-
// here
727-
728724
if(cmdline.isset("validate-goto-model"))
729725
{
730726
goto_model.validate();

regression/goto-analyzer/constant_propagation_01/test-vsd.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 7, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 16, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 14, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 7, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 16, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 14, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_02/test-vsd.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 15, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 13, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_02/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 15, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 13, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_03/test-vsd.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 15, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 13, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_03/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 15, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 13, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_04/test-vsd.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 15, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 13, function calls: 2$
88
--
99
^warning: ignoring

regression/goto-analyzer/constant_propagation_04/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
7-
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 15, function calls: 2$
7+
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 13, function calls: 2$
88
--
99
^warning: ignoring

0 commit comments

Comments
 (0)