rapx/check/safedrop/
observer.rs1use rustc_span::Span;
2
3use crate::analysis::alias::default::graph::AliasGraph;
4use crate::analysis::alias::observer::AliasObserver;
5
6use super::bug_records::*;
7use super::checks;
8use super::drop::DropRecord;
9
10pub struct SafeDropObserver<'a> {
11 pub drop_record: &'a mut Vec<DropRecord>,
12 pub bug_records: &'a mut BugRecords,
13 pub current_bb: usize,
14}
15
16impl AliasObserver for SafeDropObserver<'_> {
17 fn on_value_use(&mut self, graph: &AliasGraph, vidx: usize, span: Span, in_call: bool) {
18 checks::sync_drop_record(graph, self.drop_record);
19 checks::uaf_check(graph, self.drop_record, self.bug_records, vidx, self.current_bb, span, in_call);
20 }
21
22 fn on_value_assign(&mut self, graph: &AliasGraph, vidx: usize) {
23 checks::sync_drop_record(graph, self.drop_record);
24 checks::clear_drop_info(graph, self.drop_record, vidx);
25 }
26
27 fn on_state_change(&mut self, graph: &AliasGraph) {
28 checks::sync_drop_record(graph, self.drop_record);
29 }
30}