rapx/check/senryx/verification/
pointer.rs1use crate::check::senryx::{contract::ContractExpr, visitor::BodyVisitor};
8use rustc_middle::ty::Ty;
9
10impl<'tcx> BodyVisitor<'tcx> {
11 pub fn check_allocated(&self, _arg: usize) -> bool {
13 true
14 }
15
16 pub fn check_valid_ptr(
18 &self,
19 arg: usize,
20 length_arg: ContractExpr<'tcx>,
21 contract_ty: Ty<'tcx>,
22 ) -> bool {
23 !self.check_non_zst(arg)
24 || (self.check_non_zst(arg) && self.check_deref(arg, length_arg, contract_ty))
25 }
26
27 pub fn check_deref(
29 &self,
30 arg: usize,
31 length_arg: ContractExpr<'tcx>,
32 contract_ty: Ty<'tcx>,
33 ) -> bool {
34 self.check_allocated(arg) && self.check_inbound(arg, length_arg, contract_ty)
35 }
36
37 pub fn check_ref_to_ptr(
39 &self,
40 arg: usize,
41 length_arg: ContractExpr<'tcx>,
42 contract_ty: Ty<'tcx>,
43 ) -> bool {
44 self.check_deref(arg, length_arg, contract_ty)
45 && self.check_init(arg)
46 && self.check_align(arg, contract_ty)
47 && self.check_alias(arg)
48 }
49}