Skip to content

Commit 33bdc58

Browse files
zhassan-awstedinski
authored andcommitted
Added a goto-instrument --drop-unused-functions step to rmc and cargo-rmc (rust-lang#643)
* Added a goto-instrument --drop-unused-functions step to rmc and cargo-rmc * Added a test that checks the number of asserts * Marked test as verify-fail till rust-lang#648 is fixed
1 parent 949a22b commit 33bdc58

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed

scripts/cargo-rmc

+19-11
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,25 @@ def main():
8383
if EXIT_CODE_SUCCESS != rmc.goto_to_symbols(cbmc_filename, symbols_filename, args.verbose, args.dry_run):
8484
return 1
8585

86-
# https://github.com/diffblue/cbmc/issues/6393
87-
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
88-
cbmc_filename, cbmc_filename,
89-
['--add-library'],
90-
args.verbose, dry_run=args.dry_run):
91-
return 1
92-
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
93-
cbmc_filename, cbmc_filename,
94-
['--generate-function-body-options', 'assert-false', '--generate-function-body', '.*'],
95-
args.verbose, dry_run=args.dry_run):
96-
return 1
86+
if args.undefined_function_checks:
87+
# https://github.com/diffblue/cbmc/issues/6393
88+
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
89+
cbmc_filename, cbmc_filename,
90+
['--add-library'],
91+
args.verbose, dry_run=args.dry_run):
92+
return 1
93+
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
94+
cbmc_filename, cbmc_filename,
95+
['--generate-function-body-options', 'assert-false', '--generate-function-body', '.*', '--drop-unused-functions'],
96+
args.verbose, dry_run=args.dry_run):
97+
return 1
98+
else:
99+
# Apply --drop-unused-functions if undefined-function-checks was turned off
100+
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
101+
cbmc_filename, cbmc_filename,
102+
['--drop-unused-functions'],
103+
args.verbose, dry_run=args.dry_run):
104+
return 1
97105

98106
if "--function" not in args.cbmc_args:
99107
args.cbmc_args.extend(["--function", args.function])

scripts/rmc

+8-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ def main():
101101
return 1
102102
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
103103
goto_filename, goto_filename,
104-
['--generate-function-body-options', 'assert-false', '--generate-function-body', '.*'],
104+
['--generate-function-body-options', 'assert-false', '--generate-function-body', '.*', '--drop-unused-functions'],
105+
args.verbose, dry_run=args.dry_run):
106+
return 1
107+
else:
108+
# Apply --drop-unused-functions if undefined-function-checks was turned off
109+
if EXIT_CODE_SUCCESS != rmc.run_goto_instrument(
110+
goto_filename, goto_filename,
111+
['--drop-unused-functions'],
105112
args.verbose, dry_run=args.dry_run):
106113
return 1
107114

src/test/expected/one-assert/expected

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
** 0 of 1 failed (1 iterations)

src/test/expected/one-assert/test.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
pub fn main() {
5+
let x: u8 = rmc::nondet();
6+
let y = x;
7+
assert!(x == y);
8+
}

src/test/rmc/Never/never_return.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// rmc-verify-fail
34

45
#![feature(never_type)]
56

0 commit comments

Comments
 (0)