clang 18.0.0git
|
Holds the state of the program (store and heap) at a given program point. More...
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
Classes | |
class | ValueModel |
Supplements Environment with non-standard comparison and join operations. More... | |
Public Member Functions | |
Environment (DataflowAnalysisContext &DACtx) | |
Creates an environment that uses DACtx to store objects that encompass the state of a program. | |
Environment & | operator= (const Environment &Other)=delete |
Environment (Environment &&Other)=default | |
Environment & | operator= (Environment &&Other)=default |
Environment (DataflowAnalysisContext &DACtx, const DeclContext &DeclCtx) | |
Creates an environment that uses DACtx to store objects that encompass the state of a program. | |
Environment | fork () const |
Returns a new environment that is a copy of this one. | |
Environment | pushCall (const CallExpr *Call) const |
Creates and returns an environment to use for an inline analysis of the callee. | |
Environment | pushCall (const CXXConstructExpr *Call) const |
void | popCall (const CallExpr *Call, const Environment &CalleeEnv) |
Moves gathered information back into this from a CalleeEnv created via pushCall . | |
void | popCall (const CXXConstructExpr *Call, const Environment &CalleeEnv) |
bool | equivalentTo (const Environment &Other, Environment::ValueModel &Model) const |
Returns true if and only if the environment is equivalent to Other , i.e the two environments: | |
LatticeJoinEffect | widen (const Environment &PrevEnv, Environment::ValueModel &Model) |
Widens the environment point-wise, using PrevEnv as needed to inform the approximation. | |
StorageLocation & | createStorageLocation (QualType Type) |
Creates a storage location appropriate for Type . | |
StorageLocation & | createStorageLocation (const ValueDecl &D) |
Creates a storage location for D . | |
StorageLocation & | createStorageLocation (const Expr &E) |
Creates a storage location for E . | |
void | setStorageLocation (const ValueDecl &D, StorageLocation &Loc) |
Assigns Loc as the storage location of D in the environment. | |
StorageLocation * | getStorageLocation (const ValueDecl &D) const |
Returns the storage location assigned to D in the environment, or null if D isn't assigned a storage location in the environment. | |
void | removeDecl (const ValueDecl &D) |
Removes the location assigned to D in the environment (if any). | |
void | setStorageLocation (const Expr &E, StorageLocation &Loc) |
Assigns Loc as the storage location of the glvalue E in the environment. | |
StorageLocation * | getStorageLocation (const Expr &E) const |
Returns the storage location assigned to the glvalue E in the environment, or null if E isn't assigned a storage location in the environment. | |
RecordStorageLocation * | getThisPointeeStorageLocation () const |
Returns the storage location assigned to the this pointee in the environment or null if the this pointee has no assigned storage location in the environment. | |
RecordStorageLocation & | getResultObjectLocation (const Expr &RecordPRValue) |
Returns the location of the result object for a record-type prvalue. | |
Value * | getReturnValue () const |
Returns the return value of the current function. | |
StorageLocation * | getReturnStorageLocation () const |
Returns the storage location for the reference returned by the current function. | |
void | setReturnValue (Value *Val) |
Sets the return value of the current function. | |
void | setReturnStorageLocation (StorageLocation *Loc) |
Sets the storage location for the reference returned by the current function. | |
PointerValue & | getOrCreateNullPointerValue (QualType PointeeType) |
Returns a pointer value that represents a null pointer. | |
Value * | createValue (QualType Type) |
Creates a value appropriate for Type , if Type is supported, otherwise returns null. | |
StorageLocation & | createObject (QualType Ty, const Expr *InitExpr=nullptr) |
Creates an object (i.e. | |
StorageLocation & | createObject (const VarDecl &D) |
Creates an object for the variable declaration D . | |
StorageLocation & | createObject (const ValueDecl &D, const Expr *InitExpr) |
Creates an object for the variable declaration D . | |
void | setValue (const StorageLocation &Loc, Value &Val) |
Assigns Val as the value of Loc in the environment. | |
void | clearValue (const StorageLocation &Loc) |
Clears any association between Loc and a value in the environment. | |
void | setValue (const Expr &E, Value &Val) |
Assigns Val as the value of the prvalue E in the environment. | |
Value * | getValue (const StorageLocation &Loc) const |
Returns the value assigned to Loc in the environment or null if Loc isn't assigned a value in the environment. | |
Value * | getValue (const ValueDecl &D) const |
Equivalent to getValue(getStorageLocation(D)) if D is assigned a storage location in the environment, otherwise returns null. | |
Value * | getValue (const Expr &E) const |
Equivalent to getValue(getStorageLocation(E, SP)) if E is assigned a storage location in the environment, otherwise returns null. | |
template<typename T , typename... Args> | |
std::enable_if_t< std::is_base_of< Value, T >::value, T & > | create (Args &&...args) |
Creates a T (some subclass of Value ), forwarding args to the constructor, and returns a reference to it. | |
IntegerValue & | getIntLiteralValue (llvm::APInt Value) const |
Returns a symbolic integer value that models an integer literal equal to Value | |
BoolValue & | getBoolLiteralValue (bool Value) const |
Returns a symbolic boolean value that models a boolean literal equal to Value | |
BoolValue & | makeAtomicBoolValue () const |
Returns an atomic boolean value. | |
BoolValue & | makeTopBoolValue () const |
Returns a unique instance of boolean Top. | |
BoolValue & | makeAnd (BoolValue &LHS, BoolValue &RHS) const |
Returns a boolean value that represents the conjunction of LHS and RHS . | |
BoolValue & | makeOr (BoolValue &LHS, BoolValue &RHS) const |
Returns a boolean value that represents the disjunction of LHS and RHS . | |
BoolValue & | makeNot (BoolValue &Val) const |
Returns a boolean value that represents the negation of Val . | |
BoolValue & | makeImplication (BoolValue &LHS, BoolValue &RHS) const |
Returns a boolean value represents LHS => RHS . | |
BoolValue & | makeIff (BoolValue &LHS, BoolValue &RHS) const |
Returns a boolean value represents LHS <=> RHS . | |
Atom | getFlowConditionToken () const |
Returns a boolean variable that identifies the flow condition (FC). | |
void | assume (const Formula &) |
Record a fact that must be true if this point in the program is reached. | |
bool | proves (const Formula &) const |
Returns true if the formula is always true when this point is reached. | |
bool | allows (const Formula &) const |
Returns true if the formula may be true when this point is reached. | |
const DeclContext * | getDeclCtx () const |
Returns the DeclContext of the block being analysed, if any. | |
const FunctionDecl * | getCurrentFunc () const |
Returns the function currently being analyzed, or null if the code being analyzed isn't part of a function. | |
bool | canDescend (unsigned MaxDepth, const DeclContext *Callee) const |
Returns whether this Environment can be extended to analyze the given Callee (i.e. | |
DataflowAnalysisContext & | getDataflowAnalysisContext () const |
Returns the DataflowAnalysisContext used by the environment. | |
Arena & | arena () const |
LLVM_DUMP_METHOD void | dump () const |
LLVM_DUMP_METHOD void | dump (raw_ostream &OS) const |
Static Public Member Functions | |
static Environment | join (const Environment &EnvA, const Environment &EnvB, Environment::ValueModel &Model) |
Joins two environments by taking the intersection of storage locations and values that are stored in them. | |
Holds the state of the program (store and heap) at a given program point.
WARNING: Symbolic values that are created by the environment for static local and global variables are not currently invalidated on function calls. This is unsound and should be taken into account when designing dataflow analyses.
Definition at line 54 of file DataflowEnvironment.h.
|
explicit |
Creates an environment that uses DACtx
to store objects that encompass the state of a program.
Definition at line 406 of file DataflowEnvironment.cpp.
|
default |
clang::dataflow::Environment::Environment | ( | DataflowAnalysisContext & | DACtx, |
const DeclContext & | DeclCtx | ||
) |
Creates an environment that uses DACtx
to store objects that encompass the state of a program.
If DeclCtx
is a function, initializes the environment with symbolic representations of the function parameters.
If DeclCtx
is a non-static member function, initializes the environment with a symbolic representation of the this
pointee.
Definition at line 416 of file DataflowEnvironment.cpp.
References createObject(), createValue(), clang::FunctionDecl::getBody(), clang::DeclContext::getNonClosureAncestor(), clang::FunctionDecl::parameters(), Parent, and setStorageLocation().
Returns true if the formula may be true when this point is reached.
Returns false if the formula is always false when this point is reached (or the flow condition is overly constraining) or if the solver times out.
Definition at line 937 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::flowConditionAllows().
|
inline |
Definition at line 581 of file DataflowEnvironment.h.
References clang::dataflow::DataflowAnalysisContext::arena().
Referenced by create(), getBoolLiteralValue(), getIntLiteralValue(), makeAnd(), makeAtomicBoolValue(), makeIff(), makeImplication(), makeNot(), makeOr(), makeTopBoolValue(), clang::dataflow::UncheckedOptionalAccessModel::merge(), and clang::dataflow::mergeDistinctValues().
void clang::dataflow::Environment::assume | ( | const Formula & | F | ) |
Record a fact that must be true if this point in the program is reached.
Definition at line 929 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::addFlowConditionConstraint().
Referenced by clang::dataflow::UncheckedOptionalAccessModel::merge(), and clang::dataflow::mergeDistinctValues().
bool clang::dataflow::Environment::canDescend | ( | unsigned | MaxDepth, |
const DeclContext * | Callee | ||
) | const |
Returns whether this Environment
can be extended to analyze the given Callee
(i.e.
if pushCall
can be used), with recursion disallowed and a given MaxDepth
.
Definition at line 459 of file DataflowEnvironment.cpp.
|
inline |
Clears any association between Loc
and a value in the environment.
Definition at line 415 of file DataflowEnvironment.h.
|
inline |
Creates a T
(some subclass of Value
), forwarding args
to the constructor, and returns a reference to it.
The analysis context takes ownership of the created object. The object will be destroyed when the analysis context is destroyed.
Definition at line 460 of file DataflowEnvironment.h.
References arena(), and clang::dataflow::Arena::create().
Referenced by clang::dataflow::mergeDistinctValues(), and clang::dataflow::refreshRecordValue().
|
inline |
Creates an object for the variable declaration D
.
If InitExpr
is non-null and has a value associated with it, initializes the object with this value. Otherwise, initializes the object with a value created using createValue()
. Uses the storage location returned by DataflowAnalysisContext::getStableStorageLocation(D)
.
Definition at line 407 of file DataflowEnvironment.h.
References clang::ValueDecl::getType().
|
inline |
Creates an object for the variable declaration D
.
If D
has an initializer and this initializer is associated with a value, initializes the object with this value. Otherwise, initializes the object with a value created using createValue()
. Uses the storage location returned by DataflowAnalysisContext::getStableStorageLocation(D)
.
Definition at line 398 of file DataflowEnvironment.h.
References clang::VarDecl::getInit(), and clang::ValueDecl::getType().
|
inline |
Creates an object (i.e.
a storage location with an associated value) of type Ty
. If InitExpr
is non-null and has a value associated with it, initializes the object with this value. Otherwise, initializes the object with a value created using createValue()
.
Definition at line 389 of file DataflowEnvironment.h.
Referenced by Environment().
StorageLocation & clang::dataflow::Environment::createStorageLocation | ( | const Expr & | E | ) |
Creates a storage location for E
.
Does not assign the returned storage location to E
in the environment. Does not assign a value to the returned storage location in the environment.
Definition at line 677 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::getStableStorageLocation().
StorageLocation & clang::dataflow::Environment::createStorageLocation | ( | const ValueDecl & | D | ) |
Creates a storage location for D
.
Does not assign the returned storage location to D
in the environment. Does not assign a value to the returned storage location in the environment.
Definition at line 670 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::getStableStorageLocation().
StorageLocation & clang::dataflow::Environment::createStorageLocation | ( | QualType | Type | ) |
Creates a storage location appropriate for Type
.
Does not assign a value to the returned storage location in the environment.
Requirements:
Type
must not be null.
Definition at line 666 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::createStorageLocation().
Creates a value appropriate for Type
, if Type
is supported, otherwise returns null.
If Type
is a pointer or reference type, creates all the necessary storage locations and values for indirections until it finds a non-pointer/non-reference type.
If Type
is a class, struct, or union type, calls setValue()
to associate the RecordValue
with its storage location (RecordValue::getLoc()
).
If Type
is one of the following types, this function will always return a non-null pointer:
bool
Requirements:
Type
must not be null.
Definition at line 772 of file DataflowEnvironment.cpp.
References clang::dataflow::MaxCompositeValueSize, and Visited.
Referenced by Environment(), clang::dataflow::mergeDistinctValues(), and clang::dataflow::refreshRecordValue().
void clang::dataflow::Environment::dump | ( | ) | const |
Definition at line 965 of file DataflowEnvironment.cpp.
References dump().
Referenced by dump(), and clang::dataflow::runTypeErasedDataflowAnalysis().
void clang::dataflow::Environment::dump | ( | raw_ostream & | OS | ) | const |
Definition at line 941 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::dumpFlowCondition(), and V.
bool clang::dataflow::Environment::equivalentTo | ( | const Environment & | Other, |
Environment::ValueModel & | Model | ||
) | const |
Returns true if and only if the environment is equivalent to Other
, i.e the two environments:
Model
) values assigned to the same storage locations.Requirements:
Other
and this
must use the same DataflowAnalysisContext
.
Definition at line 548 of file DataflowEnvironment.cpp.
References clang::dataflow::compareKeyToValueMaps(), and clang::Other.
Environment clang::dataflow::Environment::fork | ( | ) | const |
Returns a new environment that is a copy of this one.
The state of the program is initially the same, but can be mutated without affecting the original.
However the original should not be further mutated, as this may interfere with the fork. (In practice, values are stored independently, but the forked flow condition references the original).
Definition at line 410 of file DataflowEnvironment.cpp.
References clang::Copy, and clang::dataflow::DataflowAnalysisContext::forkFlowCondition().
Referenced by clang::dataflow::TypeErasedDataflowAnalysisState::fork(), and clang::dataflow::runTypeErasedDataflowAnalysis().
Returns a symbolic boolean value that models a boolean literal equal to Value
Definition at line 472 of file DataflowEnvironment.h.
References arena(), and clang::dataflow::Arena::makeBoolValue().
Referenced by clang::dataflow::evaluateBooleanEquality().
|
inline |
Returns the function currently being analyzed, or null if the code being analyzed isn't part of a function.
Definition at line 569 of file DataflowEnvironment.h.
References getDeclCtx().
Referenced by getReturnStorageLocation(), getReturnValue(), setReturnStorageLocation(), and setReturnValue().
|
inline |
Returns the DataflowAnalysisContext
used by the environment.
Definition at line 579 of file DataflowEnvironment.h.
Referenced by clang::dataflow::unpackValue().
|
inline |
Returns the DeclContext
of the block being analysed, if any.
Otherwise, returns null.
Definition at line 565 of file DataflowEnvironment.h.
Referenced by getCurrentFunc().
|
inline |
Returns a boolean variable that identifies the flow condition (FC).
The flow condition is a set of facts that are necessarily true when the program reaches the current point, expressed as boolean formulas. The flow condition token is equivalent to the AND of these facts.
These may e.g. constrain the value of certain variables. A pointer variable may have a consistent modeled PointerValue throughout, but at a given point the Environment may tell us that the value must be non-null.
The FC is necessary but not sufficient for this point to be reachable. In particular, where the FC token appears in flow conditions of successor environments, it means "point X may have been reached", not "point X was reached".
Definition at line 542 of file DataflowEnvironment.h.
Referenced by clang::dataflow::mergeDistinctValues().
|
inline |
Returns a symbolic integer value that models an integer literal equal to Value
Definition at line 466 of file DataflowEnvironment.h.
References arena(), and clang::dataflow::Arena::makeIntLiteral().
PointerValue & clang::dataflow::Environment::getOrCreateNullPointerValue | ( | QualType | PointeeType | ) |
Returns a pointer value that represents a null pointer.
Calls with PointeeType
that are canonically equivalent will return the same result.
Definition at line 734 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::getOrCreateNullPointerValue().
RecordStorageLocation & clang::dataflow::Environment::getResultObjectLocation | ( | const Expr & | RecordPRValue | ) |
Returns the location of the result object for a record-type prvalue.
In C++, prvalues of record type serve only a limited purpose: They can only be used to initialize a result object (e.g. a variable or a temporary). This function returns the location of that result object.
When creating a prvalue of record type, we already need the storage location of the result object to pass in this
, even though prvalues are otherwise not associated with storage locations.
FIXME: Currently, this simply returns a stable storage location for E
, but this doesn't do the right thing in scenarios like the following:
Here, MyClass(foo)
and MyClass(bar)
will have two different storage locations, when in fact their storage locations should be the same. Eventually, we want to propagate storage locations from result objects down to the prvalues that initialize them, similar to the way that this is done in Clang's CodeGen.
Requirements: E
must be a prvalue of record type.
Definition at line 722 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::getStableStorageLocation(), clang::Expr::getType(), clang::Expr::isPRValue(), and clang::Type::isRecordType().
|
inline |
Returns the storage location for the reference returned by the current function.
This can be null if function doesn't return a single consistent reference.
Requirements: The current function must have a reference return type.
Definition at line 332 of file DataflowEnvironment.h.
References getCurrentFunc().
|
inline |
Returns the return value of the current function.
This can be null if:
Requirements: The current function must have a non-reference return type.
Definition at line 320 of file DataflowEnvironment.h.
References getCurrentFunc().
StorageLocation * clang::dataflow::Environment::getStorageLocation | ( | const Expr & | E | ) | const |
Returns the storage location assigned to the glvalue E
in the environment, or null if E
isn't assigned a storage location in the environment.
Requirements: E
must be a glvalue or a BuiltinType::BuiltinFn
Definition at line 710 of file DataflowEnvironment.cpp.
References clang::Expr::getType(), clang::Expr::isGLValue(), and clang::Type::isSpecificBuiltinType().
StorageLocation * clang::dataflow::Environment::getStorageLocation | ( | const ValueDecl & | D | ) | const |
Returns the storage location assigned to D
in the environment, or null if D
isn't assigned a storage location in the environment.
Definition at line 689 of file DataflowEnvironment.cpp.
Referenced by clang::dataflow::builtinTransferInitializer(), clang::dataflow::getBaseObjectLocation(), clang::dataflow::getImplicitObjectLocation(), getValue(), clang::dataflow::maybeUnpackLValueExpr(), clang::dataflow::propagateStorageLocation(), pushCall(), and clang::dataflow::refreshRecordValue().
RecordStorageLocation * clang::dataflow::Environment::getThisPointeeStorageLocation | ( | ) | const |
Returns the storage location assigned to the this
pointee in the environment or null if the this
pointee has no assigned storage location in the environment.
Definition at line 717 of file DataflowEnvironment.cpp.
Referenced by clang::dataflow::builtinTransferInitializer().
Equivalent to getValue(getStorageLocation(E, SP))
if E
is assigned a storage location in the environment, otherwise returns null.
Definition at line 760 of file DataflowEnvironment.cpp.
References getValue(), clang::dataflow::ignoreCFGOmittedNodes(), and clang::Expr::isPRValue().
Value * clang::dataflow::Environment::getValue | ( | const StorageLocation & | Loc | ) | const |
Returns the value assigned to Loc
in the environment or null if Loc
isn't assigned a value in the environment.
Definition at line 749 of file DataflowEnvironment.cpp.
Referenced by clang::dataflow::builtinTransferInitializer(), clang::dataflow::evaluateBooleanEquality(), clang::dataflow::getBaseObjectLocation(), clang::dataflow::getImplicitObjectLocation(), getValue(), clang::dataflow::maybeUnpackLValueExpr(), popCall(), clang::dataflow::propagateValue(), clang::dataflow::recordsEqual(), and clang::dataflow::refreshRecordValue().
Equivalent to getValue(getStorageLocation(D))
if D
is assigned a storage location in the environment, otherwise returns null.
Definition at line 753 of file DataflowEnvironment.cpp.
References getStorageLocation(), and getValue().
|
static |
Joins two environments by taking the intersection of storage locations and values that are stored in them.
Distinct values that are assigned to the same storage locations in EnvA
and EnvB
are merged using Model
.
Requirements:
EnvA
and EnvB
must use the same DataflowAnalysisContext
.
Definition at line 610 of file DataflowEnvironment.cpp.
References clang::dataflow::areEquivalentValues(), clang::Func, clang::dataflow::intersectDeclToLoc(), clang::dataflow::DataflowAnalysisContext::joinFlowConditions(), clang::dataflow::joinLocToVal(), and clang::dataflow::mergeDistinctValues().
Returns a boolean value that represents the conjunction of LHS
and RHS
.
Subsequent calls with the same arguments, regardless of their order, will return the same result. If the given boolean values represent the same value, the result will be the value itself.
Definition at line 490 of file DataflowEnvironment.h.
References arena(), clang::dataflow::BoolValue::formula(), makeAnd(), and clang::dataflow::Arena::makeBoolValue().
Referenced by makeAnd().
|
inline |
Returns an atomic boolean value.
Definition at line 477 of file DataflowEnvironment.h.
References arena(), and clang::dataflow::Arena::makeAtomValue().
Referenced by clang::dataflow::evaluateBooleanEquality(), and clang::dataflow::UncheckedOptionalAccessModel::merge().
Returns a boolean value represents LHS
<=> RHS
.
Subsequent calls with the same arguments, regardless of their order, will return the same result. If the given boolean values represent the same value, the result will be a value that represents the true boolean literal.
Definition at line 523 of file DataflowEnvironment.h.
References arena(), clang::dataflow::BoolValue::formula(), and clang::dataflow::Arena::makeBoolValue().
Referenced by clang::dataflow::evaluateBooleanEquality().
|
inline |
Returns a boolean value represents LHS
=> RHS
.
Subsequent calls with the same arguments, will return the same result. If the given boolean values represent the same value, the result will be a value that represents the true boolean literal.
Definition at line 514 of file DataflowEnvironment.h.
References arena(), clang::dataflow::BoolValue::formula(), and clang::dataflow::Arena::makeBoolValue().
Returns a boolean value that represents the negation of Val
.
Subsequent calls with the same argument will return the same result.
Definition at line 506 of file DataflowEnvironment.h.
References arena(), clang::dataflow::BoolValue::formula(), clang::dataflow::Arena::makeBoolValue(), and makeNot().
Referenced by makeNot().
Returns a boolean value that represents the disjunction of LHS
and RHS
.
Subsequent calls with the same arguments, regardless of their order, will return the same result. If the given boolean values represent the same value, the result will be the value itself.
Definition at line 499 of file DataflowEnvironment.h.
References arena(), clang::dataflow::BoolValue::formula(), clang::dataflow::Arena::makeBoolValue(), and makeOr().
Referenced by makeOr().
|
inline |
Returns a unique instance of boolean Top.
Definition at line 482 of file DataflowEnvironment.h.
References arena(), and clang::dataflow::Arena::makeTopValue().
Referenced by clang::dataflow::UncheckedOptionalAccessModel::widen(), and clang::dataflow::widenDistinctValues().
|
delete |
|
default |
void clang::dataflow::Environment::popCall | ( | const CallExpr * | Call, |
const Environment & | CalleeEnv | ||
) |
Moves gathered information back into this
from a CalleeEnv
created via pushCall
.
Definition at line 517 of file DataflowEnvironment.cpp.
References clang::Call, setStorageLocation(), and setValue().
void clang::dataflow::Environment::popCall | ( | const CXXConstructExpr * | Call, |
const Environment & | CalleeEnv | ||
) |
Definition at line 537 of file DataflowEnvironment.cpp.
References clang::Call, getValue(), and setValue().
Returns true if the formula is always true when this point is reached.
Returns false if the formula may be false (or the flow condition isn't sufficiently precise to prove that it is true) or if the solver times out.
Note that there is an asymmetry between this function and allows()
in that they both return false if the solver times out. The assumption is that if proves()
or allows()
returns true, this will result in a diagnostic, and we want to bias towards false negatives in the case where the solver times out.
Definition at line 933 of file DataflowEnvironment.cpp.
References clang::dataflow::DataflowAnalysisContext::flowConditionImplies().
Environment clang::dataflow::Environment::pushCall | ( | const CallExpr * | Call | ) | const |
Creates and returns an environment to use for an inline analysis of the callee.
Uses the storage location from each argument in the Call
as the storage location for the corresponding parameter in the callee.
Requirements:
The callee of Call
must be a FunctionDecl
.
The body of the callee must not reference globals.
The arguments of Call
must map 1:1 to the callee's parameters.
Definition at line 464 of file DataflowEnvironment.cpp.
References clang::Call, Env, and getStorageLocation().
Environment clang::dataflow::Environment::pushCall | ( | const CXXConstructExpr * | Call | ) | const |
Definition at line 483 of file DataflowEnvironment.cpp.
References clang::Call, and Env.
void clang::dataflow::Environment::removeDecl | ( | const ValueDecl & | D | ) |
Removes the location assigned to D
in the environment (if any).
Definition at line 699 of file DataflowEnvironment.cpp.
|
inline |
Sets the storage location for the reference returned by the current function.
Requirements: The current function must have a reference return type.
Definition at line 353 of file DataflowEnvironment.h.
References getCurrentFunc().
|
inline |
Sets the return value of the current function.
Requirements: The current function must have a non-reference return type.
Definition at line 342 of file DataflowEnvironment.h.
References getCurrentFunc().
void clang::dataflow::Environment::setStorageLocation | ( | const Expr & | E, |
StorageLocation & | Loc | ||
) |
Assigns Loc
as the storage location of the glvalue E
in the environment.
Requirements:
E
must not be assigned a storage location in the environment. E
must be a glvalue or a BuiltinType::BuiltinFn
Definition at line 701 of file DataflowEnvironment.cpp.
References clang::Expr::getType(), clang::Expr::isGLValue(), and clang::Type::isSpecificBuiltinType().
void clang::dataflow::Environment::setStorageLocation | ( | const ValueDecl & | D, |
StorageLocation & | Loc | ||
) |
Assigns Loc
as the storage location of D
in the environment.
Requirements:
D
must not already have a storage location in the environment.
Definition at line 684 of file DataflowEnvironment.cpp.
Referenced by Environment(), popCall(), clang::dataflow::propagateStorageLocation(), and clang::dataflow::refreshRecordValue().
Assigns Val
as the value of the prvalue E
in the environment.
If E
is not yet associated with a storage location, associates it with a newly created storage location. In any case, associates the storage location of E
with Val
.
Once the migration to strict handling of value categories is complete (see https://discourse.llvm.org/t/70086), this function will be renamed to setValue()
. At this point, prvalue expressions will be associated directly with Value
s, and the legacy behavior of associating prvalue expressions with storage locations (as described above) will be eliminated.
Requirements:
E
must be a prvalue If Val
is a RecordValue
, its RecordStorageLocation
must be the same as that of any RecordValue
that has already been associated with E
. This is to guarantee that the result object initialized by a prvalue RecordValue
has a durable storage location.
Definition at line 744 of file DataflowEnvironment.cpp.
References clang::Expr::isPRValue().
void clang::dataflow::Environment::setValue | ( | const StorageLocation & | Loc, |
Value & | Val | ||
) |
Assigns Val
as the value of Loc
in the environment.
Definition at line 738 of file DataflowEnvironment.cpp.
Referenced by clang::dataflow::builtinTransferInitializer(), clang::dataflow::maybeUnpackLValueExpr(), popCall(), clang::dataflow::propagateValue(), and clang::dataflow::refreshRecordValue().
LatticeJoinEffect clang::dataflow::Environment::widen | ( | const Environment & | PrevEnv, |
Environment::ValueModel & | Model | ||
) |
Widens the environment point-wise, using PrevEnv
as needed to inform the approximation.
Requirements:
PrevEnv
must be the immediate previous version of the environment. PrevEnv
and this
must use the same DataflowAnalysisContext
.
Definition at line 576 of file DataflowEnvironment.cpp.
References clang::dataflow::Changed, clang::dataflow::Unchanged, and clang::dataflow::widenKeyToValueMap().
Referenced by clang::dataflow::runTypeErasedDataflowAnalysis().