clang  6.0.0svn
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::CFGBlock Class Reference

CFGBlock - Represents a single basic block in a source-level CFG. More...

#include "clang/Analysis/CFG.h"

Classes

class  AdjacentBlock
 This class represents a potential adjacent block in the CFG. More...
 
class  FilteredCFGBlockIterator
 
class  FilterOptions
 

Public Types

typedef ElementList::iterator iterator
 
typedef ElementList::const_iterator const_iterator
 
typedef ElementList::reverse_iterator reverse_iterator
 
typedef ElementList::const_reverse_iterator const_reverse_iterator
 
typedef AdjacentBlocks::iterator pred_iterator
 
typedef AdjacentBlocks::const_iterator const_pred_iterator
 
typedef AdjacentBlocks::reverse_iterator pred_reverse_iterator
 
typedef AdjacentBlocks::const_reverse_iterator const_pred_reverse_iterator
 
typedef llvm::iterator_range< pred_iteratorpred_range
 
typedef llvm::iterator_range< const_pred_iteratorpred_const_range
 
typedef AdjacentBlocks::iterator succ_iterator
 
typedef AdjacentBlocks::const_iterator const_succ_iterator
 
typedef AdjacentBlocks::reverse_iterator succ_reverse_iterator
 
typedef AdjacentBlocks::const_reverse_iterator const_succ_reverse_iterator
 
typedef llvm::iterator_range< succ_iteratorsucc_range
 
typedef llvm::iterator_range< const_succ_iteratorsucc_const_range
 
typedef FilteredCFGBlockIterator< const_pred_iterator, truefiltered_pred_iterator
 
typedef FilteredCFGBlockIterator< const_succ_iterator, falsefiltered_succ_iterator
 

Public Member Functions

 CFGBlock (unsigned blockid, BumpVectorContext &C, CFG *parent)
 
CFGElement front () const
 
CFGElement back () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
unsigned size () const
 
bool empty () const
 
CFGElement operator[] (size_t i) const
 
pred_iterator pred_begin ()
 
pred_iterator pred_end ()
 
const_pred_iterator pred_begin () const
 
const_pred_iterator pred_end () const
 
pred_reverse_iterator pred_rbegin ()
 
pred_reverse_iterator pred_rend ()
 
const_pred_reverse_iterator pred_rbegin () const
 
const_pred_reverse_iterator pred_rend () const
 
pred_range preds ()
 
pred_const_range preds () const
 
succ_iterator succ_begin ()
 
succ_iterator succ_end ()
 
const_succ_iterator succ_begin () const
 
const_succ_iterator succ_end () const
 
succ_reverse_iterator succ_rbegin ()
 
succ_reverse_iterator succ_rend ()
 
const_succ_reverse_iterator succ_rbegin () const
 
const_succ_reverse_iterator succ_rend () const
 
succ_range succs ()
 
succ_const_range succs () const
 
unsigned succ_size () const
 
bool succ_empty () const
 
unsigned pred_size () const
 
bool pred_empty () const
 
filtered_pred_iterator filtered_pred_start_end (const FilterOptions &f) const
 
filtered_succ_iterator filtered_succ_start_end (const FilterOptions &f) const
 
void setTerminator (CFGTerminator Term)
 
void setLabel (Stmt *Statement)
 
void setLoopTarget (const Stmt *loopTarget)
 
void setHasNoReturnElement ()
 
CFGTerminator getTerminator ()
 
const CFGTerminator getTerminator () const
 
StmtgetTerminatorCondition (bool StripParens=true)
 
const StmtgetTerminatorCondition (bool StripParens=true) const
 
const StmtgetLoopTarget () const
 
StmtgetLabel ()
 
const StmtgetLabel () const
 
bool hasNoReturnElement () const
 
unsigned getBlockID () const
 
CFGgetParent () const
 
void dump () const
 
void dump (const CFG *cfg, const LangOptions &LO, bool ShowColors=false) const
 dump - A simply pretty printer of a CFGBlock that outputs to stderr. More...
 
void print (raw_ostream &OS, const CFG *cfg, const LangOptions &LO, bool ShowColors) const
 print - A simple pretty printer of a CFGBlock that outputs to an ostream. More...
 
void printTerminator (raw_ostream &OS, const LangOptions &LO) const
 printTerminator - A simple pretty printer of the terminator of a CFGBlock. More...
 
void printAsOperand (raw_ostream &OS, bool)
 
void addSuccessor (AdjacentBlock Succ, BumpVectorContext &C)
 Adds a (potentially unreachable) successor block to the current block. More...
 
void appendStmt (Stmt *statement, BumpVectorContext &C)
 
void appendInitializer (CXXCtorInitializer *initializer, BumpVectorContext &C)
 
void appendNewAllocator (CXXNewExpr *NE, BumpVectorContext &C)
 
void appendBaseDtor (const CXXBaseSpecifier *BS, BumpVectorContext &C)
 
void appendMemberDtor (FieldDecl *FD, BumpVectorContext &C)
 
void appendTemporaryDtor (CXXBindTemporaryExpr *E, BumpVectorContext &C)
 
void appendAutomaticObjDtor (VarDecl *VD, Stmt *S, BumpVectorContext &C)
 
void appendLifetimeEnds (VarDecl *VD, Stmt *S, BumpVectorContext &C)
 
void appendLoopExit (const Stmt *LoopStmt, BumpVectorContext &C)
 
void appendDeleteDtor (CXXRecordDecl *RD, CXXDeleteExpr *DE, BumpVectorContext &C)
 
iterator beginAutomaticObjDtorsInsert (iterator I, size_t Cnt, BumpVectorContext &C)
 
iterator insertAutomaticObjDtor (iterator I, VarDecl *VD, Stmt *S)
 
iterator beginLifetimeEndsInsert (iterator I, size_t Cnt, BumpVectorContext &C)
 
iterator insertLifetimeEnds (iterator I, VarDecl *VD, Stmt *S)
 

Static Public Member Functions

static bool FilterEdge (const FilterOptions &F, const CFGBlock *Src, const CFGBlock *Dst)
 

Detailed Description

CFGBlock - Represents a single basic block in a source-level CFG.

It consists of:

(1) A set of statements/expressions (which may contain subexpressions). (2) A "terminator" statement (not in the set of statements). (3) A list of successors and predecessors.

Terminator: The terminator represents the type of control-flow that occurs at the end of the basic block. The terminator is a Stmt* referring to an AST node that has control-flow: if-statements, breaks, loops, etc. If the control-flow is conditional, the condition expression will appear within the set of statements in the block (usually the last statement).

Predecessors: the order in the set of predecessors is arbitrary.

Successors: the order in the set of successors is NOT arbitrary. We currently have the following orderings based on the terminator:

Terminator Successor Ordering

if Then Block; Else Block ? operator LHS expression; RHS expression &&, || expression that uses result of && or ||, RHS

But note that any of that may be NULL in case of optimized-out edges.

Definition at line 401 of file CFG.h.

Member Typedef Documentation

◆ const_iterator

typedef ElementList::const_iterator clang::CFGBlock::const_iterator

Definition at line 546 of file CFG.h.

◆ const_pred_iterator

Definition at line 570 of file CFG.h.

◆ const_pred_reverse_iterator

Definition at line 572 of file CFG.h.

◆ const_reverse_iterator

Definition at line 548 of file CFG.h.

◆ const_succ_iterator

Definition at line 577 of file CFG.h.

◆ const_succ_reverse_iterator

Definition at line 579 of file CFG.h.

◆ filtered_pred_iterator

Definition at line 668 of file CFG.h.

◆ filtered_succ_iterator

Definition at line 671 of file CFG.h.

◆ iterator

typedef ElementList::iterator clang::CFGBlock::iterator

Definition at line 545 of file CFG.h.

◆ pred_const_range

Definition at line 574 of file CFG.h.

◆ pred_iterator

Definition at line 569 of file CFG.h.

◆ pred_range

typedef llvm::iterator_range<pred_iterator> clang::CFGBlock::pred_range

Definition at line 573 of file CFG.h.

◆ pred_reverse_iterator

Definition at line 571 of file CFG.h.

◆ reverse_iterator

Definition at line 547 of file CFG.h.

◆ succ_const_range

Definition at line 581 of file CFG.h.

◆ succ_iterator

Definition at line 576 of file CFG.h.

◆ succ_range

typedef llvm::iterator_range<succ_iterator> clang::CFGBlock::succ_range

Definition at line 580 of file CFG.h.

◆ succ_reverse_iterator

Definition at line 578 of file CFG.h.

Constructor & Destructor Documentation

◆ CFGBlock()

clang::CFGBlock::CFGBlock ( unsigned  blockid,
BumpVectorContext C,
CFG parent 
)
inlineexplicit

Definition at line 539 of file CFG.h.

Member Function Documentation

◆ addSuccessor()

void CFGBlock::addSuccessor ( AdjacentBlock  Succ,
BumpVectorContext C 
)

◆ appendAutomaticObjDtor()

void clang::CFGBlock::appendAutomaticObjDtor ( VarDecl VD,
Stmt S,
BumpVectorContext C 
)
inline

Definition at line 747 of file CFG.h.

◆ appendBaseDtor()

void clang::CFGBlock::appendBaseDtor ( const CXXBaseSpecifier BS,
BumpVectorContext C 
)
inline

Definition at line 735 of file CFG.h.

◆ appendDeleteDtor()

void clang::CFGBlock::appendDeleteDtor ( CXXRecordDecl RD,
CXXDeleteExpr DE,
BumpVectorContext C 
)
inline

Definition at line 759 of file CFG.h.

◆ appendInitializer()

void clang::CFGBlock::appendInitializer ( CXXCtorInitializer initializer,
BumpVectorContext C 
)
inline

Definition at line 725 of file CFG.h.

◆ appendLifetimeEnds()

void clang::CFGBlock::appendLifetimeEnds ( VarDecl VD,
Stmt S,
BumpVectorContext C 
)
inline

Definition at line 751 of file CFG.h.

◆ appendLoopExit()

void clang::CFGBlock::appendLoopExit ( const Stmt LoopStmt,
BumpVectorContext C 
)
inline

Definition at line 755 of file CFG.h.

◆ appendMemberDtor()

void clang::CFGBlock::appendMemberDtor ( FieldDecl FD,
BumpVectorContext C 
)
inline

Definition at line 739 of file CFG.h.

◆ appendNewAllocator()

void clang::CFGBlock::appendNewAllocator ( CXXNewExpr NE,
BumpVectorContext C 
)
inline

Definition at line 730 of file CFG.h.

◆ appendStmt()

void clang::CFGBlock::appendStmt ( Stmt statement,
BumpVectorContext C 
)
inline

Definition at line 721 of file CFG.h.

◆ appendTemporaryDtor()

void clang::CFGBlock::appendTemporaryDtor ( CXXBindTemporaryExpr E,
BumpVectorContext C 
)
inline

Definition at line 743 of file CFG.h.

◆ back()

CFGElement clang::CFGBlock::back ( ) const
inline

Definition at line 551 of file CFG.h.

Referenced by clang::CFG::back(), and neverReturns().

◆ begin() [1/2]

iterator clang::CFGBlock::begin ( )
inline

Definition at line 553 of file CFG.h.

Referenced by clang::LiveVariables::computeLiveness(), isImmediateSinkBlock(), and print_block().

◆ begin() [2/2]

const_iterator clang::CFGBlock::begin ( ) const
inline

Definition at line 555 of file CFG.h.

◆ beginAutomaticObjDtorsInsert()

iterator clang::CFGBlock::beginAutomaticObjDtorsInsert ( iterator  I,
size_t  Cnt,
BumpVectorContext C 
)
inline

Definition at line 766 of file CFG.h.

◆ beginLifetimeEndsInsert()

iterator clang::CFGBlock::beginLifetimeEndsInsert ( iterator  I,
size_t  Cnt,
BumpVectorContext C 
)
inline

Definition at line 779 of file CFG.h.

◆ dump() [1/2]

LLVM_DUMP_METHOD void CFGBlock::dump ( ) const

Definition at line 4856 of file CFG.cpp.

References getParent().

◆ dump() [2/2]

void CFGBlock::dump ( const CFG cfg,
const LangOptions LO,
bool  ShowColors = false 
) const

dump - A simply pretty printer of a CFGBlock that outputs to stderr.

Definition at line 4851 of file CFG.cpp.

References print().

◆ empty()

bool clang::CFGBlock::empty ( ) const
inline

◆ end() [1/2]

iterator clang::CFGBlock::end ( )
inline

Definition at line 554 of file CFG.h.

Referenced by clang::LiveVariables::computeLiveness(), isImmediateSinkBlock(), and print_block().

◆ end() [2/2]

const_iterator clang::CFGBlock::end ( ) const
inline

Definition at line 556 of file CFG.h.

◆ filtered_pred_start_end()

filtered_pred_iterator clang::CFGBlock::filtered_pred_start_end ( const FilterOptions f) const
inline

Definition at line 673 of file CFG.h.

◆ filtered_succ_start_end()

filtered_succ_iterator clang::CFGBlock::filtered_succ_start_end ( const FilterOptions f) const
inline

Definition at line 677 of file CFG.h.

◆ FilterEdge()

bool CFGBlock::FilterEdge ( const FilterOptions F,
const CFGBlock Src,
const CFGBlock Dst 
)
static

◆ front()

CFGElement clang::CFGBlock::front ( ) const
inline

Definition at line 550 of file CFG.h.

Referenced by clang::CFG::front(), and clang::BlockEntrance::getFirstElement().

◆ getBlockID()

unsigned clang::CFGBlock::getBlockID ( ) const
inline

◆ getLabel() [1/2]

Stmt* clang::CFGBlock::getLabel ( )
inline

Definition at line 699 of file CFG.h.

References Label.

Referenced by FilterEdge(), GenerateMinimalPathDiagnostic(), and print_block().

◆ getLabel() [2/2]

const Stmt* clang::CFGBlock::getLabel ( ) const
inline

Definition at line 700 of file CFG.h.

References Label.

◆ getLoopTarget()

const Stmt* clang::CFGBlock::getLoopTarget ( ) const
inline

Definition at line 697 of file CFG.h.

◆ getParent()

CFG* clang::CFGBlock::getParent ( ) const
inline

Definition at line 706 of file CFG.h.

References dump(), and Parent.

Referenced by dump().

◆ getTerminator() [1/2]

CFGTerminator clang::CFGBlock::getTerminator ( )
inline

◆ getTerminator() [2/2]

const CFGTerminator clang::CFGBlock::getTerminator ( ) const
inline

Definition at line 689 of file CFG.h.

References getTerminatorCondition().

◆ getTerminatorCondition() [1/2]

Stmt * CFGBlock::getTerminatorCondition ( bool  StripParens = true)

◆ getTerminatorCondition() [2/2]

const Stmt* clang::CFGBlock::getTerminatorCondition ( bool  StripParens = true) const
inline

Definition at line 693 of file CFG.h.

References getTerminatorCondition().

◆ hasNoReturnElement()

bool clang::CFGBlock::hasNoReturnElement ( ) const
inline

Definition at line 702 of file CFG.h.

Referenced by isImmediateSinkBlock(), neverReturns(), and print_block().

◆ insertAutomaticObjDtor()

iterator clang::CFGBlock::insertAutomaticObjDtor ( iterator  I,
VarDecl VD,
Stmt S 
)
inline

Definition at line 771 of file CFG.h.

◆ insertLifetimeEnds()

iterator clang::CFGBlock::insertLifetimeEnds ( iterator  I,
VarDecl VD,
Stmt S 
)
inline

Definition at line 784 of file CFG.h.

◆ operator[]()

CFGElement clang::CFGBlock::operator[] ( size_t  i) const
inline

Definition at line 566 of file CFG.h.

◆ pred_begin() [1/2]

pred_iterator clang::CFGBlock::pred_begin ( )
inline

◆ pred_begin() [2/2]

const_pred_iterator clang::CFGBlock::pred_begin ( ) const
inline

Definition at line 585 of file CFG.h.

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

◆ pred_empty()

bool clang::CFGBlock::pred_empty ( ) const
inline

Definition at line 621 of file CFG.h.

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

Referenced by checkRecursiveFunction(), and checkThrowInNonThrowingFunc().

◆ pred_end() [1/2]

pred_iterator clang::CFGBlock::pred_end ( )
inline

◆ pred_end() [2/2]

const_pred_iterator clang::CFGBlock::pred_end ( ) const
inline

Definition at line 586 of file CFG.h.

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

◆ pred_rbegin() [1/2]

pred_reverse_iterator clang::CFGBlock::pred_rbegin ( )
inline

Definition at line 588 of file CFG.h.

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

◆ pred_rbegin() [2/2]

const_pred_reverse_iterator clang::CFGBlock::pred_rbegin ( ) const
inline

Definition at line 590 of file CFG.h.

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

◆ pred_rend() [1/2]

pred_reverse_iterator clang::CFGBlock::pred_rend ( )
inline

Definition at line 589 of file CFG.h.

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

◆ pred_rend() [2/2]

const_pred_reverse_iterator clang::CFGBlock::pred_rend ( ) const
inline

Definition at line 591 of file CFG.h.

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

◆ pred_size()

unsigned clang::CFGBlock::pred_size ( ) const
inline

◆ preds() [1/2]

pred_range clang::CFGBlock::preds ( )
inline

Definition at line 593 of file CFG.h.

◆ preds() [2/2]

pred_const_range clang::CFGBlock::preds ( ) const
inline

Definition at line 596 of file CFG.h.

◆ print()

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

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

Generally this will only be called from CFG::print.

Definition at line 4862 of file CFG.cpp.

References print_block().

Referenced by dump(), and clang::CFG::dump().

◆ printAsOperand()

void clang::CFGBlock::printAsOperand ( raw_ostream &  OS,
bool   
)
inline

Definition at line 714 of file CFG.h.

◆ printTerminator()

void CFGBlock::printTerminator ( raw_ostream &  OS,
const LangOptions LO 
) const

printTerminator - A simple pretty printer of the terminator of a CFGBlock.

Definition at line 4870 of file CFG.cpp.

References getTerminator().

◆ rbegin() [1/2]

reverse_iterator clang::CFGBlock::rbegin ( )
inline

Definition at line 558 of file CFG.h.

Referenced by getLastStmtLoc(), and clang::ento::ExprEngine::VisitLogicalExpr().

◆ rbegin() [2/2]

const_reverse_iterator clang::CFGBlock::rbegin ( ) const
inline

Definition at line 560 of file CFG.h.

◆ rend() [1/2]

reverse_iterator clang::CFGBlock::rend ( )
inline

Definition at line 559 of file CFG.h.

Referenced by getLastStmtLoc().

◆ rend() [2/2]

const_reverse_iterator clang::CFGBlock::rend ( ) const
inline

Definition at line 561 of file CFG.h.

◆ setHasNoReturnElement()

void clang::CFGBlock::setHasNoReturnElement ( )
inline

Definition at line 686 of file CFG.h.

◆ setLabel()

void clang::CFGBlock::setLabel ( Stmt Statement)
inline

Definition at line 684 of file CFG.h.

References clang::CFGElement::Statement.

◆ setLoopTarget()

void clang::CFGBlock::setLoopTarget ( const Stmt loopTarget)
inline

Definition at line 685 of file CFG.h.

◆ setTerminator()

void clang::CFGBlock::setTerminator ( CFGTerminator  Term)
inline

Definition at line 683 of file CFG.h.

◆ size()

unsigned clang::CFGBlock::size ( ) const
inline

Definition at line 563 of file CFG.h.

Referenced by canHaveDirectConstructor().

◆ succ_begin() [1/2]

succ_iterator clang::CFGBlock::succ_begin ( )
inline

◆ succ_begin() [2/2]

const_succ_iterator clang::CFGBlock::succ_begin ( ) const
inline

Definition at line 602 of file CFG.h.

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

◆ succ_empty()

bool clang::CFGBlock::succ_empty ( ) const
inline

Definition at line 618 of file CFG.h.

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

◆ succ_end() [1/2]

succ_iterator clang::CFGBlock::succ_end ( )
inline

◆ succ_end() [2/2]

const_succ_iterator clang::CFGBlock::succ_end ( ) const
inline

Definition at line 603 of file CFG.h.

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

◆ succ_rbegin() [1/2]

succ_reverse_iterator clang::CFGBlock::succ_rbegin ( )
inline

◆ succ_rbegin() [2/2]

const_succ_reverse_iterator clang::CFGBlock::succ_rbegin ( ) const
inline

Definition at line 607 of file CFG.h.

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

◆ succ_rend() [1/2]

succ_reverse_iterator clang::CFGBlock::succ_rend ( )
inline

Definition at line 606 of file CFG.h.

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

Referenced by clang::ento::SwitchNodeBuilder::end().

◆ succ_rend() [2/2]

const_succ_reverse_iterator clang::CFGBlock::succ_rend ( ) const
inline

Definition at line 608 of file CFG.h.

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

◆ succ_size()

unsigned clang::CFGBlock::succ_size ( ) const
inline

◆ succs() [1/2]

succ_range clang::CFGBlock::succs ( )
inline

Definition at line 610 of file CFG.h.

Referenced by isInevitablySinking().

◆ succs() [2/2]

succ_const_range clang::CFGBlock::succs ( ) const
inline

Definition at line 613 of file CFG.h.


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