pub struct State<V>(StateData<V>);
Expand description

The dataflow state for an instance of ValueAnalysis.

Every instance specifies a lattice that represents the possible values of a single tracked place. If we call this lattice V and set of tracked places P, then a State is an element of {unreachable} ∪ (P -> V). This again forms a lattice, where the bottom element is unreachable and the top element is the mapping p ↦ ⊤. Note that the mapping p ↦ ⊥ is not the bottom element (because joining an unreachable and any other reachable state yields a reachable state). All operations on unreachable states are ignored.

Flooding means assigning a value (by default ) to all tracked projections of a given place.

Tuple Fields§

§0: StateData<V>

Implementations§

source§

impl<V: Clone> State<V>

source

pub fn new(init: V, map: &Map) -> State<V>

source

pub fn all(&self, f: impl Fn(&V) -> bool) -> bool

source

fn is_reachable(&self) -> bool

source

pub fn flood_with(&mut self, place: PlaceRef<'_>, map: &Map, value: V)

Assign value to all places that are contained in place or may alias one.

source

pub fn flood(&mut self, place: PlaceRef<'_>, map: &Map)
where V: HasTop,

Assign TOP to all places that are contained in place or may alias one.

source

fn flood_discr_with(&mut self, place: PlaceRef<'_>, map: &Map, value: V)

Assign value to the discriminant of place and all places that may alias it.

source

pub fn flood_discr(&mut self, place: PlaceRef<'_>, map: &Map)
where V: HasTop,

Assign TOP to the discriminant of place and all places that may alias it.

source

pub fn flood_with_tail_elem( &mut self, place: PlaceRef<'_>, tail_elem: Option<TrackElem>, map: &Map, value: V )

This method is the most general version of the flood_* method.

Assign value on the given place and all places that may alias it. In particular, when the given place has a variant downcast, we invoke the function on all the other variants.

tail_elem allows to support discriminants that are not a place in MIR, but that we track as such.

source

fn insert_idx(&mut self, target: PlaceIndex, result: ValueOrPlace<V>, map: &Map)

Low-level method that assigns to a place. This does nothing if the place is not tracked.

The target place must have been flooded before calling this method.

source

pub fn insert_value_idx(&mut self, target: PlaceIndex, value: V, map: &Map)

Low-level method that assigns a value to a place. This does nothing if the place is not tracked.

The target place must have been flooded before calling this method.

source

pub fn insert_place_idx( &mut self, target: PlaceIndex, source: PlaceIndex, map: &Map )

Copies source to target, including all tracked places beneath.

If target contains a place that is not contained in source, it will be overwritten with Top. Also, because this will copy all entries one after another, it may only be used for places that are non-overlapping or identical.

The target place must have been flooded before calling this method.

source

pub fn assign( &mut self, target: PlaceRef<'_>, result: ValueOrPlace<V>, map: &Map )
where V: HasTop,

Helper method to interpret target = result.

source

pub fn assign_discr( &mut self, target: PlaceRef<'_>, result: ValueOrPlace<V>, map: &Map )
where V: HasTop,

Helper method for assignments to a discriminant.

source

pub fn try_get(&self, place: PlaceRef<'_>, map: &Map) -> Option<V>

Retrieve the value stored for a place, or None if it is not tracked.

source

pub fn try_get_discr(&self, place: PlaceRef<'_>, map: &Map) -> Option<V>

Retrieve the discriminant stored for a place, or None if it is not tracked.

source

pub fn try_get_len(&self, place: PlaceRef<'_>, map: &Map) -> Option<V>

Retrieve the slice length stored for a place, or None if it is not tracked.

source

pub fn try_get_idx(&self, place: PlaceIndex, map: &Map) -> Option<V>

Retrieve the value stored for a place index, or None if it is not tracked.

source

pub fn get(&self, place: PlaceRef<'_>, map: &Map) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ if the place is tracked and the state is unreachable.

source

pub fn get_discr(&self, place: PlaceRef<'_>, map: &Map) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

source

pub fn get_len(&self, place: PlaceRef<'_>, map: &Map) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

source

pub fn get_idx(&self, place: PlaceIndex, map: &Map) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place index, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

Trait Implementations§

source§

impl<V: Clone> Clone for State<V>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug> Debug for State<V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx, T> DebugWithContext<ValueAnalysisWrapper<T>> for State<T::Value>
where T: ValueAnalysis<'tcx>, T::Value: Debug,

This is used to visualize the dataflow analysis.

source§

fn fmt_with( &self, ctxt: &ValueAnalysisWrapper<T>, f: &mut Formatter<'_> ) -> Result

source§

fn fmt_diff_with( &self, old: &Self, ctxt: &ValueAnalysisWrapper<T>, f: &mut Formatter<'_> ) -> Result

Print the difference between self and old. Read more
source§

impl<V: JoinSemiLattice + Clone> JoinSemiLattice for State<V>

source§

fn join(&mut self, other: &Self) -> bool

Computes the least upper bound of two elements, storing the result in self and returning true if self has changed. Read more
source§

impl<V: PartialEq> PartialEq for State<V>

source§

fn eq(&self, other: &State<V>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<V: Eq> Eq for State<V>

source§

impl<V> StructuralEq for State<V>

source§

impl<V> StructuralPartialEq for State<V>

Auto Trait Implementations§

§

impl<V> RefUnwindSafe for State<V>
where V: RefUnwindSafe,

§

impl<V> Send for State<V>
where V: Send,

§

impl<V> Sync for State<V>
where V: Sync,

§

impl<V> Unpin for State<V>
where V: Unpin,

§

impl<V> UnwindSafe for State<V>
where V: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes