Skip to content

Commit b80eea6

Browse files
Add option to generate function body to goto-instrument
1 parent ed505fe commit b80eea6

File tree

19 files changed

+586
-2
lines changed

19 files changed

+586
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <assert.h>
2+
3+
void should_not_be_replaced(void)
4+
{
5+
__CPROVER_assume(0);
6+
}
7+
8+
void should_be_generated(void);
9+
10+
int main(void)
11+
{
12+
int flag;
13+
int does_not_get_reached = 0;
14+
if(flag)
15+
{
16+
should_not_be_replaced();
17+
assert(does_not_get_reached);
18+
}
19+
should_be_generated();
20+
return 0;
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--generate-function-body '(?!__).*' --replace-function-body-options assert-false
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
^\[main.assertion.1\] assertion does_not_get_reached: SUCCESS$
8+
^\[should_be_generated.assertion.1\] assertion FALSE: FAILURE$
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <assert.h>
2+
3+
void crashes_program(void);
4+
5+
int main(void)
6+
{
7+
int flag;
8+
if(flag)
9+
{
10+
crashes_program();
11+
assert(0);
12+
}
13+
return 0;
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--replace-function-body crashes_program --replace-function-body-options assert-false-assume-false
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
^\[main.assertion.1\] assertion 0: SUCCESS$
8+
^\[crashes_program.assertion.1\] assertion FALSE: FAILURE$
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void do_not_call_this(void);
2+
3+
int main(void)
4+
{
5+
do_not_call_this();
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--replace-function-body do_not_call_this --replace-function-body-options assert-false
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[do_not_call_this.assertion.1\] assertion FALSE: FAILURE$
7+
--
8+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <assert.h>
2+
3+
void will_not_return(void);
4+
5+
int main(void)
6+
{
7+
will_not_return();
8+
assert(0);
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--replace-function-body will_not_return --replace-function-body-options assume-false
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
3+
int global = 10;
4+
const int constant_global = 10;
5+
6+
void touches_globals(void);
7+
8+
int main(void)
9+
{
10+
touches_globals();
11+
assert(global == 10);
12+
assert(constant_global == 10);
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--replace-function-body touches_globals --replace-function-body-options 'havoc,globals:(?!__).*'
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
^\[main.assertion.1\] assertion global == 10: FAILURE$
8+
^\[main.assertion.2\] assertion constant_global == 10: SUCCESS$
9+
--
10+
^warning: ignoring

0 commit comments

Comments
 (0)