clang 20.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 void join (QualType Type, const Value &Val1, const Environment &Env1, const Value &Val2, const Environment &Env2, Value &JoinedVal, Environment &JoinedEnv)
 Modifies JoinedVal to approximate both Val1 and Val2.
 
virtual std::optional< WidenResultwiden (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 69 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.

Definition at line 87 of file DataflowEnvironment.h.

References clang::dataflow::Unknown.

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

◆ join()

virtual void clang::dataflow::Environment::ValueModel::join ( QualType  Type,
const Value Val1,
const Environment Env1,
const Value Val2,
const Environment Env2,
Value JoinedVal,
Environment JoinedEnv 
)
inlinevirtual

Modifies JoinedVal to approximate both Val1 and Val2.

This should obey the properties of a lattice join.

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 JoinedVal must model values of type Type.

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

Definition at line 109 of file DataflowEnvironment.h.

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

◆ widen()

virtual std::optional< WidenResult > 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 one of the folowing:

  • std::nullopt, if this value is not of interest to the model.
  • A WidenResult with:
    • A non-null Value * that points either to Current or a widened version of Current. This value must be consistent with the flow condition of CurrentEnv. We particularly caution against using Prev, which is rarely consistent.
    • A LatticeEffect indicating whether the value should be considered a new value (Changed) or one equivalent (if not necessarily equal) to Prev (Unchanged).

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.

Definition at line 141 of file DataflowEnvironment.h.

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

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


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