pub struct AnalysisContext<'tcx, 'compilation> {
Show 17 fields pub tcx: TyCtxt<'tcx>, pub session: &'compilation Session, pub entry_point: DefId, pub analysis_options: AnalysisOptions, pub functions: IndexVec<FuncId, Rc<FunctionReference<'tcx>>>, pub func_id_map: HashMap<Rc<FunctionReference<'tcx>>, FuncId>, pub func_name_cache: HashMap<FuncId, Box<str>>, pub type_cache: TypeCache<'tcx>, pub path_ty_cache: HashMap<Rc<Path>, Ty<'tcx>>, pub path_memory_size: HashMap<Rc<Path>, usize>, pub path_cast_cache: PathCastCache<'tcx>, pub ptr_projs_cache: PointerProjectionsCache<'tcx>, pub field_byte_offset_cache: FieldByteOffsetCache<'tcx>, pub dyn_callsite_cache: HashMap<BaseCallSite, CalleeIdentifier<'tcx>>, pub special_functions: HashSet<FuncId>, pub concretized_heap_objs: HashMap<Rc<Path>, Ty<'tcx>>, pub known_names_cache: KnownNamesCache, /* private fields */
}
Expand description

Global information of the analysis

Fields§

§tcx: TyCtxt<'tcx>

The central data structure of the compiler.

§session: &'compilation Session

Represents the data associated with a compilation session for a single crate.

§entry_point: DefId

The entry function of the analysis.

§analysis_options: AnalysisOptions

Options of the analysis.

§functions: IndexVec<FuncId, Rc<FunctionReference<'tcx>>>§func_id_map: HashMap<Rc<FunctionReference<'tcx>>, FuncId>§func_name_cache: HashMap<FuncId, Box<str>>§type_cache: TypeCache<'tcx>

Provides a way to refer to a rustc_middle::ty::Ty via a handle that does not have a life time specifier.

§path_ty_cache: HashMap<Rc<Path>, Ty<'tcx>>

Record the original type for each object.

§path_memory_size: HashMap<Rc<Path>, usize>

Record the memory size for each stack and heap object.

§path_cast_cache: PathCastCache<'tcx>

Manage the cast types for each object.

§ptr_projs_cache: PointerProjectionsCache<'tcx>

Cache all the pointer type fields’ projections for each type.

§field_byte_offset_cache: FieldByteOffsetCache<'tcx>

Cache the byte offset for each field of type.

§dyn_callsite_cache: HashMap<BaseCallSite, CalleeIdentifier<'tcx>>§special_functions: HashSet<FuncId>

Functions specially handled in special_function_handler.

§concretized_heap_objs: HashMap<Rc<Path>, Ty<'tcx>>

Heap objects that have been cast to a concretized type.

§known_names_cache: KnownNamesCache

Implementations§

source§

impl<'tcx, 'compilation> AnalysisContext<'tcx, 'compilation>

source

pub fn new( session: &'compilation Session, tcx: TyCtxt<'tcx>, analysis_options: AnalysisOptions ) -> Option<Self>

source

pub fn set_path_rustc_type(&mut self, path: Rc<Path>, ty: Ty<'tcx>)

Records the type of path.

source

pub fn get_path_rustc_type(&self, path: &Rc<Path>) -> Option<Ty<'tcx>>

source

pub fn set_path_memory_size(&mut self, path: Rc<Path>, ty: Ty<'tcx>)

Records the size of `path``.

source

pub fn get_path_memory_size(&self, path: &Rc<Path>) -> Option<usize>

source

pub fn get_type_index(&mut self, ty: &Ty<'tcx>) -> usize

source

pub fn get_type_by_index(&self, index: usize) -> Option<Ty<'tcx>>

source

pub fn cast_to(&mut self, path: &Rc<Path>, ty: Ty<'tcx>) -> Option<Rc<Path>>

Creates a path cast from the given path.

source

pub fn get_type_variant( &mut self, path: &Rc<Path>, ty: Ty<'tcx> ) -> Option<Rc<Path>>

Returns the type variant of the given path, returns None if the path has not been cast to ty.

source

pub fn get_regularized_path(&mut self, path: Rc<Path>) -> Rc<Path>

Different paths may refer to the same memory location, we can regularize these path to a base path e.g. a.0.0, a.0, a.cast#T' and a will all be represented by one path.

source

pub fn get_cast_types(&self, path: &Rc<Path>) -> Option<&HashSet<Ty<'tcx>>>

Returns the types that a path have been cast to.

source

pub fn get_pointer_projections( &mut self, ty: Ty<'tcx> ) -> &Vec<(ProjectionElems, Ty<'tcx>)>

Get the pointer type fields’ projections.

source

pub fn get_field_byte_offset( &mut self, base_ty: Ty<'tcx>, proj: &ProjectionElems ) -> usize

Get the byte offset of a specific field.

source

pub fn get_or_add_function_reference( &mut self, func_ref: Rc<FunctionReference<'tcx>> ) -> FuncId

source

pub fn get_function_reference( &self, func_id: FuncId ) -> Rc<FunctionReference<'tcx>>

source

pub fn get_func_id( &mut self, def_id: DefId, gen_args: GenericArgsRef<'tcx> ) -> FuncId

source

pub fn get_promoted_id( &mut self, def_id: DefId, gen_args: Vec<GenericArgE<'tcx>>, promoted: Promoted ) -> FuncId

source

pub fn add_dyn_callsite( &mut self, callsite: BaseCallSite, callee_id: DefId, gen_args: GenericArgsRef<'tcx> )

source

pub fn get_dyn_callee_identifier( &self, callsite: &BaseCallSite ) -> Option<&CalleeIdentifier<'tcx>>

source

pub fn add_special_function(&mut self, func_id: FuncId)

source

pub fn is_std_ops_fntrait_call(&mut self, def_id: DefId) -> bool

source

pub fn def_in_ops_func_namespace(&mut self, def_id: DefId) -> bool

source

pub fn get_known_name_for(&mut self, def_id: DefId) -> KnownNames

source

pub fn create_aux_local(&mut self, func_id: FuncId, ty: Ty<'tcx>) -> Rc<Path>

Creates an auxiliary local variable with the given type for the given func_id. Returns the path of the auxiliary local variable.

Auxiliary local variables are introduced for breaking donw complex statements into simple assignments.

Auto Trait Implementations§

§

impl<'tcx, 'compilation> !RefUnwindSafe for AnalysisContext<'tcx, 'compilation>

§

impl<'tcx, 'compilation> !Send for AnalysisContext<'tcx, 'compilation>

§

impl<'tcx, 'compilation> !Sync for AnalysisContext<'tcx, 'compilation>

§

impl<'tcx, 'compilation> Unpin for AnalysisContext<'tcx, 'compilation>

§

impl<'tcx, 'compilation> !UnwindSafe for AnalysisContext<'tcx, 'compilation>

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

§

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.