clang 20.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 CFGBlockblockForStmt (const Stmt &S) const
 Returns the basic block that contains S, or null if no basic block containing S is found.
 
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 47 of file AdornedCFG.h.

Member Function Documentation

◆ blockForStmt()

const CFGBlock * clang::dataflow::AdornedCFG::blockForStmt ( const Stmt S) const
inline

Returns the basic block that contains S, or null if no basic block containing S is found.

Definition at line 68 of file AdornedCFG.h.

References clang::dataflow::internal::StmtToBlockMap::lookup().

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

◆ 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 145 of file AdornedCFG.cpp.

References clang::CFG::buildCFG(), clang::dataflow::buildContainsExprConsumedInDifferentBlock(), clang::C, D, and clang::dataflow::findReachableBlocks().

◆ 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 136 of file AdornedCFG.cpp.

References build(), and clang::Func.

Referenced by build(), and 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 85 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 64 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 61 of file AdornedCFG.h.

◆ isBlockReachable()

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

Returns whether B is reachable from the entry block.

Definition at line 73 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: