clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions
clang::CFG Class Reference

#include <CFG.h>

List of all members.

Classes

class  BuildOptions
class  const_graph_iterator
class  graph_iterator
 Provides a custom implementation of the iterator class to have the same interface as Function::iterator - iterator returns CFGBlock (not a pointer to CFGBlock). More...

Public Types

typedef BumpVector< CFGBlock * > CFGBlockListTy
typedef CFGBlockListTy::iterator iterator
typedef
CFGBlockListTy::const_iterator 
const_iterator
typedef std::reverse_iterator
< iterator
reverse_iterator
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
typedef std::vector< const
CFGBlock * >::const_iterator 
try_block_iterator
typedef llvm::DenseMap< const
DeclStmt *, const DeclStmt * >
::const_iterator 
synthetic_stmt_iterator

Public Member Functions

CFGBlockcreateBlock ()
void setEntry (CFGBlock *B)
void setIndirectGotoBlock (CFGBlock *B)
CFGBlockfront ()
CFGBlockback ()
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
graph_iterator nodes_begin ()
graph_iterator nodes_end ()
const_graph_iterator nodes_begin () const
const_graph_iterator nodes_end () const
reverse_iterator rbegin ()
reverse_iterator rend ()
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
CFGBlockgetEntry ()
const CFGBlockgetEntry () const
CFGBlockgetExit ()
const CFGBlockgetExit () const
CFGBlockgetIndirectGotoBlock ()
const CFGBlockgetIndirectGotoBlock () const
try_block_iterator try_blocks_begin () const
try_block_iterator try_blocks_end () const
void addTryDispatchBlock (const CFGBlock *block)
void addSyntheticDeclStmt (const DeclStmt *Synthetic, const DeclStmt *Source)
synthetic_stmt_iterator synthetic_stmt_begin () const
synthetic_stmt_iterator synthetic_stmt_end () const
template<typename CALLBACK >
void VisitBlockStmts (CALLBACK &O) const
unsigned getNumBlockIDs () const
unsigned size () const
void viewCFG (const LangOptions &LO) const
void print (raw_ostream &OS, const LangOptions &LO, bool ShowColors) const
 print - A simple pretty printer of a CFG that outputs to an ostream.
void dump (const LangOptions &LO, bool ShowColors) const
 dump - A simple pretty printer of a CFG that outputs to stderr.
 CFG ()
llvm::BumpPtrAllocator & getAllocator ()
BumpVectorContextgetBumpVectorContext ()

Static Public Member Functions

static std::unique_ptr< CFGbuildCFG (const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO)
 buildCFG - Builds a CFG from an AST.

Detailed Description

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

Definition at line 723 of file CFG.h.


Member Typedef Documentation

Definition at line 835 of file CFG.h.

Definition at line 837 of file CFG.h.

typedef std::reverse_iterator<const_iterator> clang::CFG::const_reverse_iterator

Definition at line 839 of file CFG.h.

Definition at line 836 of file CFG.h.

typedef std::reverse_iterator<iterator> clang::CFG::reverse_iterator

Definition at line 838 of file CFG.h.

typedef llvm::DenseMap<const DeclStmt *, const DeclStmt *>::const_iterator clang::CFG::synthetic_stmt_iterator

Definition at line 896 of file CFG.h.

Definition at line 871 of file CFG.h.


Constructor & Destructor Documentation

clang::CFG::CFG ( ) [inline]

Definition at line 951 of file CFG.h.


Member Function Documentation

void clang::CFG::addSyntheticDeclStmt ( const DeclStmt Synthetic,
const DeclStmt Source 
) [inline]

Records a synthetic DeclStmt and the DeclStmt it was constructed from.

The CFG uses synthetic DeclStmts when a single AST DeclStmt contains multiple decls.

Definition at line 887 of file CFG.h.

References clang::DeclStmt::isSingleDecl().

void clang::CFG::addTryDispatchBlock ( const CFGBlock block) [inline]

Definition at line 879 of file CFG.h.

CFGBlock& clang::CFG::back ( ) [inline]

Definition at line 842 of file CFG.h.

References clang::BumpVector< T >::back().

Referenced by createBlock().

const_iterator clang::CFG::begin ( ) const [inline]

Definition at line 846 of file CFG.h.

References clang::BumpVector< T >::begin().

std::unique_ptr< CFG > CFG::buildCFG ( const Decl D,
Stmt AST,
ASTContext C,
const BuildOptions BO 
) [static]

buildCFG - Builds a CFG from an AST.

buildCFG - Constructs a CFG from an AST.

Definition at line 3779 of file CFG.cpp.

References Builder.

Referenced by clang::AnalysisDeclContext::getCFG(), and clang::AnalysisDeclContext::getUnoptimizedCFG().

createBlock - Create a new block in the CFG. The CFG owns the block; the caller should not directly free it.

createBlock - Constructs and adds a new CFGBlock to the CFG. The block has no successors or predecessors. If this is the first block created in the CFG, it is automatically set to be the Entry and Exit of the CFG.

Definition at line 3762 of file CFG.cpp.

References back(), begin(), end(), getAllocator(), and clang::BumpVector< T >::push_back().

void CFG::dump ( const LangOptions LO,
bool  ShowColors 
) const

dump - A simple pretty printer of a CFG that outputs to stderr.

Definition at line 4408 of file CFG.cpp.

References clang::CFGBlock::print().

Referenced by clang::AnalysisDeclContext::dumpCFG().

iterator clang::CFG::end ( ) [inline]
const_iterator clang::CFG::end ( ) const [inline]

Definition at line 847 of file CFG.h.

References clang::BumpVector< T >::end().

CFGBlock& clang::CFG::front ( ) [inline]

Definition at line 841 of file CFG.h.

References clang::BumpVector< T >::front().

llvm::BumpPtrAllocator& clang::CFG::getAllocator ( ) [inline]

Definition at line 955 of file CFG.h.

References clang::BumpVectorContext::getAllocator().

Referenced by createBlock().

Definition at line 959 of file CFG.h.

const CFGBlock& clang::CFG::getEntry ( ) const [inline]

Definition at line 864 of file CFG.h.

const CFGBlock& clang::CFG::getExit ( ) const [inline]

Definition at line 866 of file CFG.h.

Definition at line 868 of file CFG.h.

Referenced by print_block().

const CFGBlock* clang::CFG::getIndirectGotoBlock ( ) const [inline]

Definition at line 869 of file CFG.h.

Definition at line 851 of file CFG.h.

References clang::BumpVector< T >::begin().

Definition at line 854 of file CFG.h.

References clang::BumpVector< T >::end().

void CFG::print ( raw_ostream &  OS,
const LangOptions LO,
bool  ShowColors 
) const

print - A simple pretty printer of a CFG that outputs to an ostream.

Definition at line 4413 of file CFG.cpp.

References print_block().

Definition at line 858 of file CFG.h.

References clang::BumpVector< T >::rbegin().

Referenced by DiagnoseSwitchLabelsFallthrough().

Definition at line 860 of file CFG.h.

References clang::BumpVector< T >::rbegin().

Definition at line 859 of file CFG.h.

References clang::BumpVector< T >::rend().

Referenced by DiagnoseSwitchLabelsFallthrough().

Definition at line 861 of file CFG.h.

References clang::BumpVector< T >::rend().

void clang::CFG::setEntry ( CFGBlock B) [inline]

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

Definition at line 825 of file CFG.h.

setIndirectGotoBlock - Set the block used for indirect goto jumps. This is typically used only during CFG construction.

Definition at line 829 of file CFG.h.

unsigned clang::CFG::size ( ) const [inline]

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

Definition at line 937 of file CFG.h.

Referenced by llvm::GraphTraits< ::clang::CFG * >::size().

Iterates over synthetic DeclStmts in the CFG.

Each element is a (synthetic statement, source statement) pair.

See also:
addSyntheticDeclStmt

Definition at line 903 of file CFG.h.

Referenced by addParentsForSyntheticStmts().

See also:
synthetic_stmt_begin

Definition at line 908 of file CFG.h.

Referenced by addParentsForSyntheticStmts().

Definition at line 872 of file CFG.h.

Referenced by clang::reachable_code::FindUnreachableCode().

Definition at line 875 of file CFG.h.

Referenced by clang::reachable_code::FindUnreachableCode().

void CFG::viewCFG ( const LangOptions LO) const

Definition at line 4534 of file CFG.cpp.

template<typename CALLBACK >
void clang::CFG::VisitBlockStmts ( CALLBACK &  O) const [inline]

Definition at line 917 of file CFG.h.

References begin(), end(), and clang::ast_matchers::stmt.

Referenced by clang::runUninitializedVariablesAnalysis().


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