Skip to content

Commit

Permalink
Check two ranges for char values
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Jul 15, 2024
1 parent 3b4042c commit d78604a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kani-compiler/src/kani_middle/transform/check_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,21 @@ pub fn ty_validity_per_offset(
ty: Ty,
current_offset: usize,
) -> Result<Vec<ValidValueReq>, String> {
debug!(typ=?ty, kind=?ty.kind(), "ty_validity_per_offset");
let layout = ty.layout().unwrap().shape();
let ty_req = || {
if ty.kind() == TyKind::RigidTy(RigidTy::Char) {
let shape = ty.layout().unwrap().shape();
let value_size = match shape.abi {
ValueAbi::Scalar(Scalar::Initialized { value, .. })
| ValueAbi::ScalarPair(Scalar::Initialized { value, .. }, _) => {
Some(value.size(machine_info))
}
_ => None,
};
return vec![ValidValueReq { offset: 0, size: value_size.unwrap(), valid_range: WrappingRange { start: 0, end: 0xD7FF }},
ValidValueReq { offset: 0, size: value_size.unwrap(), valid_range: WrappingRange { start: 0xE000, end: 0x10FFFF }}]
};
if let Some(mut req) = ValidValueReq::try_from_ty(machine_info, ty)
&& !req.is_full()
{
Expand Down

0 comments on commit d78604a

Please sign in to comment.