Skip to content

Commit

Permalink
Merge branch 'main' into contract-vacuity
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynzech authored Oct 29, 2024
2 parents 5a23e53 + 52fcc6c commit d21019b
Show file tree
Hide file tree
Showing 39 changed files with 499 additions and 277 deletions.
88 changes: 44 additions & 44 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ dependencies = [

[[package]]
name = "anstream"
version = "0.6.15"
version = "0.6.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
dependencies = [
"anstyle",
"anstyle-parse",
Expand All @@ -41,43 +41,43 @@ dependencies = [

[[package]]
name = "anstyle"
version = "1.0.8"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56"

[[package]]
name = "anstyle-parse"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]

[[package]]
name = "anstyle-query"
version = "1.1.1"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]

[[package]]
name = "anstyle-wincon"
version = "3.0.4"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]

[[package]]
name = "anyhow"
version = "1.0.90"
version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95"
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"

[[package]]
name = "arrayvec"
Expand Down Expand Up @@ -281,7 +281,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand All @@ -292,9 +292,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"

[[package]]
name = "colorchoice"
version = "1.0.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"

[[package]]
name = "colored"
Expand Down Expand Up @@ -763,7 +763,7 @@ dependencies = [
"shell-words",
"strum",
"strum_macros",
"syn 2.0.82",
"syn 2.0.85",
"tracing",
"tracing-subscriber",
"tracing-tree 0.4.0",
Expand Down Expand Up @@ -836,7 +836,7 @@ dependencies = [
"proc-macro-error2",
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand Down Expand Up @@ -900,7 +900,7 @@ version = "0.1.0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand Down Expand Up @@ -1114,9 +1114,9 @@ dependencies = [

[[package]]
name = "pin-project-lite"
version = "0.2.14"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"

[[package]]
name = "powerfmt"
Expand Down Expand Up @@ -1190,14 +1190,14 @@ dependencies = [
"proc-macro-error-attr2",
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
name = "proc-macro2"
version = "1.0.88"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
Expand Down Expand Up @@ -1290,9 +1290,9 @@ dependencies = [

[[package]]
name = "regex"
version = "1.11.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
Expand Down Expand Up @@ -1349,9 +1349,9 @@ dependencies = [

[[package]]
name = "rustix"
version = "0.38.37"
version = "0.38.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
dependencies = [
"bitflags",
"errno",
Expand Down Expand Up @@ -1410,9 +1410,9 @@ dependencies = [

[[package]]
name = "serde"
version = "1.0.210"
version = "1.0.213"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1"
dependencies = [
"serde_derive",
]
Expand All @@ -1428,13 +1428,13 @@ dependencies = [

[[package]]
name = "serde_derive"
version = "1.0.210"
version = "1.0.213"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand Down Expand Up @@ -1581,7 +1581,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand All @@ -1597,9 +1597,9 @@ dependencies = [

[[package]]
name = "syn"
version = "2.0.82"
version = "2.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021"
checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56"
dependencies = [
"proc-macro2",
"quote",
Expand Down Expand Up @@ -1633,22 +1633,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"

[[package]]
name = "thiserror"
version = "1.0.64"
version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5"
dependencies = [
"thiserror-impl",
]

[[package]]
name = "thiserror-impl"
version = "1.0.64"
version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand Down Expand Up @@ -1745,7 +1745,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]

[[package]]
Expand Down Expand Up @@ -2156,5 +2156,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.82",
"syn 2.0.85",
]
2 changes: 1 addition & 1 deletion docs/src/reference/experimental/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Fortunately, Kani is able to report a coverage metric for each proof harness.
In the `first-steps-v2` directory, try running:

```
cargo kani --coverage -Z line-coverage --harness verify_success
cargo kani --coverage -Z source-coverage --harness verify_success
```

which verifies the harness, then prints coverage information for each line.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorial-real-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ A first proof will likely start in the following form:
Running Kani on this simple starting point will help figure out:

1. What unexpected constraints might be needed on your inputs (using `kani::assume`) to avoid "expected" failures.
2. Whether you're over-constrained. Check the coverage report using `--coverage -Z line-coverage`. Ideally you'd see 100% coverage, and if not, it's usually because you've assumed too much (thus over-constraining the inputs).
2. Whether you're over-constrained. Check the coverage report using `--coverage -Z source-coverage`. Ideally you'd see 100% coverage, and if not, it's usually because you've assumed too much (thus over-constraining the inputs).
3. Whether Kani will support all the Rust features involved.
4. Whether you've started with a tractable problem.
(Remember to try setting `#[kani::unwind(1)]` to force early termination and work up from there.)
Expand Down
4 changes: 2 additions & 2 deletions kani-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ tracing-tree = "0.4.0"

# Future proofing: enable backend dependencies using feature.
[features]
default = ['aeneas', 'cprover']
aeneas = ['charon']
default = ['cprover', 'llbc']
llbc = ['charon']
cprover = ['cbmc', 'num', 'serde']
write_json_symtab = []

Expand Down
10 changes: 5 additions & 5 deletions kani-compiler/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use tracing_subscriber::filter::Directive;
#[derive(Debug, Default, Display, Clone, Copy, AsRefStr, EnumString, VariantNames, PartialEq, Eq)]
#[strum(serialize_all = "snake_case")]
pub enum BackendOption {
/// Aeneas (LLBC) backend
#[cfg(feature = "aeneas")]
Aeneas,

/// CProver (Goto) backend
#[cfg(feature = "cprover")]
#[strum(serialize = "cprover")]
#[default]
CProver,

/// LLBC backend (Aeneas's IR)
#[cfg(feature = "llbc")]
Llbc,
}

#[derive(Debug, Default, Clone, Copy, AsRefStr, EnumString, VariantNames, PartialEq, Eq)]
Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct Arguments {
/// Option name used to select which backend to use.
#[clap(long = "backend", default_value_t = BackendOption::CProver)]
pub backend: BackendOption,
/// Print the final LLBC file to stdout. This requires `-Zaeneas`.
/// Print the final LLBC file to stdout.
#[clap(long)]
pub print_llbc: bool,
}
Expand Down
11 changes: 11 additions & 0 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,17 @@ impl GotocCtx<'_> {
dynamic_fat_ptr(typ, data_cast, vtable_expr, &self.symbol_table)
}
}
TyKind::RigidTy(RigidTy::Dynamic(..)) => {
let pointee_goto_typ = self.codegen_ty_stable(pointee_ty);
let data_cast =
data.cast_to(Type::Pointer { typ: Box::new(pointee_goto_typ) });
let meta = self.codegen_operand_stable(&operands[1]);
let vtable_expr = meta
.member("_vtable_ptr", &self.symbol_table)
.member("pointer", &self.symbol_table)
.cast_to(typ.lookup_field_type("vtable", &self.symbol_table).unwrap());
dynamic_fat_ptr(typ, data_cast, vtable_expr, &self.symbol_table)
}
_ => {
let pointee_goto_typ = self.codegen_ty_stable(pointee_ty);
data.cast_to(Type::Pointer { typ: Box::new(pointee_goto_typ) })
Expand Down
16 changes: 13 additions & 3 deletions kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,19 @@ impl GotocHook for LoopInvariantRegister {
) -> Stmt {
let loc = gcx.codegen_span_stable(span);
let func_exp = gcx.codegen_func_expr(instance, loc);

Stmt::goto(bb_label(target.unwrap()), loc)
.with_loop_contracts(func_exp.call(fargs).cast_to(Type::CInteger(CIntType::Bool)))
// Add `free(0)` to make sure the body of `free` won't be dropped to
// satisfy the requirement of DFCC.
Stmt::block(
vec![
BuiltinFn::Free
.call(vec![Expr::pointer_constant(0, Type::void_pointer())], loc)
.as_stmt(loc),
Stmt::goto(bb_label(target.unwrap()), loc).with_loop_contracts(
func_exp.call(fargs).cast_to(Type::CInteger(CIntType::Bool)),
),
],
loc,
)
}
}

Expand Down
Loading

0 comments on commit d21019b

Please sign in to comment.