RaiiTracker

Struct RaiiTracker 

Source
pub struct RaiiTracker {
    pub container_borrows: Vec<ContainerBorrow>,
    pub iterator_borrows: Vec<IteratorBorrow>,
    pub lambda_captures: Vec<LambdaCapture>,
    pub member_borrows: Vec<MemberBorrow>,
    pub heap_allocations: HashMap<String, HeapAllocation>,
    pub user_defined_raii_types: HashSet<String>,
    pub current_scope: usize,
    pub variable_scopes: HashMap<String, usize>,
    pub container_variables: HashSet<String>,
    pub iterator_variables: HashSet<String>,
}
Expand description

Main RAII tracker that coordinates all RAII-related tracking

Fields§

§container_borrows: Vec<ContainerBorrow>

Container borrows: pointers/refs stored in containers

§iterator_borrows: Vec<IteratorBorrow>

Iterator borrows from containers

§lambda_captures: Vec<LambdaCapture>

Lambda captures with escape tracking

§member_borrows: Vec<MemberBorrow>

Member borrows: references to object fields (Phase 5)

§heap_allocations: HashMap<String, HeapAllocation>

Heap allocations for new/delete tracking

§user_defined_raii_types: HashSet<String>

User-defined RAII types detected in this file

§current_scope: usize

Current scope level

§variable_scopes: HashMap<String, usize>

Variable scope levels

§container_variables: HashSet<String>

Variables that are containers (vector, map, etc.)

§iterator_variables: HashSet<String>

Variables that are iterators

Implementations§

Source§

impl RaiiTracker

Source

pub fn new() -> Self

Source

pub fn is_container_type(type_name: &str) -> bool

Check if a type is a container type

Source

pub fn is_iterator_type(type_name: &str) -> bool

Check if a type is an iterator type

Source

pub fn is_container_store_method(method_name: &str) -> bool

Check if a function is a container method that stores a reference

Source

pub fn is_iterator_returning_method(method_name: &str) -> bool

Check if a function returns an iterator

Source

pub fn register_variable(&mut self, name: &str, type_name: &str, scope: usize)

Register a variable with its scope and type

Source

pub fn record_container_store( &mut self, container: &str, pointee: &str, line: usize, )

Record that a pointer/reference was stored in a container

Source

pub fn record_iterator_creation( &mut self, iterator: &str, container: &str, line: usize, )

Record that an iterator was created from a container

Source

pub fn record_lambda( &mut self, lambda_var: &str, ref_captures: Vec<String>, line: usize, )

Record a lambda with reference captures

Source

pub fn mark_lambda_escaped(&mut self, lambda_var: &str)

Mark a lambda as escaped (returned or stored in longer-lived variable)

Source

pub fn record_member_borrow( &mut self, reference: &str, object: &str, field: &str, line: usize, )

Record a reference to an object’s member field (Phase 5) When ptr = &obj.field, the reference ptr borrows from obj

Source

pub fn record_allocation(&mut self, var: &str, line: usize)

Record a new allocation

Source

pub fn record_deallocation(&mut self, var: &str, line: usize) -> Option<String>

Record a delete operation

Source

pub fn is_freed(&self, var: &str) -> bool

Check if a variable has been freed

Source

pub fn enter_scope(&mut self)

Enter a new scope

Source

pub fn exit_scope(&mut self) -> Vec<String>

Exit a scope and check for dangling references

Trait Implementations§

Source§

impl Debug for RaiiTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.