clang 17.0.0git
|
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 () | |
StorageLocation & | createStorageLocation (QualType Type) |
Returns a new storage location appropriate for Type . | |
StorageLocation & | getStableStorageLocation (const VarDecl &D) |
Returns a stable storage location for D . | |
StorageLocation & | getStableStorageLocation (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 . | |
StorageLocation * | getStorageLocation (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 . | |
StorageLocation * | getStorageLocation (const Expr &E) const |
Returns the storage location assigned to E or null if E has no assigned storage location. | |
PointerValue & | getOrCreateNullPointerValue (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 . | |
AtomicBoolValue & | forkFlowCondition (AtomicBoolValue &Token) |
Creates a new flow condition with the same constraints as the flow condition identified by Token and returns its token. | |
AtomicBoolValue & | 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. | |
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 ControlFlowContext * | getControlFlowContext (const FunctionDecl *F) |
Returns the ControlFlowContext registered for F , if any. | |
const Options & | getOptions () |
Arena & | arena () |
Friends | |
class | Environment |
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.
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().
|
default |
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().
|
inline |
Definition at line 177 of file DataflowAnalysisContext.h.
Referenced by addFlowConditionConstraint(), clang::dataflow::Environment::create(), createStorageLocation(), dumpFlowCondition(), equivalentBoolValues(), flowConditionImplies(), flowConditionIsTautology(), forkFlowCondition(), clang::dataflow::Environment::getBoolLiteralValue(), getOrCreateNullPointerValue(), joinFlowConditions(), clang::dataflow::Environment::makeAnd(), clang::dataflow::Environment::makeAtomicBoolValue(), clang::dataflow::Environment::makeIff(), clang::dataflow::Environment::makeImplication(), clang::dataflow::Environment::makeNot(), clang::dataflow::Environment::makeOr(), and clang::dataflow::Environment::makeTopBoolValue().
StorageLocation & clang::dataflow::DataflowAnalysisContext::createStorageLocation | ( | QualType | Type | ) |
Returns a new storage location appropriate for Type
.
A null Type
is interpreted as the pointee type of std::nullptr_t
.
Definition at line 50 of file DataflowAnalysisContext.cpp.
References arena(), clang::dataflow::DataflowAnalysisContext::Options::ContextSensitiveOpts, clang::dataflow::Arena::create(), createStorageLocation(), clang::dataflow::getObjectFields(), and clang::Type::isRecordType().
Referenced by createStorageLocation(), clang::dataflow::Environment::createStorageLocation(), getOrCreateNullPointerValue(), and getStableStorageLocation().
void clang::dataflow::DataflowAnalysisContext::dumpFlowCondition | ( | AtomicBoolValue & | Token, |
llvm::raw_ostream & | OS = llvm::dbgs() |
||
) |
Definition at line 191 of file DataflowAnalysisContext.cpp.
References arena(), clang::dataflow::debugString(), and clang::dataflow::Arena::makeLiteral().
Referenced by clang::dataflow::Environment::dump().
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().
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().
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().
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().
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.
|
inline |
Definition at line 175 of file DataflowAnalysisContext.h.
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().
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().
StorageLocation & clang::dataflow::DataflowAnalysisContext::getStableStorageLocation | ( | const VarDecl & | D | ) |
Returns a stable storage location for D
.
Definition at line 70 of file DataflowAnalysisContext.cpp.
References createStorageLocation(), getStorageLocation(), clang::ValueDecl::getType(), and setStorageLocation().
Referenced by clang::dataflow::Environment::createStorageLocation().
|
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().
|
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().
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().
|
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().
|
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().
|
friend |
Definition at line 180 of file DataflowAnalysisContext.h.