Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
artemagvanian committed Aug 22, 2024
1 parent 9831c1a commit 188930f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion kani-compiler/src/kani_middle/transform/check_uninit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ impl<'a, 'tcx> UninitInstrumenter<'a, 'tcx> {
}
PointeeLayout::Union { field_layouts } => {
// Writing union data, which could be either creating a union from scratch or
// performing some pointer operations with it.
// performing some pointer operations with it. If we are creating a union from
// scratch, an operation will contain a union field.

// TODO: If we don't have a union field, we are either creating a pointer to a union
// or assigning to one. In the former case, it is safe to return from this function,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use crate::kani_middle::transform::body::{InsertPosition, MutableBody, SourceInstruction};
use stable_mir::{
mir::{FieldIdx, Mutability, Operand, Place, Rvalue, Statement, StatementKind},
ty::Ty,
ty::{RigidTy, Ty},
};
use strum_macros::AsRefStr;

Expand Down Expand Up @@ -152,9 +152,19 @@ impl MemoryInitOp {
MemoryInitOp::Unsupported { .. } | MemoryInitOp::TriviallyUnsafe { .. } => {
unreachable!("operands do not exist for this operation")
}
MemoryInitOp::Copy { from, .. } => {
MemoryInitOp::Copy { from, to, .. } => {
// It does not matter which operand to return for layout generation, since both of
// them have the same pointee type.
// them have the same pointee type, so we assert that.
let from_kind = from.ty(body.locals()).unwrap().kind();
let to_kind = to.ty(body.locals()).unwrap().kind();

let RigidTy::RawPtr(from_pointee_ty, _) = from_kind.rigid().unwrap().clone() else {
unreachable!()
};
let RigidTy::RawPtr(to_pointee_ty, _) = to_kind.rigid().unwrap().clone() else {
unreachable!()
};
assert!(from_pointee_ty == to_pointee_ty);
from.ty(body.locals()).unwrap()
}
MemoryInitOp::AssignUnion { lvalue, .. } => {
Expand Down

0 comments on commit 188930f

Please sign in to comment.