pub struct CallGraph<'tcx> {
pub tcx: TyCtxt<'tcx>,
pub functions: HashSet<DefId>,
pub fn_calls: CallMap<'tcx>,
}Fields§
§tcx: TyCtxt<'tcx>§functions: HashSet<DefId>§fn_calls: CallMap<'tcx>Implementations§
Source§impl<'tcx> CallGraph<'tcx>
Internal apis for constructing a call graph
impl<'tcx> CallGraph<'tcx>
Internal apis for constructing a call graph
pub fn new(tcx: TyCtxt<'tcx>) -> Self
Sourcepub fn register_fn(&mut self, def_id: DefId) -> bool
pub fn register_fn(&mut self, def_id: DefId) -> bool
Register a function to the call graph. Return true on insert, false if that DefId already exists.
Sourcepub fn add_funciton_call(
&mut self,
caller_id: DefId,
callee_id: DefId,
terminator_stmt: Option<&'tcx Terminator<'tcx>>,
)
pub fn add_funciton_call( &mut self, caller_id: DefId, callee_id: DefId, terminator_stmt: Option<&'tcx Terminator<'tcx>>, )
Add a function call to the call graph.
Source§impl<'tcx> CallGraph<'tcx>
Public apis to get information from the call graph
impl<'tcx> CallGraph<'tcx>
Public apis to get information from the call graph
pub fn get_reverse_post_order(&self) -> Vec<DefId>
pub fn get_post_order(&self) -> Vec<DefId>
Sourcefn dfs_post_order(
&self,
func_def_id: DefId,
visited: &mut HashSet<DefId>,
post_order_ids: &mut Vec<DefId>,
)
fn dfs_post_order( &self, func_def_id: DefId, visited: &mut HashSet<DefId>, post_order_ids: &mut Vec<DefId>, )
Helper function to perform a recursive depth-first search.
Sourcepub fn get_callers_map(&self) -> CallMap<'tcx>
pub fn get_callers_map(&self) -> CallMap<'tcx>
Get a reversed (callee -> Vec
Sourcepub fn get_callees(&self, caller_def_id: DefId) -> Vec<DefId>
pub fn get_callees(&self, caller_def_id: DefId) -> Vec<DefId>
Get all direct callees’ DefId of the caller function
Sourcepub fn get_callees_recursive(&self, caller_def_id: DefId) -> Vec<DefId>
pub fn get_callees_recursive(&self, caller_def_id: DefId) -> Vec<DefId>
Get all recursively reachable callee’s DefId
Sourcepub fn get_callers(&self, callee_def_id: DefId) -> Vec<DefId>
pub fn get_callers(&self, callee_def_id: DefId) -> Vec<DefId>
Get all direct callers’ DefId of the callee function
Auto Trait Implementations§
impl<'tcx> Freeze for CallGraph<'tcx>
impl<'tcx> !RefUnwindSafe for CallGraph<'tcx>
impl<'tcx> !Send for CallGraph<'tcx>
impl<'tcx> !Sync for CallGraph<'tcx>
impl<'tcx> Unpin for CallGraph<'tcx>
impl<'tcx> !UnwindSafe for CallGraph<'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more