flowistry_pdg_construction::construct

Struct MemoPdgConstructor

Source
pub struct MemoPdgConstructor<'tcx> {
    pub(crate) tcx: TyCtxt<'tcx>,
    pub(crate) call_change_callback: Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>,
    pub(crate) dump_mir: bool,
    pub(crate) async_info: Rc<AsyncInfo>,
    pub pdg_cache: Rc<Cache<Instance<'tcx>, PartialGraph<'tcx>>>,
    pub(crate) body_cache: Rc<BodyCache<'tcx>>,
}
Expand description

A memoizing constructor of PDGs.

Each (LocalDefId, GenericArgs) pair is guaranteed to be constructed only once.

Fields§

§tcx: TyCtxt<'tcx>§call_change_callback: Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>§dump_mir: bool§async_info: Rc<AsyncInfo>§pdg_cache: Rc<Cache<Instance<'tcx>, PartialGraph<'tcx>>>§body_cache: Rc<BodyCache<'tcx>>

Implementations§

Source§

impl<'tcx> MemoPdgConstructor<'tcx>

Source

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

Initialize the constructor.

Source

pub fn new_with_cache( tcx: TyCtxt<'tcx>, body_cache: Rc<BodyCache<'tcx>>, ) -> Self

Initialize the constructor.

Source

pub fn with_dump_mir(&mut self, dump_mir: bool) -> &mut Self

Dump the MIR of any function that is visited.

Source

pub fn with_call_change_callback( &mut self, callback: impl CallChangeCallback<'tcx> + 'tcx, ) -> &mut Self

Register a callback to determine how to deal with function calls seen. Overwrites any previously registered callback with no warning.

Source

pub fn construct_root<'a>( &'a self, function: LocalDefId, ) -> &'a PartialGraph<'tcx>

Construct the intermediate PDG for this function. Instantiates any generic arguments as dyn <constraints>.

Source

pub(crate) fn construct_for<'a>( &'a self, resolution: Instance<'tcx>, ) -> Option<&'a PartialGraph<'tcx>>

Construct a graph for this instance of return it from the cache.

Returns None if this is a recursive call trying to construct the graph again.

Source

pub fn is_in_cache(&self, resolution: Instance<'tcx>) -> bool

Has a PDG been constructed for this instance before?

Source

pub fn construct_graph(&self, function: LocalDefId) -> DepGraph<'tcx>

Construct a final PDG for this function. Same as Self::construct_root this instantiates all generics as dyn.

Additionally if this is an async fn or #[async_trait] it will inline the closure as though the function were called with poll.

Source

pub fn body_for_def_id(&self, key: DefId) -> &'tcx CachedBody<'tcx>

Try to retrieve or load a body for this id.

Returns None if the loading policy forbids loading from this crate.

Source

pub fn body_cache(&self) -> &Rc<BodyCache<'tcx>>

Access to the underlying body cache.

Source

pub fn take_call_changes_policy( &mut self, ) -> Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>

Used for testing.

Auto Trait Implementations§

§

impl<'tcx> Freeze for MemoPdgConstructor<'tcx>

§

impl<'tcx> !RefUnwindSafe for MemoPdgConstructor<'tcx>

§

impl<'tcx> !Send for MemoPdgConstructor<'tcx>

§

impl<'tcx> !Sync for MemoPdgConstructor<'tcx>

§

impl<'tcx> Unpin for MemoPdgConstructor<'tcx>

§

impl<'tcx> !UnwindSafe for MemoPdgConstructor<'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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T> Captures<'_> for T
where T: ?Sized,