class DataflowAnalysisContext

Declaration

class DataflowAnalysisContext { /* full declaration omitted */ };

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:54

Member Variables

private std::unique_ptr<Solver> S
private std::vector<std::unique_ptr<StorageLocation>> Locs
private std::vector<std::unique_ptr<Value>> Vals
private llvm::DenseMap<const ValueDecl*, StorageLocation*> DeclToLoc
private llvm::DenseMap<const Expr*, StorageLocation*> ExprToLoc
private clang::dataflow::StorageLocation* ThisPointeeLoc = nullptr
private llvm::DenseMap<QualType, PointerValue*, NullableQualTypeDenseMapInfo> NullPointerVals
private clang::dataflow::AtomicBoolValue& TrueVal
private clang::dataflow::AtomicBoolValue& FalseVal
private llvm::DenseMap<std::pair<BoolValue*, BoolValue*>, ConjunctionValue*> ConjunctionVals
private llvm::DenseMap<std::pair<BoolValue*, BoolValue*>, DisjunctionValue*> DisjunctionVals
private llvm::DenseMap<BoolValue*, NegationValue*> NegationVals
private llvm::DenseMap<std::pair<BoolValue*, BoolValue*>, ImplicationValue*> ImplicationVals
private llvm::DenseMap<std::pair<BoolValue*, BoolValue*>, BiconditionalValue*> BiconditionalVals
private llvm::DenseMap<AtomicBoolValue*, llvm::DenseSet<AtomicBoolValue*>> FlowConditionDeps
private llvm::DenseMap<AtomicBoolValue*, BoolValue*> FlowConditionConstraints

Method Overview

Methods

DataflowAnalysisContext(std::unique_ptr<Solver> S)

Description

Constructs a dataflow analysis context. Requirements: `S` must not be null.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:61

Parameters

std::unique_ptr<Solver> S

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

Description

Adds `Constraint` to the flow condition identified by `Token`.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:208

Parameters

clang::dataflow::AtomicBoolValue& Token
clang::dataflow::BoolValue& Constraint

void addTransitiveFlowConditionConstraints(
    clang::dataflow::AtomicBoolValue& Token,
    llvm::DenseSet<BoolValue*>& Constraints,
    llvm::DenseSet<AtomicBoolValue*>&
        VisitedTokens)

Description

Adds all constraints of the flow condition identified by `Token` and all of its transitive dependencies to `Constraints`. `VisitedTokens` is used to track tokens of flow conditions that were already visited by recursive calls.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:273

Parameters

clang::dataflow::AtomicBoolValue& Token
llvm::DenseSet<BoolValue*>& Constraints
llvm::DenseSet<AtomicBoolValue*>& VisitedTokens

clang::dataflow::BoolValue&
buildAndSubstituteFlowCondition(
    clang::dataflow::AtomicBoolValue& Token,
    llvm::DenseMap<AtomicBoolValue*, BoolValue*>
        Substitutions)

Description

Builds and returns the logical formula defining the flow condition identified by `Token`. If a value in the formula is present as a key in `Substitutions`, it will be substituted with the value it maps to. As an example, say we have flow condition tokens FC1, FC2, FC3 and FlowConditionConstraints: { FC1: C1, FC2: C2, FC3: (FC1 v FC2) ^ C3 } buildAndSubstituteFlowCondition(FC3, {{C1 -> C1'}}) will return a value corresponding to (C1' v C2) ^ C3.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:238

Parameters

clang::dataflow::AtomicBoolValue& Token
llvm::DenseMap<AtomicBoolValue*, BoolValue*> Substitutions

clang::dataflow::BoolValue&
buildAndSubstituteFlowConditionWithCache(
    clang::dataflow::AtomicBoolValue& Token,
    llvm::DenseMap<BoolValue*, BoolValue*>&
        SubstitutionsCache)

Description

Builds and returns the logical formula defining the flow condition identified by `Token`, sub values may be substituted based on entries in `SubstitutionsCache`. Intermediate results are stored in `SubstitutionsCache` to avoid reprocessing values that have already been visited.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:304

Parameters

clang::dataflow::AtomicBoolValue& Token
llvm::DenseMap<BoolValue*, BoolValue*>& SubstitutionsCache

clang::dataflow::AtomicBoolValue&
createAtomicBoolValue()

Description

Creates an atomic boolean value.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:169

void dumpFlowCondition(
    clang::dataflow::AtomicBoolValue& Token)

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:255

Parameters

clang::dataflow::AtomicBoolValue& Token

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

Description

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.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:253

Parameters

clang::dataflow::BoolValue& Val1
clang::dataflow::BoolValue& Val2

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

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:244

Parameters

clang::dataflow::AtomicBoolValue& Token
clang::dataflow::BoolValue& Val

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

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:248

Parameters

clang::dataflow::AtomicBoolValue& Token

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

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:213

Parameters

clang::dataflow::AtomicBoolValue& Token

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

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:164

Parameters

bool Value

clang::dataflow::BoolValue&
getOrCreateConjunction(
    clang::dataflow::BoolValue& LHS,
    clang::dataflow::BoolValue& RHS)

Description

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.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:177

Parameters

clang::dataflow::BoolValue& LHS
clang::dataflow::BoolValue& RHS

clang::dataflow::BoolValue&
getOrCreateDisjunction(
    clang::dataflow::BoolValue& LHS,
    clang::dataflow::BoolValue& RHS)

Description

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.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:183

Parameters

clang::dataflow::BoolValue& LHS
clang::dataflow::BoolValue& RHS

clang::dataflow::BoolValue& getOrCreateIff(
    clang::dataflow::BoolValue& LHS,
    clang::dataflow::BoolValue& RHS)

Description

Returns a boolean value that 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.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:199

Parameters

clang::dataflow::BoolValue& LHS
clang::dataflow::BoolValue& RHS

clang::dataflow::BoolValue&
getOrCreateImplication(
    clang::dataflow::BoolValue& LHS,
    clang::dataflow::BoolValue& RHS)

Description

Returns a boolean value that 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.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:193

Parameters

clang::dataflow::BoolValue& LHS
clang::dataflow::BoolValue& RHS

clang::dataflow::BoolValue& getOrCreateNegation(
    clang::dataflow::BoolValue& Val)

Description

Returns a boolean value that represents the negation of `Val`. Subsequent calls with the same argument will return the same result.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:187

Parameters

clang::dataflow::BoolValue& Val

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

Description

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`.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:160

Parameters

clang::QualType PointeeType

clang::dataflow::StorageLocation&
getStableStorageLocation(clang::QualType Type)

Description

Returns a stable storage location appropriate for `Type`. Requirements: `Type` must not be null.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:98

Parameters

clang::QualType Type

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

Description

Returns a stable storage location for `E`.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:104

Parameters

const clang::Expr& E

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

Description

Returns a stable storage location for `D`.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:101

Parameters

const clang::VarDecl& D

clang::dataflow::StorageLocation*
getStorageLocation(const clang::Expr& E) const

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:136

Parameters

const clang::Expr& E

clang::dataflow::StorageLocation*
getStorageLocation(
    const clang::ValueDecl& D) const

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:118

Parameters

const clang::ValueDecl& D

clang::dataflow::StorageLocation*
getThisPointeeStorageLocation() const

Description

Returns the storage location assigned to the `this` pointee or null if the `this` pointee has no assigned storage location.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:153

bool isUnsatisfiable(
    llvm::DenseSet<BoolValue*> Constraints)

Description

Returns true if the solver is able to prove that there is no satisfying assignment for `Constraints`

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:286

Parameters

llvm::DenseSet<BoolValue*> Constraints

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

Description

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

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:218

Parameters

clang::dataflow::AtomicBoolValue& FirstToken
clang::dataflow::AtomicBoolValue& SecondToken

clang::dataflow::AtomicBoolValue&
makeFlowConditionToken()

Description

Creates a fresh flow condition and returns a token that identifies it. The token can be used to perform various operations on the flow condition such as adding constraints to it, forking it, joining it with another flow condition, or checking implications.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:205

Solver::Result querySolver(
    llvm::DenseSet<BoolValue*> Constraints)

Description

Returns the outcome of satisfiability checking on `Constraints`. Possible outcomes are: - `Satisfiable`: A satisfying assignment exists and is returned. - `Unsatisfiable`: A satisfying assignment does not exist. - `TimedOut`: The search for a satisfying assignment was not completed.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:282

Parameters

llvm::DenseSet<BoolValue*> Constraints

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

Description

Assigns `Loc` as the storage location of `E`. Requirements: `E` must not be assigned a storage location.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:128

Parameters

const clang::Expr& E
clang::dataflow::StorageLocation& Loc

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

Description

Assigns `Loc` as the storage location of `D`. Requirements: `D` must not be assigned a storage location.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:111

Parameters

const clang::ValueDecl& D
clang::dataflow::StorageLocation& Loc

void setThisPointeeStorageLocation(
    clang::dataflow::StorageLocation& Loc)

Description

Assigns `Loc` as the storage location of the `this` pointee. Requirements: The `this` pointee must not be assigned a storage location.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:146

Parameters

clang::dataflow::StorageLocation& Loc

clang::dataflow::BoolValue& substituteBoolValue(
    clang::dataflow::BoolValue& Val,
    llvm::DenseMap<BoolValue*, BoolValue*>&
        SubstitutionsCache)

Description

Returns a boolean value as a result of substituting `Val` and its sub values based on entries in `SubstitutionsCache`. Intermediate results are stored in `SubstitutionsCache` to avoid reprocessing values that have already been visited.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:295

Parameters

clang::dataflow::BoolValue& Val
llvm::DenseMap<BoolValue*, BoolValue*>& SubstitutionsCache

template <typename T>
typename std::enable_if<
    std::is_base_of<StorageLocation, T>::value,
    T&>::type
takeOwnership(std::unique_ptr<T> Loc)

Description

Takes ownership of `Loc` and returns a reference to it. Requirements: `Loc` must not be null.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:74

Templates

T

Parameters

std::unique_ptr<T> Loc

template <typename T>
typename std::enable_if<
    std::is_base_of<Value, T>::value,
    T&>::type
takeOwnership(std::unique_ptr<T> Val)

Description

Takes ownership of `Val` and returns a reference to it. Requirements: `Val` must not be null.

Declared at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:87

Templates

T

Parameters

std::unique_ptr<T> Val