clang: clang::CFGBlock Class Reference (original ) (raw )Represents a single basic block in a source-level CFG . More...
#include "[clang/Analysis/CFG.h](CFG%5F8h%5Fsource.html)"
Public Member Functions
CFGBlock (unsigned blockid, BumpVectorContext &C , CFG *parent)
size_t
getIndexInCFG () const
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
ref_iterator
ref_begin ()
ref_iterator
ref_end ()
const_ref_iterator
ref_begin () const
const_ref_iterator
ref_end () const
reverse_ref_iterator
rref_begin ()
reverse_ref_iterator
rref_end ()
const_reverse_ref_iterator
rref_begin () const
const_reverse_ref_iterator
rref_end () const
ref_iterator_range
refs ()
const_ref_iterator_range
refs () const
reverse_ref_iterator_range
rrefs ()
const_reverse_ref_iterator_range
rrefs () 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 ()
bool
isInevitablySinking () const
Returns true if the block would eventually end with a sink (a noreturn node).
CFGTerminator
getTerminator () const
Stmt *
getTerminatorStmt ()
const Stmt *
getTerminatorStmt () const
const Expr *
getLastCondition () const
Stmt *
getTerminatorCondition (bool StripParens=true )
const Stmt *
getTerminatorCondition (bool StripParens=true ) const
const Stmt *
getLoopTarget () const
Stmt *
getLabel ()
const Stmt *
getLabel () const
bool
hasNoReturnElement () const
unsigned
getBlockID () const
CFG *
getParent () 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.
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.
void
printTerminator (raw_ostream &OS, const LangOptions &LO) const
printTerminator - A simple pretty printer of the terminator of a CFGBlock .
void
printTerminatorJson (raw_ostream &Out, const LangOptions &LO, bool AddQuotes) const
printTerminatorJson - Pretty-prints the terminator in JSON format.
void
printAsOperand (raw_ostream &OS, bool )
void
addSuccessor (AdjacentBlock Succ, BumpVectorContext &C )
Adds a (potentially unreachable) successor block to the current block.
void
appendStmt (Stmt *statement, BumpVectorContext &C )
void
appendConstructor (CXXConstructExpr *CE, const ConstructionContext *CC, BumpVectorContext &C )
void
appendCXXRecordTypedCall (Expr *E, const ConstructionContext *CC, BumpVectorContext &C )
void
appendInitializer (CXXCtorInitializer *initializer, BumpVectorContext &C )
void
appendNewAllocator (CXXNewExpr *NE, BumpVectorContext &C )
void
appendScopeBegin (const VarDecl *VD, const Stmt *S, BumpVectorContext &C )
void
appendScopeEnd (const VarDecl *VD, const Stmt *S, 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
appendCleanupFunction (const VarDecl *VD, 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 )
Public Attributes
ElementList
Elements
The set of statements in the basic block.
Stmt *
Label = nullptr
An (optional) label that prefixes the executable statements in the block.
CFGTerminator
Terminator
The terminator for a basic block that indicates the type of control-flow that occurs between a block and its successors.
const Stmt *
LoopTarget = nullptr
Some blocks are used to represent the "loop edge" to the start of a loop from within the loop body.
unsigned
BlockID
A numerical ID assigned to a CFGBlock during construction of the CFG .
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
logical and/or
expression that consumes the op, RHS
vbase inits
already handled by the most derived class; not yet
But note that any of that may be NULL in case of optimized-out edges.
Definition at line 605 of file CFG.h .
◆ CFGElementRef◆ const_iteratorusing clang::CFGBlock::const_iterator = ElementList::const_iterator
Definition at line 901 of file CFG.h .
◆ const_pred_iterator◆ const_pred_reverse_iterator◆ const_ref_iterator◆ const_ref_iterator_range◆ const_reverse_iterator◆ const_reverse_ref_iterator◆ const_reverse_ref_iterator_rangeInitial value:
llvm::iterator_range<const_reverse_ref_iterator>
Definition at line 932 of file CFG.h .
◆ const_succ_iterator◆ const_succ_reverse_iterator◆ ConstCFGElementRef◆ filtered_pred_iteratorInitial value:
Definition at line 1060 of file CFG.h .
◆ filtered_succ_iteratorInitial value:
Definition at line 1063 of file CFG.h .
◆ iteratorusing clang::CFGBlock::iterator = ElementList::iterator
Definition at line 900 of file CFG.h .
◆ pred_const_rangeusing clang::CFGBlock::pred_const_range = llvm::iterator_range<const_pred_iterator >
Definition at line 963 of file CFG.h .
◆ pred_iterator◆ pred_rangeusing clang::CFGBlock::pred_range = llvm::iterator_range<pred_iterator >
Definition at line 962 of file CFG.h .
◆ pred_reverse_iterator◆ ref_iterator◆ ref_iterator_rangeusing clang::CFGBlock::ref_iterator_range = llvm::iterator_range<ref_iterator >
Definition at line 924 of file CFG.h .
◆ reverse_iterator◆ reverse_ref_iterator◆ reverse_ref_iterator_range◆ succ_const_rangeusing clang::CFGBlock::succ_const_range = llvm::iterator_range<const_succ_iterator >
Definition at line 970 of file CFG.h .
◆ succ_iterator◆ succ_rangeusing clang::CFGBlock::succ_range = llvm::iterator_range<succ_iterator >
Definition at line 969 of file CFG.h .
◆ succ_reverse_iteratorDefinition at line 895 of file CFG.h .
References BlockID , clang::C , Elements , false , clang::nullptr , and Terminator .
Referenced by addSuccessor() , clang::CFGBlock::AdjacentBlock::AdjacentBlock() , clang::CFGBlock::AdjacentBlock::AdjacentBlock() , clang::CFGBlock::FilteredCFGBlockIterator< const_pred_iterator, true >::FilteredCFGBlockIterator() , FilterEdge() , clang::CFGBlock::AdjacentBlock::getPossiblyUnreachableBlock() , clang::CFGBlock::AdjacentBlock::getReachableBlock() , getTerminatorCondition() , isInevitablySinking() , clang::CFGBlock::AdjacentBlock::operator CFGBlock *() , clang::CFGBlock::AdjacentBlock::operator*() , clang::CFGBlock::FilteredCFGBlockIterator< const_pred_iterator, true >::operator*() , and clang::CFGBlock::AdjacentBlock::operator->() .
◆ addSuccessor()◆ appendAutomaticObjDtor()◆ appendBaseDtor()◆ appendCleanupFunction()◆ appendConstructor()◆ appendCXXRecordTypedCall()◆ appendDeleteDtor()◆ appendInitializer()◆ appendLifetimeEnds()◆ appendLoopExit()◆ appendMemberDtor()◆ appendNewAllocator()◆ appendScopeBegin()◆ appendScopeEnd()◆ appendStmt()◆ appendTemporaryDtor()◆ back()◆ begin() [1/2]
iterator clang::CFGBlock::begin ( )
inline
◆ begin() [2/2]
◆ dump() [1/2]
LLVM_DUMP_METHOD void CFGBlock::dump
(
)
const
◆ dump() [2/2]◆ empty()
bool clang::CFGBlock::empty ( ) const
inline
◆ end() [1/2]
iterator clang::CFGBlock::end ( )
inline
◆ end() [2/2]
◆ filtered_pred_start_end()
◆ filtered_succ_start_end()
◆ FilterEdge()◆ front()
CFGElement clang::CFGBlock::front ( ) const
inline
◆ getBlockID()
unsigned clang::CFGBlock::getBlockID ( ) const
inline
Definition at line 1111 of file CFG.h .
References BlockID .
Referenced by clang::lifetimes::internal::FactManager::addBlockFacts() , clang::consumed::ConsumedBlockInfo::allBackEdgesVisited() , CheckFallThrough() , checkForRecursiveFunctionCall() , clang::LiveVariables::computeLiveness() , clang::DataflowWorklistBase< Comp, QueueSize >::dequeue() , clang::ento::CoreEngine::ExecuteWorkList() , clang::reachable_code::FindUnreachableCode() , clang::lifetimes::internal::FactManager::getFacts() , clang::internal::getID() , clang::consumed::ConsumedBlockInfo::isBackEdge() , clang::dataflow::AdornedCFG::isBlockReachable() , clang::CFGReverseBlockReachabilityAnalysis::isReachable() , clang::threadSafety::SExprBuilder::lookupBlock() , clang::WTOCompare::operator()() , print_block() , printAsOperand() , clang::ProgramPoint::printJson() , clang::ento::ExprEngine::runCheckersForBlockEntrance() , runOnBlock() , clang::dataflow::runTypeErasedDataflowAnalysis() , clang::runUninitializedVariablesAnalysis() , scanFromBlock() , and throwEscapes() .
◆ getIndexInCFG()
size_t CFGBlock::getIndexInCFG
(
)
const
◆ getLabel() [1/2]
Stmt * clang::CFGBlock::getLabel ( )
inline
◆ getLabel() [2/2]
const Stmt * clang::CFGBlock::getLabel ( ) const
inline
◆ getLastCondition()
const Expr * CFGBlock::getLastCondition
(
)
const
Returns
the last ([rbegin()](#a28d1c9e2bcd34217a4debc899ebb8a58)) condition, e.g. observe the following code snippet: if (A && B && C) A block would be created for A, B, and C. For the latter, [getTerminatorStmt()](#a9e91112f6a1a24d88a426593138b45bd) would retrieve the entire condition, rather than C itself, while this method would only return C.
Definition at line 6371 of file CFG.cpp .
References clang::cast() , clang::Cond , clang::CFGElement::getAs() , clang::isa() , rbegin() , size() , clang::CFGTerminator::StmtBranch , succ_size() , and Terminator .
◆ getLoopTarget()
const Stmt * clang::CFGBlock::getLoopTarget ( ) const
inline
◆ getParent()
CFG * clang::CFGBlock::getParent ( ) const
inline
◆ getTerminator()◆ getTerminatorCondition() [1/2]
Stmt * CFGBlock::getTerminatorCondition
(
bool
StripParens = true
)
◆ getTerminatorCondition() [2/2]
const Stmt * clang::CFGBlock::getTerminatorCondition ( bool StripParens = true ) const
inline
◆ getTerminatorStmt() [1/2]
Stmt * clang::CFGBlock::getTerminatorStmt ( )
inline
Definition at line 1087 of file CFG.h .
References Terminator .
Referenced by Accumulate() , CheckFallThrough() , DiagnoseSwitchLabelsFallthrough() , FilterEdge() , clang::BlockExit::getTerminator() , getTerminatorCondition() , isDeadReturn() , isTrivialDoWhile() , peelOffOuterExpr() , clang::ProgramPoint::printJson() , clang::ento::ExprEngine::processCFGBlockEntrance() , shouldTreatSuccessorsAsReachable() , clang::ento::SuppressInlineDefensiveChecksVisitor::VisitNode() , and clang::ento::ConditionBRVisitor::VisitNodeImpl() .
◆ getTerminatorStmt() [2/2]
const Stmt * clang::CFGBlock::getTerminatorStmt ( ) const
inline
◆ hasNoReturnElement()
bool clang::CFGBlock::hasNoReturnElement ( ) const
inline
◆ isInevitablySinking()
bool CFGBlock::isInevitablySinking
(
)
const
◆ operator[]()◆ pred_begin() [1/2]
◆ pred_begin() [2/2]
Definition at line 974 of file CFG.h .
◆ pred_empty()
bool clang::CFGBlock::pred_empty ( ) const
inline
◆ pred_end() [1/2]
◆ pred_end() [2/2]
Definition at line 975 of file CFG.h .
◆ pred_rbegin() [1/2]
Definition at line 977 of file CFG.h .
◆ pred_rbegin() [2/2]
Definition at line 979 of file CFG.h .
◆ pred_rend() [1/2]
Definition at line 978 of file CFG.h .
◆ pred_rend() [2/2]
Definition at line 980 of file CFG.h .
◆ pred_size()
unsigned clang::CFGBlock::pred_size ( ) const
inline
◆ preds() [1/2]
◆ preds() [2/2]
◆ print()
void CFGBlock::print
(
raw_ostream &
OS ,
const CFG *
cfg ,
const LangOptions &
LO ,
bool
ShowColors ) const
◆ printAsOperand()
void clang::CFGBlock::printAsOperand ( raw_ostream & OS , bool )
inline
◆ printTerminator()
void CFGBlock::printTerminator
(
raw_ostream &
OS ,
const LangOptions &
LO ) const
◆ printTerminatorJson()
void CFGBlock::printTerminatorJson
(
raw_ostream &
Out ,
const LangOptions &
LO ,
bool
AddQuotes ) const
◆ rbegin() [1/2]
◆ rbegin() [2/2]
◆ ref_begin() [1/2]
◆ ref_begin() [2/2]
◆ ref_end() [1/2]
◆ ref_end() [2/2]
◆ refs() [1/2]
◆ refs() [2/2]
◆ rend() [1/2]
◆ rend() [2/2]
◆ rref_begin() [1/2]
◆ rref_begin() [2/2]
◆ rref_end() [1/2]
◆ rref_end() [2/2]
◆ rrefs() [1/2]
◆ rrefs() [2/2]
◆ setHasNoReturnElement()
void clang::CFGBlock::setHasNoReturnElement ( )
inline
Definition at line 1079 of file CFG.h .
◆ setLabel()
void clang::CFGBlock::setLabel ( Stmt * Statement )
inline
◆ setLoopTarget()
void clang::CFGBlock::setLoopTarget ( const Stmt * loopTarget )
inline
◆ setTerminator()◆ size()
unsigned clang::CFGBlock::size ( ) const
inline
◆ succ_begin() [1/2]
Definition at line 990 of file CFG.h .
Referenced by clang::dataflow::blockIndexInPredecessor() , llvm::GraphTraits< ::clang::CFGBlock * >::child_begin() , llvm::GraphTraits< const ::clang::CFGBlock * >::child_begin() , DiagnoseSwitchLabelsFallthrough() , clang::ento::CoreEngine::ExecuteWorkList() , filtered_succ_start_end() , isAssertlikeBlock() , isDeadReturn() , isJumpToFalseBranch() , peelOffOuterExpr() , print_block() , clang::ento::ExprEngine::processCallEnter() , scanFromBlock() , succs() , succs() , clang::ento::ExprEngine::VisitLogicalExpr() , and clang::ento::ConditionBRVisitor::VisitTerminator() .
◆ succ_begin() [2/2]
Definition at line 992 of file CFG.h .
◆ succ_empty()
bool clang::CFGBlock::succ_empty ( ) const
inline
◆ succ_end() [1/2]
◆ succ_end() [2/2]
Definition at line 993 of file CFG.h .
◆ succ_rbegin() [1/2]
◆ succ_rbegin() [2/2]
Definition at line 997 of file CFG.h .
◆ succ_rend() [1/2]
Definition at line 996 of file CFG.h .
◆ succ_rend() [2/2]
Definition at line 998 of file CFG.h .
◆ succ_size()
unsigned clang::CFGBlock::succ_size ( ) const
inline
◆ succs() [1/2]
◆ succs() [2/2]
◆ BlockID◆ ElementsElementList clang::CFGBlock::Elements
The set of statements in the basic block.
Definition at line 800 of file CFG.h .
Referenced by appendAutomaticObjDtor() , appendBaseDtor() , appendCleanupFunction() , appendConstructor() , appendCXXRecordTypedCall() , appendDeleteDtor() , appendInitializer() , appendLifetimeEnds() , appendLoopExit() , appendMemberDtor() , appendNewAllocator() , appendScopeBegin() , appendScopeEnd() , appendStmt() , appendTemporaryDtor() , back() , begin() , begin() , CFGBlock() , empty() , end() , end() , front() , operator , rbegin() , rbegin() , rend() , rend() , and size() .
◆ Label◆ LoopTargetSome blocks are used to represent the "loop edge" to the start of a loop from within the loop body.
This Stmt* will be refer to the loop statement for such blocks (and be null otherwise).
Definition at line 814 of file CFG.h .
Referenced by getLoopTarget() , and setLoopTarget() .
◆ Terminator
The documentation for this class was generated from the following files: