class CFG
Declaration
class CFG { /* full declaration omitted */ };
Description
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt. The Stmt can represent an entire function body, or a single expression. A CFG will always contain one empty block that represents the Exit point of the CFG. A CFG will also contain a designated Entry block. The CFG solely represents control-flow; it consists of CFGBlocks which are simply containers of Stmt*'s in the AST the CFG was constructed from.
Declared at: clang/include/clang/Analysis/CFG.h:1226
Member Variables
- private clang::CFGBlock* Entry = nullptr
- private clang::CFGBlock* Exit = nullptr
- private clang::CFGBlock* IndirectGotoBlock = nullptr
- private unsigned int NumBlockIDs = 0
- private clang::BumpVectorContext BlkBVC
- private clang::CFG::CFGBlockListTy Blocks
- private std::vector<const CFGBlock*> TryDispatchBlocks
- C++ 'try' statements are modeled with an indirect dispatch block. This is the collection of such blocks present in the CFG.
- private llvm::DenseMap<const DeclStmt*, const DeclStmt*> SyntheticDeclStmts
- Collects DeclStmts synthesized for this CFG and maps each one back to its source DeclStmt.
Method Overview
- public CFG()
- public template <typename Callback>void VisitBlockStmts(Callback & O) const
- public void addSyntheticDeclStmt(const clang::DeclStmt * Synthetic, const clang::DeclStmt * Source)
- public void addTryDispatchBlock(const clang::CFGBlock * block)
- public clang::CFGBlock & back()
- public clang::CFG::iterator begin()
- public clang::CFG::const_iterator begin() const
- public static std::unique_ptr<CFG> buildCFG(const clang::Decl * D, clang::Stmt * AST, clang::ASTContext * C, const clang::CFG::BuildOptions & BO)
- public llvm::iterator_range<const_iterator> const_nodes() const
- public llvm::iterator_range<const_reverse_iterator> const_reverse_nodes() const
- public clang::CFGBlock * createBlock()
- public void dump(const clang::LangOptions & LO, bool ShowColors) const
- public clang::CFG::iterator end()
- public clang::CFG::const_iterator end() const
- public clang::CFGBlock & front()
- public llvm::BumpPtrAllocator & getAllocator()
- public clang::BumpVectorContext & getBumpVectorContext()
- public clang::CFGBlock & getEntry()
- public const clang::CFGBlock & getEntry() const
- public const clang::CFGBlock & getExit() const
- public clang::CFGBlock & getExit()
- public const clang::CFGBlock * getIndirectGotoBlock() const
- public clang::CFGBlock * getIndirectGotoBlock()
- public unsigned int getNumBlockIDs() const
- public bool isLinear() const
- public llvm::iterator_range<iterator> nodes()
- public clang::CFG::const_iterator nodes_begin() const
- public clang::CFG::iterator nodes_begin()
- public clang::CFG::iterator nodes_end()
- public clang::CFG::const_iterator nodes_end() const
- public void print(llvm::raw_ostream & OS, const clang::LangOptions & LO, bool ShowColors) const
- public clang::CFG::const_reverse_iterator rbegin() const
- public clang::CFG::reverse_iterator rbegin()
- public clang::CFG::const_reverse_iterator rend() const
- public clang::CFG::reverse_iterator rend()
- public llvm::iterator_range<reverse_iterator> reverse_nodes()
- public void setEntry(clang::CFGBlock * B)
- public void setIndirectGotoBlock(clang::CFGBlock * B)
- public unsigned int size() const
- public clang::CFG::synthetic_stmt_iterator synthetic_stmt_begin() const
- public clang::CFG::synthetic_stmt_iterator synthetic_stmt_end() const
- public clang::CFG::synthetic_stmt_range synthetic_stmts() const
- public clang::CFG::try_block_range try_blocks() const
- public clang::CFG::try_block_iterator try_blocks_begin() const
- public clang::CFG::try_block_iterator try_blocks_end() const
- public void viewCFG(const clang::LangOptions & LO) const
Methods
¶CFG()
CFG()
Declared at: clang/include/clang/Analysis/CFG.h:1437
¶template <typename Callback>
void VisitBlockStmts(Callback& O) const
template <typename Callback>
void VisitBlockStmts(Callback& O) const
Declared at: clang/include/clang/Analysis/CFG.h:1398
Templates
- Callback
Parameters
- Callback& O
¶void addSyntheticDeclStmt(
const clang::DeclStmt* Synthetic,
const clang::DeclStmt* Source)
void addSyntheticDeclStmt(
const clang::DeclStmt* Synthetic,
const clang::DeclStmt* Source)
Description
Records a synthetic DeclStmt and the DeclStmt it was constructed from. The CFG uses synthetic DeclStmts when a single AST DeclStmt contains multiple decls.
Declared at: clang/include/clang/Analysis/CFG.h:1363
Parameters
- const clang::DeclStmt* Synthetic
- const clang::DeclStmt* Source
¶void addTryDispatchBlock(
const clang::CFGBlock* block)
void addTryDispatchBlock(
const clang::CFGBlock* block)
Declared at: clang/include/clang/Analysis/CFG.h:1355
Parameters
- const clang::CFGBlock* block
¶clang::CFGBlock& back()
clang::CFGBlock& back()
Declared at: clang/include/clang/Analysis/CFG.h:1302
¶clang::CFG::iterator begin()
clang::CFG::iterator begin()
Declared at: clang/include/clang/Analysis/CFG.h:1304
¶clang::CFG::const_iterator begin() const
clang::CFG::const_iterator begin() const
Declared at: clang/include/clang/Analysis/CFG.h:1306
¶static std::unique_ptr<CFG> buildCFG(
const clang::Decl* D,
clang::Stmt* AST,
clang::ASTContext* C,
const clang::CFG::BuildOptions& BO)
static std::unique_ptr<CFG> buildCFG(
const clang::Decl* D,
clang::Stmt* AST,
clang::ASTContext* C,
const clang::CFG::BuildOptions& BO)
Description
Builds a CFG from an AST.
Declared at: clang/include/clang/Analysis/CFG.h:1275
Parameters
- const clang::Decl* D
- clang::Stmt* AST
- clang::ASTContext* C
- const clang::CFG::BuildOptions& BO
¶llvm::iterator_range<const_iterator> const_nodes()
const
llvm::iterator_range<const_iterator> const_nodes()
const
Declared at: clang/include/clang/Analysis/CFG.h:1313
¶llvm::iterator_range<const_reverse_iterator>
const_reverse_nodes() const
llvm::iterator_range<const_reverse_iterator>
const_reverse_nodes() const
Declared at: clang/include/clang/Analysis/CFG.h:1328
¶clang::CFGBlock* createBlock()
clang::CFGBlock* createBlock()
Description
Create a new block in the CFG. The CFG owns the block; the caller should not directly free it.
Declared at: clang/include/clang/Analysis/CFG.h:1280
¶void dump(const clang::LangOptions& LO,
bool ShowColors) const
void dump(const clang::LangOptions& LO,
bool ShowColors) const
Declared at: clang/include/clang/Analysis/CFG.h:1431
Parameters
- const clang::LangOptions& LO
- bool ShowColors
¶clang::CFG::iterator end()
clang::CFG::iterator end()
Declared at: clang/include/clang/Analysis/CFG.h:1305
¶clang::CFG::const_iterator end() const
clang::CFG::const_iterator end() const
Declared at: clang/include/clang/Analysis/CFG.h:1307
¶clang::CFGBlock& front()
clang::CFGBlock& front()
Declared at: clang/include/clang/Analysis/CFG.h:1301
¶llvm::BumpPtrAllocator& getAllocator()
llvm::BumpPtrAllocator& getAllocator()
Declared at: clang/include/clang/Analysis/CFG.h:1439
¶clang::BumpVectorContext& getBumpVectorContext()
clang::BumpVectorContext& getBumpVectorContext()
Declared at: clang/include/clang/Analysis/CFG.h:1443
¶clang::CFGBlock& getEntry()
clang::CFGBlock& getEntry()
Declared at: clang/include/clang/Analysis/CFG.h:1332
¶const clang::CFGBlock& getEntry() const
const clang::CFGBlock& getEntry() const
Declared at: clang/include/clang/Analysis/CFG.h:1333
¶const clang::CFGBlock& getExit() const
const clang::CFGBlock& getExit() const
Declared at: clang/include/clang/Analysis/CFG.h:1335
¶clang::CFGBlock& getExit()
clang::CFGBlock& getExit()
Declared at: clang/include/clang/Analysis/CFG.h:1334
¶const clang::CFGBlock* getIndirectGotoBlock()
const
const clang::CFGBlock* getIndirectGotoBlock()
const
Declared at: clang/include/clang/Analysis/CFG.h:1338
¶clang::CFGBlock* getIndirectGotoBlock()
clang::CFGBlock* getIndirectGotoBlock()
Declared at: clang/include/clang/Analysis/CFG.h:1337
¶unsigned int getNumBlockIDs() const
unsigned int getNumBlockIDs() const
Description
Returns the total number of BlockIDs allocated (which start at 0).
Declared at: clang/include/clang/Analysis/CFG.h:1412
¶bool isLinear() const
bool isLinear() const
Description
Returns true if the CFG has no branches. Usually it boils down to the CFG having exactly three blocks (entry, the actual code, exit), but sometimes more blocks appear due to having control flow that can be fully resolved in compile time.
Declared at: clang/include/clang/Analysis/CFG.h:1423
¶llvm::iterator_range<iterator> nodes()
llvm::iterator_range<iterator> nodes()
Declared at: clang/include/clang/Analysis/CFG.h:1312
¶clang::CFG::const_iterator nodes_begin() const
clang::CFG::const_iterator nodes_begin() const
Declared at: clang/include/clang/Analysis/CFG.h:1317
¶clang::CFG::iterator nodes_begin()
clang::CFG::iterator nodes_begin()
Declared at: clang/include/clang/Analysis/CFG.h:1309
¶clang::CFG::iterator nodes_end()
clang::CFG::iterator nodes_end()
Declared at: clang/include/clang/Analysis/CFG.h:1310
¶clang::CFG::const_iterator nodes_end() const
clang::CFG::const_iterator nodes_end() const
Declared at: clang/include/clang/Analysis/CFG.h:1318
¶void print(llvm::raw_ostream& OS,
const clang::LangOptions& LO,
bool ShowColors) const
void print(llvm::raw_ostream& OS,
const clang::LangOptions& LO,
bool ShowColors) const
Declared at: clang/include/clang/Analysis/CFG.h:1430
Parameters
- llvm::raw_ostream& OS
- const clang::LangOptions& LO
- bool ShowColors
¶clang::CFG::const_reverse_iterator rbegin() const
clang::CFG::const_reverse_iterator rbegin() const
Declared at: clang/include/clang/Analysis/CFG.h:1322
¶clang::CFG::reverse_iterator rbegin()
clang::CFG::reverse_iterator rbegin()
Declared at: clang/include/clang/Analysis/CFG.h:1320
¶clang::CFG::const_reverse_iterator rend() const
clang::CFG::const_reverse_iterator rend() const
Declared at: clang/include/clang/Analysis/CFG.h:1323
¶clang::CFG::reverse_iterator rend()
clang::CFG::reverse_iterator rend()
Declared at: clang/include/clang/Analysis/CFG.h:1321
¶llvm::iterator_range<reverse_iterator>
reverse_nodes()
llvm::iterator_range<reverse_iterator>
reverse_nodes()
Declared at: clang/include/clang/Analysis/CFG.h:1325
¶void setEntry(clang::CFGBlock* B)
void setEntry(clang::CFGBlock* B)
Description
Set the entry block of the CFG. This is typically used only during CFG construction. Most CFG clients expect that the entry block has no predecessors and contains no statements.
Declared at: clang/include/clang/Analysis/CFG.h:1285
Parameters
¶void setIndirectGotoBlock(clang::CFGBlock* B)
void setIndirectGotoBlock(clang::CFGBlock* B)
Description
Set the block used for indirect goto jumps. This is typically used only during CFG construction.
Declared at: clang/include/clang/Analysis/CFG.h:1289
Parameters
¶unsigned int size() const
unsigned int size() const
Description
Return the total number of CFGBlocks within the CFG This is simply a renaming of the getNumBlockIDs(). This is necessary because the dominator implementation needs such an interface.
Declared at: clang/include/clang/Analysis/CFG.h:1417
¶clang::CFG::synthetic_stmt_iterator
synthetic_stmt_begin() const
clang::CFG::synthetic_stmt_iterator
synthetic_stmt_begin() const
Description
Iterates over synthetic DeclStmts in the CFG. Each element is a (synthetic statement, source statement) pair.
Declared at: clang/include/clang/Analysis/CFG.h:1380
¶clang::CFG::synthetic_stmt_iterator
synthetic_stmt_end() const
clang::CFG::synthetic_stmt_iterator
synthetic_stmt_end() const
Declared at: clang/include/clang/Analysis/CFG.h:1385
¶clang::CFG::synthetic_stmt_range synthetic_stmts()
const
clang::CFG::synthetic_stmt_range synthetic_stmts()
const
Declared at: clang/include/clang/Analysis/CFG.h:1390
¶clang::CFG::try_block_range try_blocks() const
clang::CFG::try_block_range try_blocks() const
Declared at: clang/include/clang/Analysis/CFG.h:1351
¶clang::CFG::try_block_iterator try_blocks_begin()
const
clang::CFG::try_block_iterator try_blocks_begin()
const
Declared at: clang/include/clang/Analysis/CFG.h:1343
¶clang::CFG::try_block_iterator try_blocks_end()
const
clang::CFG::try_block_iterator try_blocks_end()
const
Declared at: clang/include/clang/Analysis/CFG.h:1347
¶void viewCFG(const clang::LangOptions& LO) const
void viewCFG(const clang::LangOptions& LO) const
Declared at: clang/include/clang/Analysis/CFG.h:1429
Parameters
- const clang::LangOptions& LO