clang 17.0.0git
Public Member Functions | List of all members
clang::dataflow::Environment::ValueModel Class Reference

Supplements Environment with non-standard comparison and join operations. More...

#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"

Inheritance diagram for clang::dataflow::Environment::ValueModel:
Inheritance graph
[legend]

Public Member Functions

virtual ~ValueModel ()=default
 
virtual ComparisonResult compare (QualType Type, const Value &Val1, const Environment &Env1, const Value &Val2, const Environment &Env2)
 Returns: Same: Val1 is equivalent to Val2, according to the model.
 
virtual bool merge (QualType Type, const Value &Val1, const Environment &Env1, const Value &Val2, const Environment &Env2, Value &MergedVal, Environment &MergedEnv)
 Modifies MergedVal to approximate both Val1 and Val2.
 
virtual Valuewiden (QualType Type, Value &Prev, const Environment &PrevEnv, Value &Current, Environment &CurrentEnv)
 This function may widen the current value – replace it with an approximation that can reach a fixed point more quickly than iterated application of the transfer function alone.
 

Detailed Description

Supplements Environment with non-standard comparison and join operations.

Definition at line 70 of file DataflowEnvironment.h.

Constructor & Destructor Documentation

◆ ~ValueModel()

virtual clang::dataflow::Environment::ValueModel::~ValueModel ( )
virtualdefault

Member Function Documentation

◆ compare()

virtual ComparisonResult clang::dataflow::Environment::ValueModel::compare ( QualType  Type,
const Value Val1,
const Environment Env1,
const Value Val2,
const Environment Env2 
)
inlinevirtual

Returns: Same: Val1 is equivalent to Val2, according to the model.

Different: Val1 is distinct from Val2, according to the model. Unknown: The model can't determine a relationship between Val1 and Val2.

Requirements:

Val1 and Val2 must be distinct.

Val1 and Val2 must model values of type Type.

Val1 and Val2 must be assigned to the same storage location in Env1 and Env2 respectively.

Reimplemented in clang::dataflow::UncheckedOptionalAccessModel.

Definition at line 88 of file DataflowEnvironment.h.

References clang::dataflow::Unknown.

Referenced by clang::dataflow::compareDistinctValues(), and widen().

◆ merge()

virtual bool clang::dataflow::Environment::ValueModel::merge ( QualType  Type,
const Value Val1,
const Environment Env1,
const Value Val2,
const Environment Env2,
Value MergedVal,
Environment MergedEnv 
)
inlinevirtual

Modifies MergedVal to approximate both Val1 and Val2.

This could be a strict lattice join or a more general widening operation.

If this function returns true, MergedVal will be assigned to a storage location of type Type in MergedEnv.

Env1 and Env2 can be used to query child values and path condition implications of Val1 and Val2 respectively.

Requirements:

Val1 and Val2 must be distinct.

Val1, Val2, and MergedVal must model values of type Type.

Val1 and Val2 must be assigned to the same storage location in Env1 and Env2 respectively.

Reimplemented in clang::dataflow::UncheckedOptionalAccessModel.

Definition at line 113 of file DataflowEnvironment.h.

Referenced by clang::dataflow::mergeDistinctValues().

◆ widen()

virtual Value * clang::dataflow::Environment::ValueModel::widen ( QualType  Type,
Value Prev,
const Environment PrevEnv,
Value Current,
Environment CurrentEnv 
)
inlinevirtual

This function may widen the current value – replace it with an approximation that can reach a fixed point more quickly than iterated application of the transfer function alone.

The previous value is provided to inform the choice of widened value. The function must also serve as a comparison operation, by indicating whether the widened value is equivalent to the previous value.

Returns either:

nullptr, if this value is not of interest to the model, or

&Prev, if the widened value is equivalent to Prev, or

A non-null value that approximates Current. Prev is available to inform the chosen approximation.

PrevEnv and CurrentEnv can be used to query child values and path condition implications of Prev and Current, respectively.

Requirements:

Prev and Current must model values of type Type.

Prev and Current must be assigned to the same storage location in PrevEnv and CurrentEnv, respectively.

Reimplemented in clang::dataflow::UncheckedOptionalAccessModel.

Definition at line 145 of file DataflowEnvironment.h.

References compare(), clang::dataflow::Different, clang::dataflow::Same, and clang::dataflow::Unknown.

Referenced by clang::dataflow::widenDistinctValues().


The documentation for this class was generated from the following file: