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: usizeCurrent 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
impl RaiiTracker
pub fn new() -> Self
Sourcepub fn is_container_type(type_name: &str) -> bool
pub fn is_container_type(type_name: &str) -> bool
Check if a type is a container type
Sourcepub fn is_iterator_type(type_name: &str) -> bool
pub fn is_iterator_type(type_name: &str) -> bool
Check if a type is an iterator type
Sourcepub fn is_container_store_method(method_name: &str) -> bool
pub fn is_container_store_method(method_name: &str) -> bool
Check if a function is a container method that stores a reference
Sourcepub fn is_iterator_returning_method(method_name: &str) -> bool
pub fn is_iterator_returning_method(method_name: &str) -> bool
Check if a function returns an iterator
Sourcepub fn register_variable(&mut self, name: &str, type_name: &str, scope: usize)
pub fn register_variable(&mut self, name: &str, type_name: &str, scope: usize)
Register a variable with its scope and type
Sourcepub fn record_container_store(
&mut self,
container: &str,
pointee: &str,
line: usize,
)
pub fn record_container_store( &mut self, container: &str, pointee: &str, line: usize, )
Record that a pointer/reference was stored in a container
Sourcepub fn record_iterator_creation(
&mut self,
iterator: &str,
container: &str,
line: usize,
)
pub fn record_iterator_creation( &mut self, iterator: &str, container: &str, line: usize, )
Record that an iterator was created from a container
Sourcepub fn record_lambda(
&mut self,
lambda_var: &str,
ref_captures: Vec<String>,
line: usize,
)
pub fn record_lambda( &mut self, lambda_var: &str, ref_captures: Vec<String>, line: usize, )
Record a lambda with reference captures
Sourcepub fn mark_lambda_escaped(&mut self, lambda_var: &str)
pub fn mark_lambda_escaped(&mut self, lambda_var: &str)
Mark a lambda as escaped (returned or stored in longer-lived variable)
Sourcepub fn record_member_borrow(
&mut self,
reference: &str,
object: &str,
field: &str,
line: usize,
)
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
Sourcepub fn record_allocation(&mut self, var: &str, line: usize)
pub fn record_allocation(&mut self, var: &str, line: usize)
Record a new allocation
Sourcepub fn record_deallocation(&mut self, var: &str, line: usize) -> Option<String>
pub fn record_deallocation(&mut self, var: &str, line: usize) -> Option<String>
Record a delete operation
Sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Enter a new scope
Sourcepub fn exit_scope(&mut self) -> Vec<String>
pub fn exit_scope(&mut self) -> Vec<String>
Exit a scope and check for dangling references