Skip to main content

FunctionSummary

Struct FunctionSummary 

Source
pub struct FunctionSummary {
Show 17 fields pub function_id: FunctionId, pub version: u64, pub return_effects: Vec<ReturnEffect>, pub memory_effects: Vec<MemoryEffect>, pub allocation_effects: Vec<AllocationEffect>, pub callees: BTreeSet<CalleeRef>, pub role: Option<SummaryRole>, pub pure: bool, pub noreturn: bool, pub param_nullness: BTreeMap<u32, SummaryNullness>, pub return_nullness: Option<SummaryNullness>, pub taint_propagation: Vec<SummaryTaintPropagation>, pub return_bound: Option<SummaryComputedBound>, pub param_freed: BTreeMap<u32, bool>, pub param_dereferenced: BTreeMap<u32, bool>, pub source: SummarySource, pub precision: SummaryPrecision,
}
Expand description

A compact, serializable description of a function’s pointer and memory behavior.

This is the universal exchange format for function behavior information. Summaries can originate from YAML specs, static analysis, or default conservative assumptions, and are used by incremental and compositional analyses to avoid re-analyzing unchanged functions.

Fields§

§function_id: FunctionId

The function this summary describes.

§version: u64

Monotonically increasing version for cache invalidation.

§return_effects: Vec<ReturnEffect>

Effects on the return value (aliasing, fresh allocation).

§memory_effects: Vec<MemoryEffect>

Memory read/write side effects.

§allocation_effects: Vec<AllocationEffect>

Allocation effects (heap/stack objects created by this function).

§callees: BTreeSet<CalleeRef>

Known callees (direct and indirect).

§role: Option<SummaryRole>

High-level role (allocator, source, sink, etc.).

§pure: bool

Whether the function is pure (no side effects, result depends only on inputs).

§noreturn: bool

Whether the function never returns (e.g., exit, abort).

§param_nullness: BTreeMap<u32, SummaryNullness>

Per-parameter nullness classification.

§return_nullness: Option<SummaryNullness>

Return value nullness classification.

§taint_propagation: Vec<SummaryTaintPropagation>

Taint propagation rules.

§return_bound: Option<SummaryComputedBound>

Computed return value bound relative to a parameter property.

§param_freed: BTreeMap<u32, bool>

Per-parameter: whether the callee frees this parameter.

§param_dereferenced: BTreeMap<u32, bool>

Per-parameter: whether the callee dereferences this parameter.

§source: SummarySource

How this summary was produced.

§precision: SummaryPrecision

Precision guarantee.

Implementations§

Source§

impl FunctionSummary

Source

pub fn default_for(function_id: FunctionId) -> Self

Create a new default (conservative) summary for the given function.

Source

pub fn save(&self, cache_dir: &Path) -> Result<(), Error>

Save this summary to {cache_dir}/summaries/{function_id_hex}.json.

Creates the summaries/ subdirectory if it does not exist.

§Errors

Returns an I/O error if the directory cannot be created or the file cannot be written.

Source

pub fn load( cache_dir: &Path, function_id: &FunctionId, ) -> Result<Option<Self>, Error>

Load a summary from {cache_dir}/summaries/{function_id_hex}.json.

Returns Ok(None) if the file does not exist.

§Errors

Returns an I/O error if the file exists but cannot be read or parsed.

Source

pub fn from_spec(spec: &FunctionSpec, function_id: FunctionId) -> Self

Convert a FunctionSpec into a FunctionSummary.

This conversion is lossless: every spec field maps to a corresponding summary field. The resulting summary has source = Spec and precision = Sound (specs are assumed to be authoritative).

Source

fn convert_return_spec(ret: &ReturnSpec, summary: &mut Self)

Helper: convert a ReturnSpec into summary return/allocation effects.

Source

fn convert_taint_spec(taint: &TaintSpec, summary: &mut Self)

Helper: convert a TaintSpec into summary taint propagation rules.

Source

fn taint_location_to_access_path(loc: TaintLocation) -> Option<AccessPath>

Convert a TaintLocation to an AccessPath.

Returns None for TaintLocation::Unknown.

Source

pub fn to_simple_spec(&self, name: &str) -> FunctionSpec

Convert this summary to a simple FunctionSpec (lossy).

Access paths are collapsed to parameter-level reads/modifies. Complex effects (field-sensitive access, deep dereferences) are simplified. The resulting spec preserves role, pure, noreturn, nullness, taint, and parameter-level read/write information.

Source

fn access_path_root_param(path: &AccessPath) -> Option<u32>

Extract the root parameter index from an access path, if it is rooted at a Param.

Source

fn access_path_to_taint_location(path: &AccessPath) -> Option<TaintLocation>

Convert an AccessPath to a TaintLocation (lossy).

Only Param and Return bases are representable; other paths return None.

Trait Implementations§

Source§

impl Clone for FunctionSummary

Source§

fn clone(&self) -> FunctionSummary

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FunctionSummary

Source§

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

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

impl<'de> Deserialize<'de> for FunctionSummary

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FunctionSummary

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

Source§

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

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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,