MCPcopy Create free account
hub / github.com/CodeSentryAI/lockbud / intraproc_points_to

Method intraproc_points_to

src/analysis/pointsto/mod.rs:887–915  ·  view source on GitHub ↗

Check if `pointer` points-to `pointee` in the same function.

(
        &mut self,
        instance: &Instance<'tcx>,
        pointer: ConstraintNode<'tcx>,
        pointee: ConstraintNode<'tcx>,
    )

Source from the content-addressed store, hash-verified

885
886 /// Check if `pointer` points-to `pointee` in the same function.
887 fn intraproc_points_to(
888 &mut self,
889 instance: &Instance<'tcx>,
890 pointer: ConstraintNode<'tcx>,
891 pointee: ConstraintNode<'tcx>,
892 ) -> Option<ApproximateAliasKind> {
893 let body = self.tcx.instance_mir(instance.def);
894 let points_to_map = self.get_or_insert_pts(instance.def_id(), body);
895 let pointer_pts = points_to_map.get(&pointer)?;
896 // 1. if pts(pointer) contains pointee then probably alias
897 if pointer_pts.contains(&pointee) {
898 return Some(ApproximateAliasKind::Probably);
899 }
900 let pointee_pts = points_to_map.get(&pointee)?;
901 // 2. if exists p: pts(pointer) contains Place(p) and pts(pointee) contains Alloc(p) then possibly alias
902 if pointer_pts.iter().any(|n1| {
903 let p = match n1 {
904 ConstraintNode::Place(p) => *p,
905 _ => return false,
906 };
907 pointee_pts
908 .iter()
909 .any(|n2| matches!(n2, ConstraintNode::Alloc(p2) if *p2 == p))
910 }) {
911 Some(ApproximateAliasKind::Possibly)
912 } else {
913 Some(ApproximateAliasKind::Unlikely)
914 }
915 }
916
917 /// Check alias of p1 and p2 if they are from different fn.
918 /// To avoid interproc analysis, we use heuristic assumption:

Callers 1

interproc_aliasMethod · 0.80

Calls 1

get_or_insert_ptsMethod · 0.80

Tested by

no test coverage detected