-
Notifications
You must be signed in to change notification settings - Fork 277
Generate function bodies that nondet havoc the function arguments [blocks: #3457] #3455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danpoe
merged 6 commits into
diffblue:develop
from
danpoe:feature/nondet-function-argument-targets
Jan 22, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c90986
Move function body generation to goto instrument directory
danpoe 15e34b6
Add regression tests for havoc-ing of function arguments
danpoe 3401a38
Move function body generation before goto_check() instrumentation
danpoe 6cf7982
Pass c object factory parameters to function body generation
danpoe 3e4701a
Adapt c nondet symbol factory for use in function body generation
danpoe ade4e66
Use c nondet object factory in function body generation
danpoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
regression/goto-instrument/generate-function-body-havoc-params-simple-null/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
void func(int *p); | ||
|
||
void main() | ||
{ | ||
int *p; | ||
p = NULL; | ||
|
||
func(p); | ||
} |
7 changes: 7 additions & 0 deletions
7
regression/goto-instrument/generate-function-body-havoc-params-simple-null/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
main.c | ||
--generate-function-body func --generate-function-body-options havoc,params:p --pointer-check | ||
^SIGNAL=0$ | ||
^EXIT=0$ | ||
-- | ||
^warning: ignoring |
14 changes: 14 additions & 0 deletions
14
regression/goto-instrument/generate-function-body-havoc-params-simple/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
void func(int *p); | ||
|
||
void main() | ||
{ | ||
int i; | ||
i = 0; | ||
|
||
func(&i); | ||
|
||
assert(i == 0); | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-instrument/generate-function-body-havoc-params-simple/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--generate-function-body func --generate-function-body-options havoc,params:p | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
\[main.assertion.1\] line \d+ assertion i == 0: FAILURE | ||
-- | ||
^warning: ignoring |
33 changes: 33 additions & 0 deletions
33
...ession/goto-instrument/generate-function-body-havoc-params-struct-mutual-recursion/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct st1 | ||
{ | ||
struct st2 *to_st2; | ||
int data; | ||
} st1_t; | ||
|
||
typedef struct st2 | ||
{ | ||
struct st1 *to_st1; | ||
int data; | ||
} st2_t; | ||
|
||
st1_t dummy1; | ||
st2_t dummy2; | ||
|
||
void func(st1_t *p); | ||
|
||
void main() | ||
{ | ||
st1_t st; | ||
|
||
func(&st); | ||
|
||
assert(st.to_st2 != NULL); | ||
assert(st.to_st2->to_st1 != NULL); | ||
assert(st.to_st2->to_st1->to_st2 == NULL); | ||
|
||
assert(st.to_st2 != &dummy2); | ||
assert(st.to_st2->to_st1 != &dummy1); | ||
} |
8 changes: 8 additions & 0 deletions
8
...ion/goto-instrument/generate-function-body-havoc-params-struct-mutual-recursion/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--generate-function-body func --generate-function-body-options 'havoc,params:p' --min-null-tree-depth 10 --max-nondet-tree-depth 3 --pointer-check | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
19 changes: 19 additions & 0 deletions
19
regression/goto-instrument/generate-function-body-havoc-params-struct-non-recursive/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct st | ||
{ | ||
int data; | ||
} st_t; | ||
|
||
void func(st_t *p); | ||
|
||
void main() | ||
{ | ||
st_t st; | ||
st.data = 0; | ||
|
||
func(&st); | ||
|
||
assert(st.data == 0); | ||
} |
8 changes: 8 additions & 0 deletions
8
...ession/goto-instrument/generate-function-body-havoc-params-struct-non-recursive/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--generate-function-body func --generate-function-body-options havoc,params:p | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
\[main.assertion.1\] line \d+ assertion st.data == 0: FAILURE | ||
-- | ||
^warning: ignoring |
31 changes: 31 additions & 0 deletions
31
...sion/goto-instrument/generate-function-body-havoc-params-struct-simple-recursion-2/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct st | ||
{ | ||
struct st *next; | ||
struct st *prev; | ||
int data; | ||
} st_t; | ||
|
||
st_t dummy; | ||
|
||
void func(st_t *p); | ||
|
||
void main() | ||
{ | ||
st_t st; | ||
|
||
func(&st); | ||
|
||
assert(st.prev != NULL); | ||
assert(st.prev != &dummy); | ||
|
||
assert(st.next != NULL); | ||
assert(st.next != &dummy); | ||
|
||
assert(st.prev->prev == NULL); | ||
assert(st.prev->next == NULL); | ||
assert(st.next->prev == NULL); | ||
assert(st.next->next == NULL); | ||
} |
8 changes: 8 additions & 0 deletions
8
...n/goto-instrument/generate-function-body-havoc-params-struct-simple-recursion-2/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--generate-function-body func --generate-function-body-options havoc,params:p --min-null-tree-depth 10 --max-nondet-tree-depth 2 --pointer-check | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
26 changes: 26 additions & 0 deletions
26
...ession/goto-instrument/generate-function-body-havoc-params-struct-simple-recursion/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct st | ||
{ | ||
struct st *next; | ||
int data; | ||
} st_t; | ||
|
||
st_t dummy; | ||
|
||
void func(st_t *p); | ||
|
||
void main() | ||
{ | ||
st_t st; | ||
|
||
func(&st); | ||
|
||
assert(st.next != NULL); | ||
assert(st.next->next != NULL); | ||
assert(st.next->next->next == NULL); | ||
|
||
assert(st.next != &dummy); | ||
assert(st.next->next != &dummy); | ||
} |
8 changes: 8 additions & 0 deletions
8
...ion/goto-instrument/generate-function-body-havoc-params-struct-simple-recursion/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--generate-function-body func --generate-function-body-options havoc,params:p --min-null-tree-depth 10 --max-nondet-tree-depth 3 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,8 @@ exprt::operandst build_function_environment( | |
base_name, | ||
p.type(), | ||
p.source_location(), | ||
object_factory_parameters); | ||
object_factory_parameters, | ||
lifetimet::AUTOMATIC_LOCAL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Random place for comment: it would be nice if the commit message could explain why the existing symbol factory wasn't usable as-is. |
||
} | ||
|
||
return main_arguments; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.