CallGraph

Struct CallGraph 

Source
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

Source

pub fn new(tcx: TyCtxt<'tcx>) -> Self

Source

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.

Source

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

Source

pub fn get_reverse_post_order(&self) -> Vec<DefId>

Source

pub fn get_post_order(&self) -> Vec<DefId>

Source

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.

Source

pub fn get_callers_map(&self) -> CallMap<'tcx>

Get a reversed (callee -> Vec) call map.

Source

pub fn get_callees(&self, caller_def_id: DefId) -> Vec<DefId>

Get all direct callees’ DefId of the caller function

Source

pub fn get_callees_recursive(&self, caller_def_id: DefId) -> Vec<DefId>

Get all recursively reachable callee’s DefId

Source

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> 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V