clang
10.0.0git
|
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 |
Static Public Member Functions | |
static bool | FilterEdge (const FilterOptions &F, const CFGBlock *Src, const CFGBlock *Dst) |
Public Attributes | |
ElementList | Elements |
The set of statements in the basic block. More... | |
Stmt * | Label = nullptr |
An (optional) label that prefixes the executable statements in the block. More... | |
CFGTerminator | Terminator |
The terminator for a basic block that indicates the type of control-flow that occurs between a block and its successors. More... | |
const Stmt * | LoopTarget = nullptr |
Some blocks are used to represent the "loop edge" to the start of a loop from within the loop body. More... | |
unsigned | BlockID |
A numerical ID assigned to a CFGBlock during construction of the CFG. More... | |
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.
using clang::CFGBlock::CFGElementRef = ElementRefImpl<false> |
using clang::CFGBlock::const_iterator = ElementList::const_iterator |
using clang::CFGBlock::const_ref_iterator = ElementRefIterator<false, true> |
using clang::CFGBlock::const_ref_iterator_range = llvm::iterator_range<const_ref_iterator> |
using clang::CFGBlock::const_reverse_ref_iterator = ElementRefIterator<true, true> |
using clang::CFGBlock::const_reverse_ref_iterator_range = llvm::iterator_range<const_reverse_ref_iterator> |
using clang::CFGBlock::ConstCFGElementRef = ElementRefImpl<true> |
using clang::CFGBlock::iterator = ElementList::iterator |
using clang::CFGBlock::pred_const_range = llvm::iterator_range<const_pred_iterator> |
using clang::CFGBlock::pred_range = llvm::iterator_range<pred_iterator> |
using clang::CFGBlock::ref_iterator = ElementRefIterator<false, false> |
using clang::CFGBlock::ref_iterator_range = llvm::iterator_range<ref_iterator> |
using clang::CFGBlock::reverse_ref_iterator = ElementRefIterator<true, false> |
using clang::CFGBlock::reverse_ref_iterator_range = llvm::iterator_range<reverse_ref_iterator> |
using clang::CFGBlock::succ_const_range = llvm::iterator_range<const_succ_iterator> |
using clang::CFGBlock::succ_range = llvm::iterator_range<succ_iterator> |
|
inlineexplicit |
void CFGBlock::addSuccessor | ( | AdjacentBlock | Succ, |
BumpVectorContext & | C | ||
) |
Adds a (potentially unreachable) successor block to the current block.
Definition at line 5055 of file CFG.cpp.
References clang::CFGBlock::AdjacentBlock::getPossiblyUnreachableBlock(), clang::CFGBlock::AdjacentBlock::getReachableBlock(), and clang::CFGBlock::AdjacentBlock::isReachable().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 874 of file CFG.h.
Referenced by clang::CFG::back(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), and neverReturns().
|
inline |
Definition at line 876 of file CFG.h.
Referenced by Accumulate(), clang::LiveVariables::computeLiveness(), isImmediateSinkBlock(), and print_block().
|
inline |
|
inline |
|
inline |
|
inline |
LLVM_DUMP_METHOD void CFGBlock::dump | ( | ) | const |
Definition at line 5806 of file CFG.cpp.
References getParent().
void CFGBlock::dump | ( | const CFG * | cfg, |
const LangOptions & | LO, | ||
bool | ShowColors = false |
||
) | const |
|
inline |
Definition at line 919 of file CFG.h.
Referenced by clang::ento::CoreEngine::ExecuteWorkList(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), clang::BlockEntrance::getFirstElement(), clang::ento::WorkList::makeUnexploredFirstPriorityQueue(), neverReturns(), clang::ento::ExprEngine::processCallEnter(), and clang::ento::ExprEngine::VisitLogicalExpr().
|
inline |
Definition at line 877 of file CFG.h.
Referenced by Accumulate(), clang::LiveVariables::computeLiveness(), isImmediateSinkBlock(), and print_block().
|
inline |
|
inline |
|
inline |
|
static |
Definition at line 5066 of file CFG.cpp.
References clang::CFG::begin(), clang::CFG::end(), clang::IfStmt::getCond(), clang::SwitchStmt::getCond(), clang::WhileStmt::getCond(), clang::DoStmt::getCond(), clang::ForStmt::getCond(), clang::AbstractConditionalOperator::getCond(), clang::ChooseExpr::getCond(), clang::ForStmt::getInc(), clang::ForStmt::getInit(), clang::CFGTerminator::getKind(), getLabel(), clang::BinaryOperator::getLHS(), clang::NamedDecl::getName(), clang::BinaryOperator::getOpcode(), clang::DeclStmt::getSingleDecl(), clang::CFGTerminator::getStmt(), clang::Stmt::getStmtClass(), clang::IndirectGotoStmt::getTarget(), getTerminatorStmt(), clang::CFGBlock::FilterOptions::IgnoreDefaultsWithCoveredEnums, clang::CFGBlock::FilterOptions::IgnoreNullPredecessors, clang::PrintingPolicy::IncludeNewlines, clang::BinaryOperator::isLogicalOp(), P, print(), clang::Stmt::printPretty(), clang::ast_matchers::stmt, clang::CFGTerminator::StmtBranch, clang::CFGTerminator::TemporaryDtorsBranch, and clang::CFGTerminator::VirtualBaseBranch.
|
inline |
Definition at line 873 of file CFG.h.
Referenced by clang::CFG::front(), and clang::BlockEntrance::getFirstElement().
|
inline |
Definition at line 1075 of file CFG.h.
Referenced by clang::consumed::ConsumedBlockInfo::addInfo(), clang::consumed::ConsumedBlockInfo::allBackEdgesVisited(), clang::PostOrderCFGView::CFGBlockSet::alreadySet(), clang::ento::NodeBuilderContext::blockCount(), clang::consumed::ConsumedBlockInfo::borrowInfo(), CheckFallThrough(), checkForRecursiveFunctionCall(), clang::LiveVariables::computeLiveness(), clang::consumed::ConsumedBlockInfo::discardInfo(), clang::LiveVariables::dumpBlockLiveness(), clang::ento::CoreEngine::ExecuteWorkList(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), clang::reachable_code::FindUnreachableCode(), clang::ento::CheckerContext::getBlockID(), clang::consumed::ConsumedBlockInfo::getInfo(), getStaticBooleanValue(), clang::PostOrderCFGView::CFGBlockSet::insert(), isAlwaysUninit(), clang::consumed::ConsumedBlockInfo::isBackEdge(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), clang::CFGReverseBlockReachabilityAnalysis::isReachable(), clang::threadSafety::SExprBuilder::lookupBlock(), print_block(), runOnBlock(), clang::runUninitializedVariablesAnalysis(), scanFromBlock(), and SrcCmp().
size_t CFGBlock::getIndexInCFG | ( | ) | const |
Definition at line 5796 of file CFG.cpp.
References clang::CFG::begin(), and getParent().
|
inline |
Definition at line 1070 of file CFG.h.
References Label.
Referenced by Accumulate(), FilterEdge(), getEnclosingStmtLocation(), and print_block().
|
inline |
const Expr * CFGBlock::getLastCondition | ( | ) | const |
rbegin()
) 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()
would retrieve the entire condition, rather than C itself, while this method would only return C. Definition at line 5902 of file CFG.cpp.
References clang::CFGElement::getAs(), rbegin(), size(), clang::CFGTerminator::StmtBranch, and succ_size().
|
inline |
Definition at line 1077 of file CFG.h.
References clang::CFGElement::dump(), Parent, and print().
Referenced by dump(), getIndexInCFG(), and isInevitablySinking().
|
inline |
Definition at line 1049 of file CFG.h.
Referenced by clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), clang::ento::SwitchNodeBuilder::getSwitch(), clang::consumed::ConsumedStateMap::operator!=(), print_block(), printTerminator(), ResolveCondition(), and clang::ento::ExprEngine::VisitLogicalExpr().
Definition at line 5930 of file CFG.cpp.
References clang::Stmt::getStmtClass(), getTerminatorStmt(), clang::Expr::IgnoreParens(), and Terminator.
Referenced by getStaticBooleanValue(), getTerminatorCondition(), and shouldTreatSuccessorsAsReachable().
Definition at line 1064 of file CFG.h.
References getTerminatorCondition().
|
inline |
Definition at line 1051 of file CFG.h.
References clang::CFGTerminator::getStmt().
Referenced by Accumulate(), CheckFallThrough(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), FilterEdge(), getLastStmtLoc(), getLocationRegionIfReference(), getStaticBooleanValue(), getTerminatorCondition(), clang::ento::ExprEngine::processCFGBlockEntrance(), shouldTreatSuccessorsAsReachable(), and writeShouldKill().
|
inline |
Definition at line 1052 of file CFG.h.
References clang::CFGTerminator::getStmt(), and getTerminatorCondition().
|
inline |
Definition at line 1073 of file CFG.h.
Referenced by CheckFallThrough(), isImmediateSinkBlock(), neverReturns(), and print_block().
bool CFGBlock::isInevitablySinking | ( | ) | const |
Returns true if the block would eventually end with a sink (a noreturn node).
Definition at line 5864 of file CFG.cpp.
References clang::CFG::getExit(), getParent(), isImmediateSinkBlock(), and succs().
|
inline |
|
inline |
Definition at line 938 of file CFG.h.
References clang::BumpVector< T >::begin().
Referenced by clang::consumed::ConsumedBlockInfo::allBackEdgesVisited(), llvm::GraphTraits< Inverse< ::clang::CFGBlock * > >::child_begin(), llvm::GraphTraits< Inverse< const ::clang::CFGBlock * > >::child_begin(), getLastStmtLoc(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), clang::CFGReverseBlockReachabilityAnalysis::isReachable(), print_block(), and runOnBlock().
|
inline |
Definition at line 940 of file CFG.h.
References clang::BumpVector< T >::begin().
|
inline |
Definition at line 978 of file CFG.h.
References clang::BumpVector< T >::empty().
Referenced by checkRecursiveFunction(), checkThrowInNonThrowingFunc(), and print_block().
|
inline |
Definition at line 939 of file CFG.h.
References clang::BumpVector< T >::end().
Referenced by clang::consumed::ConsumedBlockInfo::allBackEdgesVisited(), llvm::GraphTraits< Inverse< ::clang::CFGBlock * > >::child_end(), llvm::GraphTraits< Inverse< const ::clang::CFGBlock * > >::child_end(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), clang::CFGReverseBlockReachabilityAnalysis::isReachable(), print_block(), and runOnBlock().
|
inline |
Definition at line 941 of file CFG.h.
References clang::BumpVector< T >::end().
|
inline |
Definition at line 943 of file CFG.h.
References clang::BumpVector< T >::rbegin().
|
inline |
Definition at line 945 of file CFG.h.
References clang::BumpVector< T >::rbegin().
|
inline |
Definition at line 944 of file CFG.h.
References clang::BumpVector< T >::rend().
|
inline |
Definition at line 946 of file CFG.h.
References clang::BumpVector< T >::rend().
|
inline |
Definition at line 977 of file CFG.h.
References clang::BumpVector< T >::size().
Referenced by getLastStmtLoc(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), and print_block().
|
inline |
|
inline |
|
inline |
|
inline |
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 5812 of file CFG.cpp.
References print_block().
Referenced by dump(), clang::CFG::dump(), and FilterEdge().
|
inline |
void CFGBlock::printTerminator | ( | raw_ostream & | OS, |
const LangOptions & | LO | ||
) | const |
printTerminator - A simple pretty printer of the terminator of a CFGBlock.
Definition at line 5820 of file CFG.cpp.
References getTerminator().
Referenced by printTerminatorJson().
void CFGBlock::printTerminatorJson | ( | raw_ostream & | Out, |
const LangOptions & | LO, | ||
bool | AddQuotes | ||
) | const |
printTerminatorJson - Pretty-prints the terminator in JSON format.
Definition at line 5827 of file CFG.cpp.
References clang::JsonFormat(), and printTerminator().
|
inline |
Definition at line 881 of file CFG.h.
Referenced by CheckFallThrough(), getLastCondition(), getLastStmtLoc(), ResolveCondition(), clang::ento::ExprEngine::VisitLogicalExpr(), and writeShouldKill().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 882 of file CFG.h.
Referenced by CheckFallThrough(), getLastStmtLoc(), ResolveCondition(), and writeShouldKill().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 1041 of file CFG.h.
References clang::CFGElement::Statement.
Referenced by shouldAddCase().
|
inline |
|
inline |
|
inline |
Definition at line 918 of file CFG.h.
Referenced by clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), clang::ento::CallEvent::getCalleeStackFrame(), and getLastCondition().
|
inline |
Definition at line 956 of file CFG.h.
References clang::BumpVector< T >::begin().
Referenced by clang::ento::IndirectGotoNodeBuilder::begin(), CheckFallThrough(), checkForRecursiveFunctionCall(), llvm::GraphTraits< ::clang::CFGBlock * >::child_begin(), llvm::GraphTraits< const ::clang::CFGBlock * >::child_begin(), ClassifyDiagnostic(), clang::LiveVariables::computeLiveness(), clang::ento::CoreEngine::ExecuteWorkList(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), getLastStmtLoc(), getLocationRegionIfReference(), isAlwaysUninit(), isJumpToFalseBranch(), clang::consumed::ConsumedStateMap::operator!=(), print_block(), clang::ento::ExprEngine::processCallEnter(), scanFromBlock(), and clang::ento::ExprEngine::VisitLogicalExpr().
|
inline |
Definition at line 958 of file CFG.h.
References clang::BumpVector< T >::begin().
|
inline |
Definition at line 975 of file CFG.h.
References clang::BumpVector< T >::empty().
Referenced by print_block().
|
inline |
Definition at line 957 of file CFG.h.
References clang::BumpVector< T >::end().
Referenced by CheckFallThrough(), checkForRecursiveFunctionCall(), llvm::GraphTraits< ::clang::CFGBlock * >::child_end(), llvm::GraphTraits< const ::clang::CFGBlock * >::child_end(), ClassifyDiagnostic(), clang::LiveVariables::computeLiveness(), clang::ento::IndirectGotoNodeBuilder::end(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), isAlwaysUninit(), print_block(), and scanFromBlock().
|
inline |
Definition at line 959 of file CFG.h.
References clang::BumpVector< T >::end().
|
inline |
Definition at line 961 of file CFG.h.
References clang::BumpVector< T >::rbegin().
Referenced by clang::ento::SwitchNodeBuilder::begin(), and clang::ento::SwitchNodeBuilder::generateDefaultCaseNode().
|
inline |
Definition at line 963 of file CFG.h.
References clang::BumpVector< T >::rbegin().
|
inline |
Definition at line 962 of file CFG.h.
References clang::BumpVector< T >::rend().
Referenced by clang::ento::SwitchNodeBuilder::end().
|
inline |
Definition at line 964 of file CFG.h.
References clang::BumpVector< T >::rend().
|
inline |
Definition at line 974 of file CFG.h.
References clang::BumpVector< T >::size().
Referenced by clang::ento::CoreEngine::ExecuteWorkList(), clang::ento::CoreEngine::ExecuteWorkListWithInitialState(), getLastCondition(), getLastStmtLoc(), isJumpToFalseBranch(), print_block(), clang::ento::ExprEngine::processCallEnter(), and clang::ento::ExprEngine::VisitLogicalExpr().
|
inline |
Definition at line 966 of file CFG.h.
Referenced by isInevitablySinking(), and clang::CFG::isLinear().
|
inline |
unsigned clang::CFGBlock::BlockID |
ElementList clang::CFGBlock::Elements |
Stmt* clang::CFGBlock::Label = nullptr |
An (optional) label that prefixes the executable statements in the block.
When this variable is non-NULL, it is either an instance of LabelStmt, SwitchCase or CXXCatchStmt.
Definition at line 772 of file CFG.h.
Referenced by print_block().
const Stmt* clang::CFGBlock::LoopTarget = nullptr |
CFGTerminator clang::CFGBlock::Terminator |
The terminator for a basic block that indicates the type of control-flow that occurs between a block and its successors.
Definition at line 776 of file CFG.h.
Referenced by getTerminatorCondition().