clang 19.0.0git
Public Member Functions | Static Public Member Functions | List of all members
clang::dataflow::AdornedCFG Class Reference

Holds CFG with additional information derived from it that is needed to perform dataflow analysis. More...

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

Public Member Functions

const DeclgetDecl () const
 Returns the Decl containing the statement used to construct the CFG, if available.
 
const CFGgetCFG () const
 Returns the CFG that is stored in this context.
 
const llvm::DenseMap< const Stmt *, const CFGBlock * > & getStmtToBlock () const
 Returns a mapping from statements to basic blocks that contain them.
 
bool isBlockReachable (const CFGBlock &B) const
 Returns whether B is reachable from the entry block.
 
bool containsExprConsumedInDifferentBlock (const CFGBlock &B) const
 Returns whether B contains an expression that is consumed in a different block than B (i.e.
 

Static Public Member Functions

static llvm::Expected< AdornedCFGbuild (const FunctionDecl &Func)
 Builds an AdornedCFG from a FunctionDecl.
 
static llvm::Expected< AdornedCFGbuild (const Decl &D, Stmt &S, ASTContext &C)
 Builds an AdornedCFG from an AST node.
 

Detailed Description

Holds CFG with additional information derived from it that is needed to perform dataflow analysis.

Definition at line 32 of file AdornedCFG.h.

Member Function Documentation

◆ build() [1/2]

llvm::Expected< AdornedCFG > clang::dataflow::AdornedCFG::build ( const Decl D,
Stmt S,
ASTContext C 
)
static

Builds an AdornedCFG from an AST node.

D is the function in which S resides. D.isTemplated() must be false.

Definition at line 138 of file AdornedCFG.cpp.

References clang::dataflow::buildContainsExprConsumedInDifferentBlock(), clang::dataflow::buildStmtToBasicBlockMap(), clang::dataflow::findReachableBlocks(), and clang::Decl::isTemplated().

◆ build() [2/2]

llvm::Expected< AdornedCFG > clang::dataflow::AdornedCFG::build ( const FunctionDecl Func)
static

Builds an AdornedCFG from a FunctionDecl.

Func.doesThisDeclarationHaveABody() must be true, and Func.isTemplated() must be false.

Definition at line 129 of file AdornedCFG.cpp.

References clang::Func.

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

◆ containsExprConsumedInDifferentBlock()

bool clang::dataflow::AdornedCFG::containsExprConsumedInDifferentBlock ( const CFGBlock B) const
inline

Returns whether B contains an expression that is consumed in a different block than B (i.e.

the parent of the expression is in a different block). This happens if there is control flow within a full-expression (triggered by &&, ||, or the conditional operator). Note that the operands of these operators are not the only expressions that can be consumed in a different block. For example, in the function call f(&i, cond() ? 1 : 0), &i is in a different block than the CallExpr.

Definition at line 69 of file AdornedCFG.h.

◆ getCFG()

const CFG & clang::dataflow::AdornedCFG::getCFG ( ) const
inline

Returns the CFG that is stored in this context.

Definition at line 49 of file AdornedCFG.h.

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

◆ getDecl()

const Decl & clang::dataflow::AdornedCFG::getDecl ( ) const
inline

Returns the Decl containing the statement used to construct the CFG, if available.

Definition at line 46 of file AdornedCFG.h.

◆ getStmtToBlock()

const llvm::DenseMap< const Stmt *, const CFGBlock * > & clang::dataflow::AdornedCFG::getStmtToBlock ( ) const
inline

Returns a mapping from statements to basic blocks that contain them.

Definition at line 52 of file AdornedCFG.h.

Referenced by clang::dataflow::StmtToEnvMap::getEnvironment().

◆ isBlockReachable()

bool clang::dataflow::AdornedCFG::isBlockReachable ( const CFGBlock B) const
inline

Returns whether B is reachable from the entry block.

Definition at line 57 of file AdornedCFG.h.

References clang::CFGBlock::getBlockID().

Referenced by clang::dataflow::StmtToEnvMap::getEnvironment().


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