clang 17.0.0git
Classes | Public Member Functions | Friends | List of all members
clang::dataflow::DataflowAnalysisContext Class Reference

Owns objects that encompass the state of a program and stores context that is used during dataflow analysis. More...

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

Classes

struct  Options
 

Public Member Functions

 DataflowAnalysisContext (std::unique_ptr< Solver > S, Options Opts=Options{ std::nullopt, nullptr})
 Constructs a dataflow analysis context.
 
 ~DataflowAnalysisContext ()
 
StorageLocationcreateStorageLocation (QualType Type)
 Returns a new storage location appropriate for Type.
 
StorageLocationgetStableStorageLocation (const VarDecl &D)
 Returns a stable storage location for D.
 
StorageLocationgetStableStorageLocation (const Expr &E)
 Returns a stable storage location for E.
 
void setStorageLocation (const ValueDecl &D, StorageLocation &Loc)
 Assigns Loc as the storage location of D.
 
StorageLocationgetStorageLocation (const ValueDecl &D) const
 Returns the storage location assigned to D or null if D has no assigned storage location.
 
void setStorageLocation (const Expr &E, StorageLocation &Loc)
 Assigns Loc as the storage location of E.
 
StorageLocationgetStorageLocation (const Expr &E) const
 Returns the storage location assigned to E or null if E has no assigned storage location.
 
PointerValuegetOrCreateNullPointerValue (QualType PointeeType)
 Returns a pointer value that represents a null pointer.
 
void addFlowConditionConstraint (AtomicBoolValue &Token, BoolValue &Constraint)
 Adds Constraint to the flow condition identified by Token.
 
AtomicBoolValueforkFlowCondition (AtomicBoolValue &Token)
 Creates a new flow condition with the same constraints as the flow condition identified by Token and returns its token.
 
AtomicBoolValuejoinFlowConditions (AtomicBoolValue &FirstToken, AtomicBoolValue &SecondToken)
 Creates a new flow condition that represents the disjunction of the flow conditions identified by FirstToken and SecondToken, and returns its token.
 
bool flowConditionImplies (AtomicBoolValue &Token, BoolValue &Val)
 Returns true if and only if the constraints of the flow condition identified by Token imply that Val is true.
 
bool flowConditionIsTautology (AtomicBoolValue &Token)
 Returns true if and only if the constraints of the flow condition identified by Token are always true.
 
bool equivalentBoolValues (BoolValue &Val1, BoolValue &Val2)
 Returns true if Val1 is equivalent to Val2.
 
LLVM_DUMP_METHOD void dumpFlowCondition (AtomicBoolValue &Token, llvm::raw_ostream &OS=llvm::dbgs())
 
const ControlFlowContextgetControlFlowContext (const FunctionDecl *F)
 Returns the ControlFlowContext registered for F, if any.
 
const OptionsgetOptions ()
 
Arenaarena ()
 

Friends

class Environment
 

Detailed Description

Owns objects that encompass the state of a program and stores context that is used during dataflow analysis.

Definition at line 64 of file DataflowAnalysisContext.h.

Constructor & Destructor Documentation

◆ DataflowAnalysisContext()

clang::dataflow::DataflowAnalysisContext::DataflowAnalysisContext ( std::unique_ptr< Solver S,
Options  Opts = Options{ std::nullopt, nullptr} 
)

Constructs a dataflow analysis context.

Requirements:

S must not be null.

Definition at line 252 of file DataflowAnalysisContext.cpp.

References DataflowLog(), clang::dataflow::DataflowAnalysisContext::Options::Log, clang::dataflow::makeLoggerFromCommandLine(), and clang::dataflow::Logger::null().

◆ ~DataflowAnalysisContext()

clang::dataflow::DataflowAnalysisContext::~DataflowAnalysisContext ( )
default

Member Function Documentation

◆ addFlowConditionConstraint()

void clang::dataflow::DataflowAnalysisContext::addFlowConditionConstraint ( AtomicBoolValue Token,
BoolValue Constraint 
)

Adds Constraint to the flow condition identified by Token.

Definition at line 99 of file DataflowAnalysisContext.cpp.

References arena(), and clang::dataflow::Arena::makeAnd().

Referenced by clang::dataflow::Environment::addToFlowCondition(), forkFlowCondition(), and joinFlowConditions().

◆ arena()

Arena & clang::dataflow::DataflowAnalysisContext::arena ( )
inline

◆ createStorageLocation()

StorageLocation & clang::dataflow::DataflowAnalysisContext::createStorageLocation ( QualType  Type)

◆ dumpFlowCondition()

void clang::dataflow::DataflowAnalysisContext::dumpFlowCondition ( AtomicBoolValue Token,
llvm::raw_ostream &  OS = llvm::dbgs() 
)

◆ equivalentBoolValues()

bool clang::dataflow::DataflowAnalysisContext::equivalentBoolValues ( BoolValue Val1,
BoolValue Val2 
)

Returns true if Val1 is equivalent to Val2.

Note: This function doesn't take into account constraints on Val1 and Val2 imposed by the flow condition.

Definition at line 159 of file DataflowAnalysisContext.cpp.

References arena(), and clang::dataflow::Arena::makeNot().

◆ flowConditionImplies()

bool clang::dataflow::DataflowAnalysisContext::flowConditionImplies ( AtomicBoolValue Token,
BoolValue Val 
)

Returns true if and only if the constraints of the flow condition identified by Token imply that Val is true.

Definition at line 135 of file DataflowAnalysisContext.cpp.

References arena(), and clang::dataflow::Arena::makeNot().

Referenced by clang::dataflow::Environment::flowConditionImplies().

◆ flowConditionIsTautology()

bool clang::dataflow::DataflowAnalysisContext::flowConditionIsTautology ( AtomicBoolValue Token)

Returns true if and only if the constraints of the flow condition identified by Token are always true.

Definition at line 149 of file DataflowAnalysisContext.cpp.

References arena(), and clang::dataflow::Arena::makeNot().

◆ forkFlowCondition()

AtomicBoolValue & clang::dataflow::DataflowAnalysisContext::forkFlowCondition ( AtomicBoolValue Token)

Creates a new flow condition with the same constraints as the flow condition identified by Token and returns its token.

Definition at line 109 of file DataflowAnalysisContext.cpp.

References addFlowConditionConstraint(), arena(), and clang::dataflow::Arena::makeFlowConditionToken().

◆ getControlFlowContext()

const ControlFlowContext * clang::dataflow::DataflowAnalysisContext::getControlFlowContext ( const FunctionDecl F)

Returns the ControlFlowContext registered for F, if any.

Otherwise, returns null.

Definition at line 204 of file DataflowAnalysisContext.cpp.

References clang::dataflow::ControlFlowContext::build(), CFCtx, clang::FunctionDecl::getDefinition(), clang::FunctionDecl::hasBody(), and clang::Result.

◆ getOptions()

const Options & clang::dataflow::DataflowAnalysisContext::getOptions ( )
inline

Definition at line 175 of file DataflowAnalysisContext.h.

◆ getOrCreateNullPointerValue()

PointerValue & clang::dataflow::DataflowAnalysisContext::getOrCreateNullPointerValue ( QualType  PointeeType)

Returns a pointer value that represents a null pointer.

Calls with PointeeType that are canonically equivalent will return the same result. A null PointeeType can be used for the pointee of std::nullptr_t.

Definition at line 88 of file DataflowAnalysisContext.cpp.

References arena(), clang::dataflow::Arena::create(), createStorageLocation(), clang::QualType::getCanonicalType(), and clang::QualType::isNull().

Referenced by clang::dataflow::Environment::getOrCreateNullPointerValue().

◆ getStableStorageLocation() [1/2]

StorageLocation & clang::dataflow::DataflowAnalysisContext::getStableStorageLocation ( const Expr E)

Returns a stable storage location for E.

Definition at line 79 of file DataflowAnalysisContext.cpp.

References createStorageLocation(), getStorageLocation(), clang::Expr::getType(), and setStorageLocation().

◆ getStableStorageLocation() [2/2]

StorageLocation & clang::dataflow::DataflowAnalysisContext::getStableStorageLocation ( const VarDecl D)

◆ getStorageLocation() [1/2]

StorageLocation * clang::dataflow::DataflowAnalysisContext::getStorageLocation ( const Expr E) const
inline

Returns the storage location assigned to E or null if E has no assigned storage location.

Definition at line 131 of file DataflowAnalysisContext.h.

References clang::dataflow::ignoreCFGOmittedNodes().

◆ getStorageLocation() [2/2]

StorageLocation * clang::dataflow::DataflowAnalysisContext::getStorageLocation ( const ValueDecl D) const
inline

Returns the storage location assigned to D or null if D has no assigned storage location.

Definition at line 113 of file DataflowAnalysisContext.h.

Referenced by getStableStorageLocation().

◆ joinFlowConditions()

AtomicBoolValue & clang::dataflow::DataflowAnalysisContext::joinFlowConditions ( AtomicBoolValue FirstToken,
AtomicBoolValue SecondToken 
)

Creates a new flow condition that represents the disjunction of the flow conditions identified by FirstToken and SecondToken, and returns its token.

Definition at line 117 of file DataflowAnalysisContext.cpp.

References addFlowConditionConstraint(), arena(), and clang::dataflow::Arena::makeFlowConditionToken().

Referenced by clang::dataflow::Environment::join().

◆ setStorageLocation() [1/2]

void clang::dataflow::DataflowAnalysisContext::setStorageLocation ( const Expr E,
StorageLocation Loc 
)
inline

Assigns Loc as the storage location of E.

Requirements:

E must not be assigned a storage location.

Definition at line 123 of file DataflowAnalysisContext.h.

References clang::dataflow::ignoreCFGOmittedNodes().

◆ setStorageLocation() [2/2]

void clang::dataflow::DataflowAnalysisContext::setStorageLocation ( const ValueDecl D,
StorageLocation Loc 
)
inline

Assigns Loc as the storage location of D.

Requirements:

D must not be assigned a storage location.

Definition at line 106 of file DataflowAnalysisContext.h.

Referenced by getStableStorageLocation().

Friends And Related Function Documentation

◆ Environment

friend class Environment
friend

Definition at line 180 of file DataflowAnalysisContext.h.


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