Skip to content

Commit

Permalink
Add more comments, remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
artemagvanian committed Jul 3, 2024
1 parent fb2aa14 commit bb2a02b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use ty_layout::{PointeeInfo, PointeeLayout};
use uninit_visitor::{CheckUninitVisitor, InitRelevantInstruction, MemoryInitOp};

const SKIPPED_DIAGNOSTIC_ITEMS: &[&str] =
&["KaniIsUnitPtrInitialized", "KaniSetUnitPtrInitialized", "KaniContractsApplyClosure"];
&["KaniIsUnitPtrInitialized", "KaniSetUnitPtrInitialized"];

/// Instrument the code with checks for uninitialized memory.
#[derive(Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,11 @@ impl<'a> MirVisitor for CheckUninitVisitor<'a> {
}
name if name.starts_with("atomic") => {
let num_args = match name {
// All `atomic_cxchg` intrinsics take `dst, old, src` as arguments.
name if name.starts_with("atomic_cxchg") => 3,
// All `atomic_load` intrinsics take `src` as an argument.
name if name.starts_with("atomic_load") => 1,
// All other `atomic` intrinsics take `dst, src` as arguments.
_ => 2,
};
assert_eq!(
Expand Down Expand Up @@ -529,6 +532,7 @@ impl<'a> MirVisitor for CheckUninitVisitor<'a> {
for (_, prov) in &allocation.provenance.ptrs {
if let GlobalAlloc::Static(_) = GlobalAlloc::from(prov.0) {
if constant.ty().kind().is_raw_ptr() {
// If a static is a raw pointer, need to mark it as initialized.
self.push_target(MemoryInitOp::Set {
operand: Operand::Constant(constant.clone()),
count: mk_const_operand(1, location.span()),
Expand Down
1 change: 0 additions & 1 deletion library/kani/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ pub fn init_contracts() {}
/// This should only be used within contracts. The intent is to
/// perform type inference on a closure's argument
#[doc(hidden)]
#[rustc_diagnostic_item = "KaniContractsApplyClosure"]
pub fn apply_closure<T, U: Fn(&T) -> bool>(f: U, x: &T) -> bool {
f(x)
}

0 comments on commit bb2a02b

Please sign in to comment.