Skip to content

Commit 2a78b3d

Browse files
Add tests for filtering shadow memory
The --no-shadow-memory-matching option will allow to avoid the allocation of shadow memory for matching variables.
1 parent c120e32 commit 2a78b3d

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
struct STRUCTNAME
5+
{
6+
int x;
7+
};
8+
9+
void f_charptr_val(char *__cs_param)
10+
{
11+
// Access to shadow memory of z.
12+
assert(__CPROVER_get_field(__cs_param, "field1") == 255);
13+
14+
// Fails because parameter itself doesn't have shadow memory.
15+
assert(__CPROVER_get_field(&__cs_param, "field1") == 0);
16+
}
17+
18+
int main()
19+
{
20+
__CPROVER_field_decl_local("field1", (char)0);
21+
22+
char *__cs_threadargs[2];
23+
struct STRUCTNAME z;
24+
__CPROVER_set_field(&z, "field1", 255);
25+
26+
__cs_threadargs[1] = (char *)(&z);
27+
f_charptr_val(__cs_threadargs[1]);
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FUTURE
2+
main.c
3+
--no-shadow-memory-matching '.*\.c:.*__cs_.*'
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
^Shadow memory: field 'field1' expected to exist for

0 commit comments

Comments
 (0)