clang 19.0.0git
Classes | Public Types | Public Member Functions | List of all members
clang::dataflow::DataflowAnalysis< Derived, LatticeT > Class Template Reference

Base class template for dataflow analyses built on a single lattice type. More...

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

Inheritance diagram for clang::dataflow::DataflowAnalysis< Derived, LatticeT >:
Inheritance graph
[legend]

Public Types

using Lattice = LatticeT
 Bounded join-semilattice that is used in the analysis.
 

Public Member Functions

 DataflowAnalysis (ASTContext &Context)
 
 DataflowAnalysis (ASTContext &Context, DataflowAnalysisOptions Options)
 
ASTContextgetASTContext () final
 Returns the ASTContext that is used by the analysis.
 
TypeErasedLattice typeErasedInitialElement () final
 Returns a type-erased lattice element that models the initial state of a basic block.
 
TypeErasedLattice joinTypeErased (const TypeErasedLattice &E1, const TypeErasedLattice &E2) final
 Joins two type-erased lattice elements by computing their least upper bound.
 
LatticeJoinEffect widenTypeErased (TypeErasedLattice &Current, const TypeErasedLattice &Previous) final
 Chooses a lattice element that approximates the current element at a program point, given the previous element at that point.
 
bool isEqualTypeErased (const TypeErasedLattice &E1, const TypeErasedLattice &E2) final
 Returns true if and only if the two given type-erased lattice elements are equal.
 
void transferTypeErased (const CFGElement &Element, TypeErasedLattice &E, Environment &Env) final
 Applies the analysis transfer function for a given control flow graph element and type-erased lattice element.
 
void transferBranchTypeErased (bool Branch, const Stmt *Stmt, TypeErasedLattice &E, Environment &Env) final
 Applies the analysis transfer function for a given edge from a CFG block of a conditional statement.
 
- Public Member Functions inherited from clang::dataflow::TypeErasedDataflowAnalysis
 TypeErasedDataflowAnalysis ()
 
 TypeErasedDataflowAnalysis (DataflowAnalysisOptions Options)
 
virtual ~TypeErasedDataflowAnalysis ()
 
virtual ASTContextgetASTContext ()=0
 Returns the ASTContext that is used by the analysis.
 
virtual TypeErasedLattice typeErasedInitialElement ()=0
 Returns a type-erased lattice element that models the initial state of a basic block.
 
virtual TypeErasedLattice joinTypeErased (const TypeErasedLattice &, const TypeErasedLattice &)=0
 Joins two type-erased lattice elements by computing their least upper bound.
 
virtual LatticeJoinEffect widenTypeErased (TypeErasedLattice &Current, const TypeErasedLattice &Previous)=0
 Chooses a lattice element that approximates the current element at a program point, given the previous element at that point.
 
virtual bool isEqualTypeErased (const TypeErasedLattice &, const TypeErasedLattice &)=0
 Returns true if and only if the two given type-erased lattice elements are equal.
 
virtual void transferTypeErased (const CFGElement &, TypeErasedLattice &, Environment &)=0
 Applies the analysis transfer function for a given control flow graph element and type-erased lattice element.
 
virtual void transferBranchTypeErased (bool Branch, const Stmt *, TypeErasedLattice &, Environment &)=0
 Applies the analysis transfer function for a given edge from a CFG block of a conditional statement.
 
const std::optional< DataflowAnalysisContext::Options > & builtinOptions () const
 If the built-in model is enabled, returns the options to be passed to them.
 
- Public Member Functions inherited from clang::dataflow::Environment::ValueModel
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

template<typename Derived, typename LatticeT>
class clang::dataflow::DataflowAnalysis< Derived, LatticeT >

Base class template for dataflow analyses built on a single lattice type.

Requirements:

Derived must be derived from a specialization of this class template and must provide the following public members:

Derived can optionally provide the following members:

Derived can optionally override the virtual functions in the Environment::ValueModel interface (which is an indirect base class of this class).

LatticeT is a bounded join-semilattice that is used by Derived and must provide the following public members:

LatticeT can optionally provide the following members:

Definition at line 80 of file DataflowAnalysis.h.

Member Typedef Documentation

◆ Lattice

template<typename Derived , typename LatticeT >
using clang::dataflow::DataflowAnalysis< Derived, LatticeT >::Lattice = LatticeT

Bounded join-semilattice that is used in the analysis.

Definition at line 83 of file DataflowAnalysis.h.

Constructor & Destructor Documentation

◆ DataflowAnalysis() [1/2]

template<typename Derived , typename LatticeT >
clang::dataflow::DataflowAnalysis< Derived, LatticeT >::DataflowAnalysis ( ASTContext Context)
inlineexplicit

Definition at line 85 of file DataflowAnalysis.h.

◆ DataflowAnalysis() [2/2]

template<typename Derived , typename LatticeT >
clang::dataflow::DataflowAnalysis< Derived, LatticeT >::DataflowAnalysis ( ASTContext Context,
DataflowAnalysisOptions  Options 
)
inlineexplicit

Definition at line 87 of file DataflowAnalysis.h.

Member Function Documentation

◆ getASTContext()

template<typename Derived , typename LatticeT >
ASTContext & clang::dataflow::DataflowAnalysis< Derived, LatticeT >::getASTContext ( )
inlinefinalvirtual

Returns the ASTContext that is used by the analysis.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 91 of file DataflowAnalysis.h.

◆ isEqualTypeErased()

template<typename Derived , typename LatticeT >
bool clang::dataflow::DataflowAnalysis< Derived, LatticeT >::isEqualTypeErased ( const TypeErasedLattice ,
const TypeErasedLattice  
)
inlinefinalvirtual

Returns true if and only if the two given type-erased lattice elements are equal.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 113 of file DataflowAnalysis.h.

◆ joinTypeErased()

template<typename Derived , typename LatticeT >
TypeErasedLattice clang::dataflow::DataflowAnalysis< Derived, LatticeT >::joinTypeErased ( const TypeErasedLattice ,
const TypeErasedLattice  
)
inlinefinalvirtual

Joins two type-erased lattice elements by computing their least upper bound.

Places the join result in the left element and returns an effect indicating whether any changes were made to it.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 97 of file DataflowAnalysis.h.

◆ transferBranchTypeErased()

template<typename Derived , typename LatticeT >
void clang::dataflow::DataflowAnalysis< Derived, LatticeT >::transferBranchTypeErased ( bool  Branch,
const Stmt ,
TypeErasedLattice ,
Environment  
)
inlinefinalvirtual

Applies the analysis transfer function for a given edge from a CFG block of a conditional statement.

Parameters
StmtThe condition which is responsible for the split in the CFG.
BranchTrue if the edge goes to the basic block where the condition is true.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 126 of file DataflowAnalysis.h.

References Env.

◆ transferTypeErased()

template<typename Derived , typename LatticeT >
void clang::dataflow::DataflowAnalysis< Derived, LatticeT >::transferTypeErased ( const CFGElement ,
TypeErasedLattice ,
Environment  
)
inlinefinalvirtual

Applies the analysis transfer function for a given control flow graph element and type-erased lattice element.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 120 of file DataflowAnalysis.h.

References Env, and clang::dataflow::transfer().

◆ typeErasedInitialElement()

template<typename Derived , typename LatticeT >
TypeErasedLattice clang::dataflow::DataflowAnalysis< Derived, LatticeT >::typeErasedInitialElement ( )
inlinefinalvirtual

Returns a type-erased lattice element that models the initial state of a basic block.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 93 of file DataflowAnalysis.h.

◆ widenTypeErased()

template<typename Derived , typename LatticeT >
LatticeJoinEffect clang::dataflow::DataflowAnalysis< Derived, LatticeT >::widenTypeErased ( TypeErasedLattice Current,
const TypeErasedLattice Previous 
)
inlinefinalvirtual

Chooses a lattice element that approximates the current element at a program point, given the previous element at that point.

Places the widened result in the current element (Current). Widening is optional – it is only needed to either accelerate convergence (for lattices with non-trivial height) or guarantee convergence (for lattices with infinite height).

Returns an indication of whether any changes were made to Current in order to widen. This saves a separate call to isEqualTypeErased after the widening.

Implements clang::dataflow::TypeErasedDataflowAnalysis.

Definition at line 106 of file DataflowAnalysis.h.

References clang::C, P, and Previous.


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