Skip to content

Commit 911b8b9

Browse files
authored
Propogate solver options into synthesizer (rust-lang#2320)
1 parent f70faac commit 911b8b9

File tree

7 files changed

+17
-4
lines changed

7 files changed

+17
-4
lines changed

kani-driver/src/call_cbmc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl KaniSession {
198198
args
199199
}
200200

201-
fn handle_solver_args(
201+
pub fn handle_solver_args(
202202
&self,
203203
harness_solver: &Option<CbmcSolver>,
204204
args: &mut Vec<OsString>,

kani-driver/src/call_goto_synthesizer.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use crate::util::warning;
55
use anyhow::Result;
6+
use kani_metadata::HarnessMetadata;
67
use std::ffi::OsString;
78
use std::path::Path;
89
use std::process::Command;
@@ -14,7 +15,12 @@ impl KaniSession {
1415
/// The synthesizer we use is `goto-synthesizer` built in CBMC codebase, which is an enumerative
1516
/// loop-contracts synthesizer. `goto-synthesizer` enumerates and checks if a candidate can be
1617
/// used to prove some assertions, and applies found invariants when all checks pass.
17-
pub fn synthesize_loop_contracts(&self, input: &Path, output: &Path) -> Result<()> {
18+
pub fn synthesize_loop_contracts(
19+
&self,
20+
input: &Path,
21+
output: &Path,
22+
harness_metadata: &HarnessMetadata,
23+
) -> Result<()> {
1824
if !self.args.quiet {
1925
println!("Running loop contract synthesizer.");
2026
warning("This process may not terminate.");
@@ -23,12 +29,14 @@ impl KaniSession {
2329
);
2430
}
2531

26-
let args: Vec<OsString> = vec![
32+
let mut args: Vec<OsString> = vec![
2733
"--loop-contracts-no-unwind".into(),
2834
input.to_owned().into_os_string(), // input
2935
output.to_owned().into_os_string(), // output
3036
];
3137

38+
self.handle_solver_args(&harness_metadata.attributes.solver, &mut args)?;
39+
3240
let mut cmd = Command::new("goto-synthesizer");
3341
cmd.args(args);
3442

kani-driver/src/harness_runner.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ impl<'sess, 'pr> HarnessRunner<'sess, 'pr> {
6666
)?;
6767

6868
if self.sess.args.synthesize_loop_contracts {
69-
self.sess.synthesize_loop_contracts(&specialized_obj, &specialized_obj)?;
69+
self.sess.synthesize_loop_contracts(
70+
&specialized_obj,
71+
&specialized_obj,
72+
&harness,
73+
)?;
7074
}
7175

7276
let result = self.sess.check_harness(&specialized_obj, &report_dir, harness)?;

tests/ui/LoopContractsSynthesizer/main_unsigned/main_unsigned.rs renamed to tests/ui/loop-contracts-synthesis/main_unsigned/main_unsigned.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// loop invariants.
88

99
#[kani::proof]
10+
#[kani::solver(kissat)]
1011
fn main() {
1112
let mut x: u64 = kani::any_where(|i| *i > 1);
1213

0 commit comments

Comments
 (0)