Skip to content

Commit 53b4457

Browse files
author
Brett Schiff
committed
Work in progress Rust Front-End
1 parent 3ad2a27 commit 53b4457

File tree

105 files changed

+6967
-8
lines changed

Some content is hidden

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

105 files changed

+6967
-8
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ jobs:
119119
compiler: clang
120120
cache: ccache
121121
before_install:
122-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache parallel gdb
123-
- export PATH=$PATH:/usr/local/opt/ccache/libexec
122+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache parallel gdb bison
123+
- export PATH=/usr/local/opt/ccache/libexec:/usr/local/opt/bison/bin:$PATH
124124
env:
125125
- COMPILER="ccache clang++"
126126
- WITH_MEMORY_ANALYZER=0
@@ -288,8 +288,8 @@ jobs:
288288
compiler: clang
289289
cache: ccache
290290
before_install:
291-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache gdb
292-
- export PATH=$PATH:/usr/local/opt/ccache/libexec
291+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache gdb bison
292+
- export PATH=/usr/local/opt/ccache/libexec:/usr/local/opt/bison/bin:$PATH
293293
env:
294294
- BUILD_SYSTEM=cmake
295295
- CCACHE_CPP2=yes

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ cprover_default_properties(
164164
langapi
165165
linking
166166
pointer-analysis
167+
rust
167168
solvers
168169
statement-list
169170
symtab2gb

buildspec-windows.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ phases:
2020
2121
- |
2222
$env:Path = "C:\tools\cygwin\bin;c:\tools\clcache\clcache-4.1.0;$env:Path"
23+
$env:INCLUDE = "C:\tools\cygwin\usr\include;$env:INCLUDE"
2324
$env:CLCACHE_DIR = "C:\clcache"
2425
$env:CLCACHE_BASEDIR = (Get-Item -Path ".\").FullName
2526
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make CXX=clcache.exe -j4 -C src BUILD_ENV=MSVC" '

regression/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ add_subdirectory(goto-harness)
5454
add_subdirectory(goto-cc-file-local)
5555
add_subdirectory(linking-goto-binaries)
5656
add_subdirectory(symtab2gb)
57+
add_subdirectory(rust)
5758

5859
if(WITH_MEMORY_ANALYZER)
5960
add_subdirectory(snapshot-harness)

regression/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ DIRS = cbmc \
2929
goto-cc-file-local \
3030
linking-goto-binaries \
3131
symtab2gb \
32+
rust \
3233
# Empty last line
3334

3435
ifeq ($(OS),Windows_NT)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
fn main() {
3+
let mut a : u32;
4+
a /= 2;
5+
let mut b : u32;
6+
b /= 2;
7+
let c = b;
8+
b += a;
9+
10+
let d = a;
11+
12+
assert!(b > a || a == 0 || c == 0);
13+
14+
b -= a;
15+
16+
assert!(c == b);
17+
18+
a *= 2;
19+
20+
assert!(a > d || d == 0);
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
fn main() {
3+
let a : u32;
4+
assert!( a / 2 <= a );
5+
assert!( a / 2 * 2 >= a / 2 );
6+
assert!( a / 2 + 5 + 1 > a / 2 + 5);
7+
assert!(a / 2 + 5 + 1 - 2 < a / 2 + 5);
8+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
fn main() {
3+
assert!(3 | 5 == 7);
4+
assert!(7 & 9 == 1);
5+
assert!(9 ^ 7 == 14);
6+
assert!(!8 ^ !0 == 8);
7+
8+
let x = 1;
9+
let a : u32;
10+
let b : u32;
11+
let c = a + b;
12+
if c & x == x {
13+
let d = a ^ b;
14+
assert!(d & x == x);
15+
}
16+
else {
17+
assert!(a & x == b & x)
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
fn main() {
3+
let mut x = 0;
4+
x |= 1;
5+
assert!(x == 1);
6+
x ^= 7;
7+
assert!(x == 6);
8+
x %= 4;
9+
assert!(x == 2);
10+
x = 18;
11+
x &= 15;
12+
assert!(x == 2);
13+
14+
let mut a : u32;
15+
a %= 8;
16+
17+
let mut b : u32;
18+
b %= 8;
19+
20+
let mut c = a;
21+
let mut d = b;
22+
23+
c &= b;
24+
d |= a;
25+
26+
assert!(c < 8 && d < 8);
27+
assert!(c + d >= c & d);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
fn main() {
3+
assert!(8 >> 4 == 0);
4+
assert!(1 << 4 == 16);
5+
6+
let mut a = 8;
7+
assert!(a >> 1 == 4);
8+
assert!(a << 1 == 16);
9+
10+
a <<= 2;
11+
assert!(a == 32);
12+
a >>= 3;
13+
assert!(a == 4);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
fn main() {
3+
assert!(true);
4+
assert!(true || false);
5+
assert!(!false);
6+
7+
let a = true;
8+
let b = false;
9+
let c = a || b;
10+
let d = c && a;
11+
assert!(d && true);
12+
assert!(!b && d);
13+
14+
let e : bool;
15+
assert!(e || !e);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

regression/rust/CMakeLists.txt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
add_test_pl_tests(
2+
"$<TARGET_FILE:cbmc> --validate-goto-model --validate-ssa-equation"
3+
)
4+
5+
add_test_pl_profile(
6+
"cbmc-paths-lifo"
7+
"$<TARGET_FILE:cbmc> --paths lifo"
8+
"-C;-s;paths-lifo"
9+
"CORE"
10+
)
11+
12+
add_test_pl_profile(
13+
"cbmc-cprover-smt2"
14+
"$<TARGET_FILE:cbmc> --cprover-smt2"
15+
"-C;-X;broken-smt-backend;-s;cprover-smt2"
16+
"CORE"
17+
)
18+
19+
set_property(
20+
TEST "cbmc-cprover-smt2-CORE"
21+
PROPERTY ENVIRONMENT
22+
"PATH=$ENV{PATH}:${CMAKE_BINARY_DIR}/bin"
23+
)

regression/rust/EQ-NE/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
fn main() {
3+
let x : u32;
4+
let y = x * 2;
5+
6+
assert!(y % 2 == 0);
7+
assert!(y % 2 != 3);
8+
}

regression/rust/EQ-NE/test.desc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
fn main() {
3+
assert!(x_plus_two_1(0) == 2);
4+
assert!(x_plus_two_2(1) == 3);
5+
assert!(x_plus_two_1(x_plus_two_2(0) + 1) == 5);
6+
}
7+
fn x_plus_two_1(x : u32) -> u32 {
8+
x + 2
9+
}
10+
fn x_plus_two_2(x : u32) -> u32 {
11+
let y = x + 1;
12+
{
13+
let z = 1;
14+
y + z
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
fn main() {
3+
assert!(true);
4+
trivial_function();
5+
assert!(1.0 == 1.0);
6+
}
7+
fn trivial_function() {
8+
assert!(1 + 1 == 2);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
fn main() {
3+
check_u32(4);
4+
check_u32(123);
5+
check_u32(119);
6+
}
7+
fn check_u32(x : u32) {
8+
if x % 2 == 0 {
9+
assert!(x < 119)
10+
} else if x % 3 == 0 {
11+
assert!(x > 119)
12+
} else {
13+
assert!(x == 119)
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
fn main() {
3+
let a = return_u32();
4+
assert!(a < 10);
5+
assert!(return_u32() < 10);
6+
assert!(return_u64() >= 100);
7+
assert!(return_bool());
8+
assert!(return_f32() < 21.0);
9+
assert!(return_f64() < 11.0 && return_f64() > -11.0);
10+
}
11+
fn return_u32() -> u32 {
12+
let x : u32;
13+
14+
if x < 10 {
15+
return x;
16+
} else {
17+
return 5;
18+
}
19+
}
20+
fn return_u64() -> u64 {
21+
let x : u64;
22+
23+
if x > 100 {
24+
return x;
25+
} else {
26+
return 100;
27+
}
28+
}
29+
fn return_bool() -> bool {
30+
let x : bool;
31+
if x {
32+
return x;
33+
} else {
34+
return !x;
35+
}
36+
}
37+
fn return_f32() -> f32 {
38+
let x = 10.0;
39+
let y : bool;
40+
if y {
41+
return x / 2.0;
42+
} else {
43+
return x * 2.0;
44+
}
45+
}
46+
fn return_f64() -> f64 {
47+
let x : f64;
48+
if x <= 10.0 && x >= -10.0 {
49+
return x;
50+
} else {
51+
return 0.0;
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.rs
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

0 commit comments

Comments
 (0)