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

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 (const Environment &Other)
 
Environmentoperator= (const Environment &Other)
 
 Environment (Environment &&Other)=default
 
Environmentoperator= (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 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 join (const Environment &Other, Environment::ValueModel &Model)
 Joins the environment with Other by taking the intersection of storage locations and values that are stored in them.
 
LatticeJoinEffect widen (const Environment &PrevEnv, Environment::ValueModel &Model)
 Widens the environment point-wise, using PrevEnv as needed to inform the approximation.
 
StorageLocationcreateStorageLocation (QualType Type)
 Creates a storage location appropriate for Type.
 
StorageLocationcreateStorageLocation (const VarDecl &D)
 Creates a storage location for D.
 
StorageLocationcreateStorageLocation (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.
 
StorageLocationgetStorageLocation (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 setStorageLocation (const Expr &E, StorageLocation &Loc)
 Assigns Loc as the storage location of E in the environment.
 
void setStorageLocationStrict (const Expr &E, StorageLocation &Loc)
 Assigns Loc as the storage location of the glvalue E in the environment.
 
StorageLocationgetStorageLocation (const Expr &E, SkipPast SP) const
 Returns the storage location assigned to E in the environment, applying the SP policy for skipping past indirections, or null if E isn't assigned a storage location in the environment.
 
StorageLocationgetStorageLocationStrict (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.
 
StorageLocationgetThisPointeeStorageLocation () 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.
 
ValuegetReturnValue () const
 Returns the return value of the current function.
 
StorageLocationgetReturnStorageLocation () 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.
 
PointerValuegetOrCreateNullPointerValue (QualType PointeeType)
 Returns a pointer value that represents a null pointer.
 
ValuecreateValue (QualType Type)
 Creates a value appropriate for Type, if Type is supported, otherwise return null.
 
void setValue (const StorageLocation &Loc, Value &Val)
 Assigns Val as the value of Loc in the environment.
 
void setValueStrict (const Expr &E, Value &Val)
 Assigns Val as the value of the prvalue E in the environment.
 
ValuegetValue (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.
 
ValuegetValue (const ValueDecl &D) const
 Equivalent to getValue(getStorageLocation(D, SP), SkipPast::None) if D is assigned a storage location in the environment, otherwise returns null.
 
ValuegetValue (const Expr &E, SkipPast SP) const
 Equivalent to getValue(getStorageLocation(E, SP), SkipPast::None) if E is assigned a storage location in the environment, otherwise returns null.
 
ValuegetValueStrict (const Expr &E) const
 Returns the Value assigned to the prvalue E in the environment, or null if E isn't assigned a value in the environment.
 
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.
 
AtomicBoolValuegetBoolLiteralValue (bool Value) const
 Returns a symbolic boolean value that models a boolean literal equal to Value
 
BoolValuemakeAtomicBoolValue () const
 Returns an atomic boolean value.
 
BoolValuemakeTopBoolValue () const
 Returns a unique instance of boolean Top.
 
BoolValuemakeAnd (BoolValue &LHS, BoolValue &RHS) const
 Returns a boolean value that represents the conjunction of LHS and RHS.
 
BoolValuemakeOr (BoolValue &LHS, BoolValue &RHS) const
 Returns a boolean value that represents the disjunction of LHS and RHS.
 
BoolValuemakeNot (BoolValue &Val) const
 Returns a boolean value that represents the negation of Val.
 
BoolValuemakeImplication (BoolValue &LHS, BoolValue &RHS) const
 Returns a boolean value represents LHS => RHS.
 
BoolValuemakeIff (BoolValue &LHS, BoolValue &RHS) const
 Returns a boolean value represents LHS <=> RHS.
 
AtomicBoolValuegetFlowConditionToken () const
 Returns the token that identifies the flow condition of the environment.
 
void addToFlowCondition (BoolValue &Val)
 Adds Val to the set of clauses that constitute the flow condition.
 
bool flowConditionImplies (BoolValue &Val) const
 Returns true if and only if the clauses that constitute the flow condition imply that Val is true.
 
const DeclContextgetDeclCtx () const
 Returns the DeclContext of the block being analysed, if any.
 
const FunctionDeclgetCurrentFunc () 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.
 
DataflowAnalysisContextgetDataflowAnalysisContext () const
 Returns the DataflowAnalysisContext used by the environment.
 
LLVM_DUMP_METHOD void dump () const
 
LLVM_DUMP_METHOD void dump (raw_ostream &OS) const
 

Detailed Description

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 64 of file DataflowEnvironment.h.

Constructor & Destructor Documentation

◆ Environment() [1/4]

clang::dataflow::Environment::Environment ( DataflowAnalysisContext DACtx)
explicit

Creates an environment that uses DACtx to store objects that encompass the state of a program.

Definition at line 264 of file DataflowEnvironment.cpp.

◆ Environment() [2/4]

clang::dataflow::Environment::Environment ( const Environment Other)

Definition at line 268 of file DataflowEnvironment.cpp.

◆ Environment() [3/4]

clang::dataflow::Environment::Environment ( Environment &&  Other)
default

◆ Environment() [4/4]

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 283 of file DataflowEnvironment.cpp.

References createStorageLocation(), createValue(), clang::FunctionDecl::getBody(), clang::FunctionDecl::parameters(), Parent, setStorageLocation(), and setValue().

Member Function Documentation

◆ addToFlowCondition()

void clang::dataflow::Environment::addToFlowCondition ( BoolValue Val)

Adds Val to the set of clauses that constitute the flow condition.

Definition at line 888 of file DataflowEnvironment.cpp.

References clang::dataflow::DataflowAnalysisContext::addFlowConditionConstraint().

Referenced by clang::dataflow::UncheckedOptionalAccessModel::merge(), and clang::dataflow::mergeDistinctValues().

◆ canDescend()

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 324 of file DataflowEnvironment.cpp.

◆ create()

template<typename T , typename... Args>
std::enable_if_t< std::is_base_of< Value, T >::value, T & > clang::dataflow::Environment::create ( Args &&...  args)
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 447 of file DataflowEnvironment.h.

References clang::dataflow::DataflowAnalysisContext::arena(), and clang::dataflow::Arena::create().

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

◆ createStorageLocation() [1/3]

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 647 of file DataflowEnvironment.cpp.

References clang::dataflow::DataflowAnalysisContext::getStableStorageLocation().

◆ createStorageLocation() [2/3]

StorageLocation & clang::dataflow::Environment::createStorageLocation ( const VarDecl 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 640 of file DataflowEnvironment.cpp.

References clang::dataflow::DataflowAnalysisContext::getStableStorageLocation().

◆ createStorageLocation() [3/3]

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 636 of file DataflowEnvironment.cpp.

References clang::dataflow::DataflowAnalysisContext::createStorageLocation().

Referenced by Environment(), and setValueStrict().

◆ createValue()

Value * clang::dataflow::Environment::createValue ( QualType  Type)

Creates a value appropriate for Type, if Type is supported, otherwise return 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.

Requirements:

Type must not be null.

Definition at line 791 of file DataflowEnvironment.cpp.

References clang::dataflow::MaxCompositeValueSize, and Visited.

Referenced by Environment(), and clang::dataflow::mergeDistinctValues().

◆ dump() [1/2]

void clang::dataflow::Environment::dump ( ) const

Definition at line 916 of file DataflowEnvironment.cpp.

References dump().

Referenced by dump(), and clang::dataflow::runTypeErasedDataflowAnalysis().

◆ dump() [2/2]

void clang::dataflow::Environment::dump ( raw_ostream &  OS) const

◆ equivalentTo()

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:

  • have the same mappings from declarations to storage locations,
  • have the same mappings from expressions to storage locations,
  • have the same or equivalent (according to Model) values assigned to the same storage locations.

Requirements:

Other and this must use the same DataflowAnalysisContext.

Definition at line 435 of file DataflowEnvironment.cpp.

References clang::dataflow::areEquivalentValues(), clang::dataflow::compareDistinctValues(), and clang::dataflow::StorageLocation::getType().

◆ flowConditionImplies()

bool clang::dataflow::Environment::flowConditionImplies ( BoolValue Val) const

Returns true if and only if the clauses that constitute the flow condition imply that Val is true.

Definition at line 892 of file DataflowEnvironment.cpp.

References clang::dataflow::DataflowAnalysisContext::flowConditionImplies().

◆ getBoolLiteralValue()

AtomicBoolValue & clang::dataflow::Environment::getBoolLiteralValue ( bool  Value) const
inline

Returns a symbolic boolean value that models a boolean literal equal to Value

Definition at line 453 of file DataflowEnvironment.h.

References clang::dataflow::DataflowAnalysisContext::arena(), and clang::dataflow::Arena::makeLiteral().

◆ getCurrentFunc()

const FunctionDecl * clang::dataflow::Environment::getCurrentFunc ( ) const
inline

Returns the function currently being analyzed, or null if the code being analyzed isn't part of a function.

Definition at line 521 of file DataflowEnvironment.h.

References getDeclCtx().

Referenced by getReturnStorageLocation(), getReturnValue(), setReturnStorageLocation(), and setReturnValue().

◆ getDataflowAnalysisContext()

DataflowAnalysisContext & clang::dataflow::Environment::getDataflowAnalysisContext ( ) const
inline

Returns the DataflowAnalysisContext used by the environment.

Definition at line 531 of file DataflowEnvironment.h.

◆ getDeclCtx()

const DeclContext * clang::dataflow::Environment::getDeclCtx ( ) const
inline

Returns the DeclContext of the block being analysed, if any.

Otherwise, returns null.

Definition at line 517 of file DataflowEnvironment.h.

Referenced by getCurrentFunc().

◆ getFlowConditionToken()

AtomicBoolValue & clang::dataflow::Environment::getFlowConditionToken ( ) const
inline

Returns the token that identifies the flow condition of the environment.

Definition at line 506 of file DataflowEnvironment.h.

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

◆ getOrCreateNullPointerValue()

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 714 of file DataflowEnvironment.cpp.

References clang::dataflow::DataflowAnalysisContext::getOrCreateNullPointerValue().

◆ getReturnStorageLocation()

StorageLocation * clang::dataflow::Environment::getReturnStorageLocation ( ) const
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 346 of file DataflowEnvironment.h.

References getCurrentFunc().

◆ getReturnValue()

Value * clang::dataflow::Environment::getReturnValue ( ) const
inline

Returns the return value of the current function.

This can be null if:

  • The function has a void return type
  • No return value could be determined for the function, for example because it calls a function without a body.

Requirements: The current function must have a non-reference return type.

Definition at line 334 of file DataflowEnvironment.h.

References getCurrentFunc().

◆ getStorageLocation() [1/2]

StorageLocation * clang::dataflow::Environment::getStorageLocation ( const Expr E,
SkipPast  SP 
) const

Returns the storage location assigned to E in the environment, applying the SP policy for skipping past indirections, or null if E isn't assigned a storage location in the environment.

This function is deprecated; prefer getStorageLocationStrict(). For details, see https://discourse.llvm.org/t/70086.

Definition at line 688 of file DataflowEnvironment.cpp.

References clang::dataflow::ignoreCFGOmittedNodes().

◆ getStorageLocation() [2/2]

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.

Note that if D has reference type, the storage location that is returned refers directly to the referenced object, not a ReferenceValue.

Definition at line 660 of file DataflowEnvironment.cpp.

References getValue().

Referenced by clang::dataflow::getBaseObjectLocation(), clang::dataflow::getImplicitObjectLocation(), getStorageLocationStrict(), getValue(), pushCall(), and setValueStrict().

◆ getStorageLocationStrict()

StorageLocation * clang::dataflow::Environment::getStorageLocationStrict ( 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.

If the storage location for E is associated with a ReferenceValue RefVal, returns RefVal.getReferentLoc() instead.

This function is the preferred alternative to getStorageLocation(const Expr &, SkipPast). Once the migration to strict handling of value categories is complete (see https://discourse.llvm.org/t/70086), getStorageLocation() will be removed and this function will be renamed to getStorageLocation().

Requirements: E must be a glvalue or a BuiltinType::BuiltinFn

Definition at line 695 of file DataflowEnvironment.cpp.

References getStorageLocation(), clang::Expr::getType(), getValue(), clang::Expr::isGLValue(), clang::Type::isSpecificBuiltinType(), and clang::dataflow::None.

Referenced by clang::dataflow::builtinTransferInitializer(), clang::dataflow::maybeUnpackLValueExpr(), and clang::dataflow::propagateStorageLocation().

◆ getThisPointeeStorageLocation()

StorageLocation * 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 710 of file DataflowEnvironment.cpp.

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

◆ getValue() [1/3]

Value * clang::dataflow::Environment::getValue ( const Expr E,
SkipPast  SP 
) const

Equivalent to getValue(getStorageLocation(E, SP), SkipPast::None) if E is assigned a storage location in the environment, otherwise returns null.

This function is deprecated; prefer getValueStrict(). For details, see https://discourse.llvm.org/t/70086.

Definition at line 775 of file DataflowEnvironment.cpp.

References getStorageLocation(), and getValue().

◆ getValue() [2/3]

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 763 of file DataflowEnvironment.cpp.

Referenced by clang::dataflow::getBaseObjectLocation(), clang::dataflow::getImplicitObjectLocation(), getStorageLocation(), getStorageLocationStrict(), getValue(), getValueStrict(), clang::dataflow::maybeUnpackLValueExpr(), popCall(), and setStorageLocation().

◆ getValue() [3/3]

Value * clang::dataflow::Environment::getValue ( const ValueDecl D) const

Equivalent to getValue(getStorageLocation(D, SP), SkipPast::None) if D is assigned a storage location in the environment, otherwise returns null.

Definition at line 768 of file DataflowEnvironment.cpp.

References getStorageLocation(), and getValue().

◆ getValueStrict()

Value * clang::dataflow::Environment::getValueStrict ( const Expr E) const

Returns the Value assigned to the prvalue E in the environment, or null if E isn't assigned a value in the environment.

This function is the preferred alternative to getValue(const Expr &, SkipPast). Once the migration to strict handling of value categories is complete (see https://discourse.llvm.org/t/70086), getValue() will be removed and this function will be renamed to getValue().

Requirements:

E must be a prvalue

Definition at line 782 of file DataflowEnvironment.cpp.

References getValue(), clang::Expr::isPRValue(), and clang::dataflow::None.

Referenced by clang::dataflow::builtinTransferInitializer(), clang::dataflow::evaluateBooleanEquality(), and clang::dataflow::propagateValue().

◆ join()

LatticeJoinEffect clang::dataflow::Environment::join ( const Environment Other,
Environment::ValueModel Model 
)

Joins the environment with Other 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 the environment and Other are merged using Model.

Requirements:

Other and this must use the same DataflowAnalysisContext.

Definition at line 538 of file DataflowEnvironment.cpp.

References clang::dataflow::areEquivalentValues(), clang::dataflow::Changed, clang::dataflow::StorageLocation::getType(), clang::dataflow::intersectDenseMaps(), clang::dataflow::DataflowAnalysisContext::joinFlowConditions(), clang::dataflow::mergeDistinctValues(), and clang::dataflow::Unchanged.

◆ makeAnd()

BoolValue & clang::dataflow::Environment::makeAnd ( BoolValue LHS,
BoolValue RHS 
) const
inline

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 471 of file DataflowEnvironment.h.

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

Referenced by clang::dataflow::mergeDistinctValues(), and clang::dataflow::unpackValue().

◆ makeAtomicBoolValue()

BoolValue & clang::dataflow::Environment::makeAtomicBoolValue ( ) const
inline

◆ makeIff()

BoolValue & clang::dataflow::Environment::makeIff ( BoolValue LHS,
BoolValue RHS 
) const
inline

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 501 of file DataflowEnvironment.h.

References clang::dataflow::DataflowAnalysisContext::arena(), and clang::dataflow::Arena::makeEquals().

Referenced by clang::dataflow::evaluateBooleanEquality(), clang::dataflow::mergeDistinctValues(), and clang::dataflow::unpackValue().

◆ makeImplication()

BoolValue & clang::dataflow::Environment::makeImplication ( BoolValue LHS,
BoolValue RHS 
) const
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 493 of file DataflowEnvironment.h.

References clang::dataflow::DataflowAnalysisContext::arena(), and clang::dataflow::Arena::makeImplies().

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

◆ makeNot()

BoolValue & clang::dataflow::Environment::makeNot ( BoolValue Val) const
inline

Returns a boolean value that represents the negation of Val.

Subsequent calls with the same argument will return the same result.

Definition at line 485 of file DataflowEnvironment.h.

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

Referenced by clang::dataflow::UncheckedOptionalAccessModel::merge(), and clang::dataflow::unpackValue().

◆ makeOr()

BoolValue & clang::dataflow::Environment::makeOr ( BoolValue LHS,
BoolValue RHS 
) const
inline

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 479 of file DataflowEnvironment.h.

References clang::dataflow::DataflowAnalysisContext::arena(), and clang::dataflow::Arena::makeOr().

Referenced by clang::dataflow::mergeDistinctValues(), and clang::dataflow::unpackValue().

◆ makeTopBoolValue()

BoolValue & clang::dataflow::Environment::makeTopBoolValue ( ) const
inline

◆ operator=() [1/2]

Environment & clang::dataflow::Environment::operator= ( const Environment Other)

Definition at line 277 of file DataflowEnvironment.cpp.

◆ operator=() [2/2]

Environment & clang::dataflow::Environment::operator= ( Environment &&  Other)
default

◆ popCall() [1/2]

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 402 of file DataflowEnvironment.cpp.

References setStorageLocationStrict(), and setValueStrict().

◆ popCall() [2/2]

void clang::dataflow::Environment::popCall ( const CXXConstructExpr Call,
const Environment CalleeEnv 
)

Definition at line 423 of file DataflowEnvironment.cpp.

References getValue(), and setValueStrict().

◆ pushCall() [1/2]

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 329 of file DataflowEnvironment.cpp.

References Env, getStorageLocation(), and clang::dataflow::Reference.

◆ pushCall() [2/2]

Environment clang::dataflow::Environment::pushCall ( const CXXConstructExpr Call) const

Definition at line 347 of file DataflowEnvironment.cpp.

References Env.

◆ setReturnStorageLocation()

void clang::dataflow::Environment::setReturnStorageLocation ( StorageLocation Loc)
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 367 of file DataflowEnvironment.h.

References getCurrentFunc().

◆ setReturnValue()

void clang::dataflow::Environment::setReturnValue ( Value Val)
inline

Sets the return value of the current function.

Requirements: The current function must have a non-reference return type.

Definition at line 356 of file DataflowEnvironment.h.

References getCurrentFunc().

◆ setStorageLocation() [1/2]

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

Assigns Loc as the storage location of E in the environment.

This function is deprecated; prefer setStorageLocationStrict(). For details, see https://discourse.llvm.org/t/70086.

Requirements:

E must not be assigned a storage location in the environment.

Definition at line 672 of file DataflowEnvironment.cpp.

References clang::dataflow::ignoreCFGOmittedNodes().

◆ setStorageLocation() [2/2]

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.

If D has reference type, Loc must refer directly to the referenced object (if any), not to a ReferenceValue, and it is not permitted to later change Loc to refer to a ReferenceValue.

Definition at line 654 of file DataflowEnvironment.cpp.

References getValue().

Referenced by Environment(), setStorageLocationStrict(), and setValueStrict().

◆ setStorageLocationStrict()

void clang::dataflow::Environment::setStorageLocationStrict ( const Expr E,
StorageLocation Loc 
)

Assigns Loc as the storage location of the glvalue E in the environment.

This function is the preferred alternative to setStorageLocation(const Expr &, StorageLocation &). Once the migration to strict handling of value categories is complete (see https://discourse.llvm.org/t/70086), setStorageLocation() will be removed and this function will be renamed to setStorageLocation().

Requirements:

E must not be assigned a storage location in the environment. E must be a glvalue or a BuiltinType::BuiltinFn

Definition at line 678 of file DataflowEnvironment.cpp.

References clang::Expr::getType(), clang::Expr::isGLValue(), clang::Type::isSpecificBuiltinType(), and setStorageLocation().

Referenced by popCall(), and clang::dataflow::propagateStorageLocation().

◆ setValue()

void clang::dataflow::Environment::setValue ( const StorageLocation Loc,
Value Val 
)

◆ setValueStrict()

void clang::dataflow::Environment::setValueStrict ( const Expr E,
Value Val 
)

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 Values, and the legacy behavior of associating prvalue expressions with storage locations (as described above) will be eliminated.

Requirements:

E must be a prvalue Val must not be a ReferenceValue

Definition at line 751 of file DataflowEnvironment.cpp.

References createStorageLocation(), getStorageLocation(), clang::Expr::isPRValue(), clang::dataflow::None, setStorageLocation(), and setValue().

Referenced by popCall(), and clang::dataflow::propagateValue().

◆ widen()

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 476 of file DataflowEnvironment.cpp.

References clang::dataflow::areEquivalentValues(), clang::dataflow::Changed, clang::dataflow::StorageLocation::getType(), clang::dataflow::Unchanged, and clang::dataflow::widenDistinctValues().

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


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