Skip to content

Commit 301bc13

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#424 from diffblue/CBMC_merge_2018-05-21
Cbmc merge 2018 05 21
2 parents 23c0457 + fc7d11a commit 301bc13

File tree

194 files changed

+3993
-1527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+3993
-1527
lines changed

cbmc/.travis.yml

-11
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,6 @@ jobs:
9090
- COMPILER="ccache /usr/bin/g++-5"
9191
- EXTRA_CXXFLAGS="-D_GLIBCXX_DEBUG"
9292

93-
# OS X using g++
94-
- stage: Test different OS/CXX/Flags
95-
os: osx
96-
sudo: false
97-
compiler: gcc
98-
cache: ccache
99-
before_install:
100-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache parallel
101-
- export PATH=$PATH:/usr/local/opt/ccache/libexec
102-
env: COMPILER="ccache g++"
103-
10493
# OS X using clang++
10594
- stage: Test different OS/CXX/Flags
10695
os: osx
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetCharSequence
4+
{
5+
static void main()
6+
{
7+
CharSequence x = CProver.nondetWithNull();
8+
assert x == null || x instanceof CharSequence;
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
NondetCharSequence.class
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetString
4+
{
5+
static void main()
6+
{
7+
String x = CProver.nondetWithNull();
8+
assert x == null || x instanceof String;
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
NondetString.class
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetStringBuffer
4+
{
5+
static void main()
6+
{
7+
StringBuffer x = CProver.nondetWithNull();
8+
assert x == null || x instanceof StringBuffer;
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
NondetStringBuffer.class
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetStringBuilder
4+
{
5+
static void main()
6+
{
7+
StringBuilder x = CProver.nondetWithNull();
8+
assert x == null || x instanceof StringBuilder;
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
NondetStringBuilder.class
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

cbmc/regression/cbmc-java/NullPointer3/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NullPointer3.class
33
--pointer-check
44
^EXIT=10$
55
^SIGNAL=0$
6-
^.*Throw null: FAILURE$
6+
^.*Null pointer check: FAILURE$
77
^VERIFICATION FAILED$
88
--
99
^warning: ignoring
251 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
public class Test {
2+
3+
// In each of these cases a guard is repeated -- either an explicit assertion,
4+
// or a guard implied by Java's semantics, e.g. that an array index is in bounds.
5+
// It should be possible to violate the condition the first time, but not the second,
6+
// as the program would have aborted (without --java-throw-runtime-exceptions) or a
7+
// runtime exception thrown (with --java-throw-runtime-exceptions).
8+
9+
public static void testAssertion(boolean condition) {
10+
assert(condition);
11+
assert(condition);
12+
}
13+
14+
public static void testArrayBounds(int[] array, int index) {
15+
if(array == null)
16+
return;
17+
int got = array[index];
18+
got = array[index];
19+
}
20+
21+
public static void testClassCast(boolean unknown) {
22+
A maybe_b = unknown ? new A() : new B();
23+
B definitely_b = (B)maybe_b;
24+
definitely_b = (B)maybe_b;
25+
}
26+
27+
public static void testNullDeref(A maybeNull) {
28+
int got = maybeNull.field;
29+
got = maybeNull.field;
30+
}
31+
32+
public static void testDivByZero(int unknown) {
33+
int div = 1 / unknown;
34+
div = 1 / unknown;
35+
}
36+
37+
public static void testArrayCreation(int maybeNegative) {
38+
int[] arr = new int[maybeNegative];
39+
arr = new int[maybeNegative];
40+
}
41+
42+
}
43+
44+
class A { public int field; }
45+
class B extends A {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.testArrayBounds
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
array-index-out-of-bounds-low\.1.*: FAILURE$
8+
array-index-out-of-bounds-low\.2.*: SUCCESS$
9+
array-index-out-of-bounds-high\.1.*: FAILURE$
10+
array-index-out-of-bounds-high\.2.*: SUCCESS$
11+
--
12+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.testArrayCreation
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
array-create-negative-size\.1.*: FAILURE$
8+
array-create-negative-size\.2.*: SUCCESS$
9+
--
10+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.testAssertion
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
assertion at file Test\.java line 10.*: FAILURE$
8+
assertion at file Test\.java line 11.*: SUCCESS$
9+
--
10+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.testClassCast
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
bad-dynamic-cast\.1.*: FAILURE$
8+
bad-dynamic-cast\.2.*: SUCCESS$
9+
--
10+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.testDivByZero
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
integer-divide-by-zero\.1.*: FAILURE$
8+
integer-divide-by-zero\.2.*: SUCCESS$
9+
--
10+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--function Test.testNullDeref
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
testNullDeref:\(LA;\)V\.null-pointer-exception\.1.*: FAILURE$
8+
testNullDeref:\(LA;\)V\.null-pointer-exception\.2.*: SUCCESS$
9+
--
10+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <assert.h>
2+
3+
// After a reachability slice based on the assertion in `target`, we should
4+
// retain both its possible callers (...may_call_target_1, ...may_call_target_2)
5+
// and their callees, but should be more precise concerning before_target and
6+
// after_target, which even though they are also called by
7+
// `unreachable_calls_before_target` and `unreachable_calls_after_target`, those
8+
// functions are not reachable.
9+
10+
void before_target()
11+
{
12+
const char *local = "before_target_kept";
13+
}
14+
15+
void after_target()
16+
{
17+
const char *local = "after_target_kept";
18+
}
19+
20+
void target()
21+
{
22+
const char *local = "target_kept";
23+
24+
before_target();
25+
assert(0);
26+
after_target();
27+
}
28+
29+
void unreachable_calls_before_target()
30+
{
31+
const char *local = "unreachable_calls_before_target_kept";
32+
before_target();
33+
}
34+
35+
void unreachable_calls_after_target()
36+
{
37+
const char *local = "unreachable_calls_after_target_kept";
38+
after_target();
39+
}
40+
41+
void reachable_before_target_caller_1()
42+
{
43+
const char *local = "reachable_before_target_caller_1_kept";
44+
}
45+
46+
void reachable_after_target_caller_1()
47+
{
48+
const char *local = "reachable_after_target_caller_1_kept";
49+
}
50+
51+
void reachable_may_call_target_1()
52+
{
53+
const char *local = "reachable_may_call_target_1_kept";
54+
reachable_before_target_caller_1();
55+
target();
56+
reachable_after_target_caller_1();
57+
}
58+
59+
void reachable_before_target_caller_2()
60+
{
61+
const char *local = "reachable_before_target_caller_2_kept";
62+
}
63+
64+
void reachable_after_target_caller_2()
65+
{
66+
const char *local = "reachable_after_target_caller_2_kept";
67+
}
68+
69+
void reachable_may_call_target_2()
70+
{
71+
const char *local = "reachable_may_call_target_2_kept";
72+
reachable_before_target_caller_2();
73+
target();
74+
reachable_after_target_caller_2();
75+
}
76+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
test.c
3+
--reachability-slice-fb --show-goto-functions
4+
target_kept
5+
reachable_before_target_caller_1_kept
6+
reachable_after_target_caller_1_kept
7+
reachable_may_call_target_1_kept
8+
reachable_before_target_caller_2_kept
9+
reachable_after_target_caller_2_kept
10+
reachable_may_call_target_2_kept
11+
--
12+
unreachable_calls_before_target_kept
13+
unreachable_calls_after_target_kept
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
typedef float _Float32;
2+
typedef double _Float32x;
3+
typedef double _Float64;
4+
typedef long double _Float64x;
5+
typedef long double _Float128;
6+
typedef long double _Float128x;
7+
8+
int main(int argc, char** argv) {
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

cbmc/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ main.c
99
^SIGNAL=0$
1010
--
1111
^warning: ignoring
12-
^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$
13-
^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$
14-
^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$
15-
^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$
16-
^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$
17-
^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$
12+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f1 THEN GOTO [0-9]$
13+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f5 THEN GOTO [0-9]$
14+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f6 THEN GOTO [0-9]$
15+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f7 THEN GOTO [0-9]$
16+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f8 THEN GOTO [0-9]$
17+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f9 THEN GOTO [0-9]$
1818
function \w+: replacing function pointer by 9 possible targets

cbmc/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ replacing function pointer by 3 possible targets
1010
^SIGNAL=0$
1111
--
1212
^warning: ignoring
13-
^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$
14-
^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$
15-
^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$
16-
^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$
17-
^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$
18-
^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$
13+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f1 THEN GOTO [0-9]$
14+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f5 THEN GOTO [0-9]$
15+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f6 THEN GOTO [0-9]$
16+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f7 THEN GOTO [0-9]$
17+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f8 THEN GOTO [0-9]$
18+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f9 THEN GOTO [0-9]$
1919
function \w+: replacing function pointer by 9 possible targets

cbmc/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ main.c
99
^SIGNAL=0$
1010
--
1111
^warning: ignoring
12-
^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$
13-
^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$
14-
^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$
15-
^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$
16-
^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$
17-
^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$
12+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f1 THEN GOTO [0-9]$
13+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f5 THEN GOTO [0-9]$
14+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f6 THEN GOTO [0-9]$
15+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f7 THEN GOTO [0-9]$
16+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f8 THEN GOTO [0-9]$
17+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f9 THEN GOTO [0-9]$
1818
function \w+: replacing function pointer by 9 possible targets

cbmc/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ main.c
99
^SIGNAL=0$
1010
--
1111
^warning: ignoring
12-
^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$
13-
^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$
14-
^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$
15-
^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$
16-
^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$
17-
^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$
12+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f1 THEN GOTO [0-9]$
13+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f5 THEN GOTO [0-9]$
14+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f6 THEN GOTO [0-9]$
15+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f7 THEN GOTO [0-9]$
16+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f8 THEN GOTO [0-9]$
17+
^\s*IF fp_tbl\[\(signed( long)? long int\)i\] == f9 THEN GOTO [0-9]$
1818
function \w+: replacing function pointer by 9 possible targets

0 commit comments

Comments
 (0)