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)"
Classes | |
---|---|
class | AdjacentBlock |
This class represents a potential adjacent block in the CFG. More... | |
class | FilteredCFGBlockIterator |
class | FilterOptions |
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 604 of file CFG.h.
◆ CFGElementRef
◆ const_iterator
◆ 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_range
◆ const_succ_iterator
◆ const_succ_reverse_iterator
◆ ConstCFGElementRef
◆ filtered_pred_iterator
◆ filtered_succ_iterator
◆ iterator
◆ pred_const_range
◆ pred_iterator
◆ pred_range
◆ pred_reverse_iterator
◆ ref_iterator
◆ ref_iterator_range
◆ reverse_iterator
◆ reverse_ref_iterator
◆ reverse_ref_iterator_range
◆ succ_const_range
◆ succ_iterator
◆ succ_range
◆ succ_reverse_iterator
◆ 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 1105 of file CFG.h.
References BlockID.
Referenced by clang::consumed::ConsumedBlockInfo::allBackEdgesVisited(), CheckFallThrough(), checkForRecursiveFunctionCall(), clang::LiveVariables::computeLiveness(), clang::DataflowWorklistBase< Comp, QueueSize >::dequeue(), clang::ento::CoreEngine::ExecuteWorkList(), clang::reachable_code::FindUnreachableCode(), clang::ento::CheckerContext::getBlockID(), clang::internal::getID(), clang::consumed::ConsumedBlockInfo::isBackEdge(), clang::dataflow::AdornedCFG::isBlockReachable(), clang::CFGReverseBlockReachabilityAnalysis::isReachable(), clang::threadSafety::SExprBuilder::lookupBlock(), clang::WTOCompare::operator()(), print_block(), printAsOperand(), 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()](classclang%5F1%5F1CFGBlock.html#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()](classclang%5F1%5F1CFGBlock.html#a9e91112f6a1a24d88a426593138b45bd)
would retrieve the entire condition, rather than C itself, while this method would only return C.
Definition at line 6242 of file CFG.cpp.
References clang::CFGElement::getAs(), clang::CFGTerminator::getKind(), clang::Expr::IgnoreParens(), 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 1081 of file CFG.h.
References clang::CFGTerminator::getStmt(), and Terminator.
Referenced by Accumulate(), CheckFallThrough(), DiagnoseSwitchLabelsFallthrough(), FilterEdge(), getLastStmtLoc(), clang::BlockExit::getTerminator(), getTerminatorCondition(), isTrivialDoWhile(), peelOffOuterExpr(), 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]
◆ pred_empty()
bool clang::CFGBlock::pred_empty ( ) const | inline |
---|
◆ pred_end() [1/2]
◆ pred_end() [2/2]
◆ pred_rbegin() [1/2]
◆ pred_rbegin() [2/2]
◆ pred_rend() [1/2]
◆ pred_rend() [2/2]
◆ 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 1073 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 984 of file CFG.h.
Referenced by clang::ento::IndirectGotoNodeBuilder::begin(), clang::dataflow::blockIndexInPredecessor(), checkForRecursiveFunctionCall(), llvm::GraphTraits< ::clang::CFGBlock * >::child_begin(), llvm::GraphTraits< const ::clang::CFGBlock * >::child_begin(), clang::LiveVariables::computeLiveness(), DiagnoseSwitchLabelsFallthrough(), clang::ento::CoreEngine::ExecuteWorkList(), filtered_succ_start_end(), getFirstStmtLoc(), getLastStmtLoc(), isAssertlikeBlock(), isJumpToFalseBranch(), peelOffOuterExpr(), print_block(), clang::ento::ExprEngine::processCallEnter(), scanFromBlock(), succs(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ConditionBRVisitor::VisitTerminator().
◆ succ_begin() [2/2]
◆ succ_empty()
bool clang::CFGBlock::succ_empty ( ) const | inline |
---|
◆ succ_end() [1/2]
◆ succ_end() [2/2]
◆ succ_rbegin() [1/2]
◆ succ_rbegin() [2/2]
◆ succ_rend() [1/2]
◆ succ_rend() [2/2]
◆ succ_size()
unsigned clang::CFGBlock::succ_size ( ) const | inline |
---|
Definition at line 1002 of file CFG.h.
Referenced by DiagnoseSwitchLabelsFallthrough(), clang::ento::CoreEngine::ExecuteWorkList(), getFirstStmtLoc(), getLastCondition(), getLastStmtLoc(), isAssertlikeBlock(), isJumpToFalseBranch(), print_block(), clang::ento::ExprEngine::processCallEnter(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ConditionBRVisitor::VisitTerminator().
◆ succs() [1/2]
◆ succs() [2/2]
◆ BlockID
◆ Elements
ElementList clang::CFGBlock::Elements
The set of statements in the basic block.
Definition at line 794 of file CFG.h.
Referenced by appendAutomaticObjDtor(), appendBaseDtor(), appendCleanupFunction(), appendConstructor(), appendCXXRecordTypedCall(), appendDeleteDtor(), appendInitializer(), appendLifetimeEnds(), appendLoopExit(), appendMemberDtor(), appendNewAllocator(), appendScopeBegin(), appendScopeEnd(), appendStmt(), appendTemporaryDtor(), back(), begin(), empty(), end(), front(), operator, rbegin(), rend(), and size().
◆ Label
Stmt* clang::CFGBlock::Label = nullptr
◆ LoopTarget
const Stmt* clang::CFGBlock::LoopTarget = nullptr
Some 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 808 of file CFG.h.
Referenced by getLoopTarget(), and setLoopTarget().
◆ Terminator
The documentation for this class was generated from the following files: