clang API Documentation
#include <CFG.h>
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.
typedef ElementList::const_iterator clang::CFGBlock::const_iterator |
typedef ElementList::iterator clang::CFGBlock::iterator |
clang::CFGBlock::CFGBlock | ( | unsigned | blockid, |
BumpVectorContext & | C, | ||
CFG * | parent | ||
) | [inline, explicit] |
clang::CFGBlock::~CFGBlock | ( | ) | [inline] |
void CFGBlock::addSuccessor | ( | AdjacentBlock | Succ, |
BumpVectorContext & | C | ||
) |
Adds a (potentially unreachable) successor block to the current block.
Definition at line 3848 of file CFG.cpp.
References clang::CFGBlock::AdjacentBlock::getPossiblyUnreachableBlock(), clang::CFGBlock::AdjacentBlock::getReachableBlock(), clang::CFGBlock::AdjacentBlock::isReachable(), and clang::BumpVector< T >::push_back().
void clang::CFGBlock::appendAutomaticObjDtor | ( | VarDecl * | VD, |
Stmt * | S, | ||
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendBaseDtor | ( | const CXXBaseSpecifier * | BS, |
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendDeleteDtor | ( | CXXRecordDecl * | RD, |
CXXDeleteExpr * | DE, | ||
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendInitializer | ( | CXXCtorInitializer * | initializer, |
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendMemberDtor | ( | FieldDecl * | FD, |
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendNewAllocator | ( | CXXNewExpr * | NE, |
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendStmt | ( | Stmt * | statement, |
BumpVectorContext & | C | ||
) | [inline] |
void clang::CFGBlock::appendTemporaryDtor | ( | CXXBindTemporaryExpr * | E, |
BumpVectorContext & | C | ||
) | [inline] |
CFGElement clang::CFGBlock::back | ( | ) | const [inline] |
Definition at line 505 of file CFG.h.
Referenced by clang::threadSafety::neverReturns().
iterator clang::CFGBlock::begin | ( | ) | [inline] |
Definition at line 507 of file CFG.h.
Referenced by Accumulate(), clang::LiveVariables::computeLiveness(), print_block(), and runOnBlock().
const_iterator clang::CFGBlock::begin | ( | ) | const [inline] |
iterator clang::CFGBlock::beginAutomaticObjDtorsInsert | ( | iterator | I, |
size_t | Cnt, | ||
BumpVectorContext & | C | ||
) | [inline] |
Definition at line 694 of file CFG.h.
References AttributeLangSupport::C.
void CFGBlock::dump | ( | ) | const |
Definition at line 4440 of file CFG.cpp.
References getParent().
void CFGBlock::dump | ( | const CFG * | cfg, |
const LangOptions & | LO, | ||
bool | ShowColors = false |
||
) | const |
bool clang::CFGBlock::empty | ( | ) | const [inline] |
Definition at line 518 of file CFG.h.
Referenced by DiagnoseSwitchLabelsFallthrough(), clang::ento::CoreEngine::ExecuteWorkList(), clang::BlockEntrance::getFirstElement(), clang::threadSafety::neverReturns(), clang::ento::ExprEngine::processCallEnter(), and clang::ento::ExprEngine::VisitLogicalExpr().
iterator clang::CFGBlock::end | ( | ) | [inline] |
Definition at line 508 of file CFG.h.
Referenced by Accumulate(), clang::LiveVariables::computeLiveness(), print_block(), and runOnBlock().
const_iterator clang::CFGBlock::end | ( | ) | const [inline] |
filtered_pred_iterator clang::CFGBlock::filtered_pred_start_end | ( | const FilterOptions & | f | ) | const [inline] |
Definition at line 609 of file CFG.h.
References pred_begin(), and pred_end().
filtered_succ_iterator clang::CFGBlock::filtered_succ_start_end | ( | const FilterOptions & | f | ) | const [inline] |
Definition at line 613 of file CFG.h.
References succ_begin(), and succ_end().
bool CFGBlock::FilterEdge | ( | const FilterOptions & | F, |
const CFGBlock * | Src, | ||
const CFGBlock * | Dst | ||
) | [static] |
Definition at line 3859 of file CFG.cpp.
References getLabel(), clang::CFGTerminator::getStmt(), getTerminator(), clang::CFGBlock::FilterOptions::IgnoreDefaultsWithCoveredEnums, and clang::CFGBlock::FilterOptions::IgnoreNullPredecessors.
CFGElement clang::CFGBlock::front | ( | ) | const [inline] |
Definition at line 504 of file CFG.h.
Referenced by clang::BlockEntrance::getFirstElement().
unsigned clang::CFGBlock::getBlockID | ( | ) | const [inline] |
Definition at line 640 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(), checkForFunctionCall(), checkRecursiveFunction(), clang::LiveVariables::computeLiveness(), clang::consumed::ConsumedBlockInfo::discardInfo(), clang::ento::CoreEngine::ExecuteWorkList(), clang::reachable_code::FindUnreachableCode(), clang::ento::CheckerContext::getBlockID(), clang::threadSafety::ThreadSafetyAnalyzer::getEdgeLockset(), clang::consumed::ConsumedBlockInfo::getInfo(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), clang::PostOrderCFGView::CFGBlockSet::insert(), clang::consumed::ConsumedBlockInfo::isBackEdge(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), clang::CFGReverseBlockReachabilityAnalysis::isReachable(), clang::threadSafety::SExprBuilder::lookupBlock(), print_block(), printAsOperand(), clang::threadSafety::ThreadSafetyAnalyzer::runAnalysis(), runOnBlock(), clang::runUninitializedVariablesAnalysis(), scanFromBlock(), and clang::threadSafety::LocalVariableMap::traverseCFG().
Stmt* clang::CFGBlock::getLabel | ( | ) | [inline] |
Definition at line 635 of file CFG.h.
Referenced by Accumulate(), DiagnoseSwitchLabelsFallthrough(), FilterEdge(), GenerateMinimalPathDiagnostic(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), and print_block().
const Stmt* clang::CFGBlock::getLabel | ( | ) | const [inline] |
const Stmt* clang::CFGBlock::getLoopTarget | ( | ) | const [inline] |
CFG* clang::CFGBlock::getParent | ( | ) | const [inline] |
CFGTerminator clang::CFGBlock::getTerminator | ( | ) | [inline] |
Definition at line 624 of file CFG.h.
Referenced by Accumulate(), CheckFallThrough(), DiagnoseSwitchLabelsFallthrough(), FilterEdge(), GenerateAlternateExtensivePathDiagnostic(), GenerateExtensivePathDiagnostic(), GenerateMinimalPathDiagnostic(), getLastStmtLoc(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), clang::ento::SwitchNodeBuilder::getSwitch(), clang::BlockExit::getTerminator(), isDeadReturn(), isTrivialDoWhile(), peelOffOuterExpr(), print_block(), printTerminator(), ResolveCondition(), shouldTreatSuccessorsAsReachable(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ConditionBRVisitor::VisitNodeImpl().
const CFGTerminator clang::CFGBlock::getTerminator | ( | ) | const [inline] |
Stmt * CFGBlock::getTerminatorCondition | ( | bool | StripParens = true | ) |
Definition at line 4460 of file CFG.cpp.
References clang::Stmt::getStmtClass(), and clang::Expr::IgnoreParens().
Referenced by clang::ento::PathDiagnosticLocation::create(), GenerateExtensivePathDiagnostic(), clang::threadSafety::ThreadSafetyAnalyzer::getEdgeLockset(), getTerminatorCondition(), getTerminatorCondition(), and shouldTreatSuccessorsAsReachable().
const Stmt* clang::CFGBlock::getTerminatorCondition | ( | bool | StripParens = true | ) | const [inline] |
Definition at line 629 of file CFG.h.
References getTerminatorCondition().
bool clang::CFGBlock::hasNoReturnElement | ( | ) | const [inline] |
Definition at line 638 of file CFG.h.
Referenced by CheckFallThrough(), clang::threadSafety::neverReturns(), and print_block().
iterator clang::CFGBlock::insertAutomaticObjDtor | ( | iterator | I, |
VarDecl * | VD, | ||
Stmt * | S | ||
) | [inline] |
CFGElement clang::CFGBlock::operator[] | ( | size_t | i | ) | const [inline] |
pred_iterator clang::CFGBlock::pred_begin | ( | ) | [inline] |
Definition at line 533 of file CFG.h.
References clang::BumpVector< T >::begin().
Referenced by clang::consumed::ConsumedBlockInfo::allBackEdgesVisited(), llvm::GraphTraits< Inverse< ::clang::CFGBlock * > >::child_begin(), filtered_pred_start_end(), getLastStmtLoc(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), print_block(), and runOnBlock().
const_pred_iterator clang::CFGBlock::pred_begin | ( | ) | const [inline] |
Definition at line 535 of file CFG.h.
References clang::BumpVector< T >::begin().
bool clang::CFGBlock::pred_empty | ( | ) | const [inline] |
Definition at line 557 of file CFG.h.
References clang::BumpVector< T >::empty().
Referenced by checkRecursiveFunction(), and print_block().
pred_iterator clang::CFGBlock::pred_end | ( | ) | [inline] |
Definition at line 534 of file CFG.h.
References clang::BumpVector< T >::end().
Referenced by clang::consumed::ConsumedBlockInfo::allBackEdgesVisited(), llvm::GraphTraits< Inverse< ::clang::CFGBlock * > >::child_end(), filtered_pred_start_end(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), print_block(), and runOnBlock().
const_pred_iterator clang::CFGBlock::pred_end | ( | ) | const [inline] |
Definition at line 536 of file CFG.h.
References clang::BumpVector< T >::end().
pred_reverse_iterator clang::CFGBlock::pred_rbegin | ( | ) | [inline] |
Definition at line 538 of file CFG.h.
References clang::BumpVector< T >::rbegin().
const_pred_reverse_iterator clang::CFGBlock::pred_rbegin | ( | ) | const [inline] |
Definition at line 540 of file CFG.h.
References clang::BumpVector< T >::rbegin().
pred_reverse_iterator clang::CFGBlock::pred_rend | ( | ) | [inline] |
Definition at line 539 of file CFG.h.
References clang::BumpVector< T >::rend().
const_pred_reverse_iterator clang::CFGBlock::pred_rend | ( | ) | const [inline] |
Definition at line 541 of file CFG.h.
References clang::BumpVector< T >::rend().
unsigned clang::CFGBlock::pred_size | ( | ) | const [inline] |
Definition at line 556 of file CFG.h.
References clang::BumpVector< T >::size().
Referenced by getLastStmtLoc(), clang::consumed::ConsumedBlockInfo::isBackEdgeTarget(), isDeadReturn(), and print_block().
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 4446 of file CFG.cpp.
References print_block().
Referenced by dump(), and clang::CFG::dump().
void clang::CFGBlock::printAsOperand | ( | raw_ostream & | OS, |
bool | |||
) | [inline] |
Definition at line 650 of file CFG.h.
References getBlockID().
void CFGBlock::printTerminator | ( | raw_ostream & | OS, |
const LangOptions & | LO | ||
) | const |
printTerminator - A simple pretty printer of the terminator of a CFGBlock.
Definition at line 4454 of file CFG.cpp.
References getTerminator().
Referenced by llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel().
reverse_iterator clang::CFGBlock::rbegin | ( | ) | [inline] |
Definition at line 512 of file CFG.h.
Referenced by CheckFallThrough(), getLastStmtLoc(), isDeadReturn(), ResolveCondition(), clang::ento::ExprEngine::VisitGuardedExpr(), and clang::ento::ExprEngine::VisitLogicalExpr().
const_reverse_iterator clang::CFGBlock::rbegin | ( | ) | const [inline] |
reverse_iterator clang::CFGBlock::rend | ( | ) | [inline] |
Definition at line 513 of file CFG.h.
Referenced by CheckFallThrough(), getLastStmtLoc(), isDeadReturn(), ResolveCondition(), and clang::ento::ExprEngine::VisitGuardedExpr().
const_reverse_iterator clang::CFGBlock::rend | ( | ) | const [inline] |
void clang::CFGBlock::setHasNoReturnElement | ( | ) | [inline] |
void clang::CFGBlock::setLabel | ( | Stmt * | Statement | ) | [inline] |
void clang::CFGBlock::setLoopTarget | ( | const Stmt * | loopTarget | ) | [inline] |
void clang::CFGBlock::setTerminator | ( | CFGTerminator | Term | ) | [inline] |
unsigned clang::CFGBlock::size | ( | ) | const [inline] |
Definition at line 517 of file CFG.h.
Referenced by getRegionForConstructedObject().
succ_iterator clang::CFGBlock::succ_begin | ( | ) | [inline] |
Definition at line 543 of file CFG.h.
References clang::BumpVector< T >::begin().
Referenced by clang::ento::IndirectGotoNodeBuilder::begin(), CheckFallThrough(), checkForFunctionCall(), 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(), GenerateMinimalPathDiagnostic(), getLastStmtLoc(), clang::threadSafety::ThreadSafetyAnalyzer::getMutexIDs(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), isDeadReturn(), isJumpToFalseBranch(), peelOffOuterExpr(), print_block(), clang::ento::ExprEngine::processCallEnter(), scanFromBlock(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ConditionBRVisitor::VisitTerminator().
const_succ_iterator clang::CFGBlock::succ_begin | ( | ) | const [inline] |
Definition at line 545 of file CFG.h.
References clang::BumpVector< T >::begin().
bool clang::CFGBlock::succ_empty | ( | ) | const [inline] |
Definition at line 554 of file CFG.h.
References clang::BumpVector< T >::empty().
Referenced by print_block().
succ_iterator clang::CFGBlock::succ_end | ( | ) | [inline] |
Definition at line 544 of file CFG.h.
References clang::BumpVector< T >::end().
Referenced by CheckFallThrough(), checkForFunctionCall(), llvm::GraphTraits< ::clang::CFGBlock * >::child_end(), clang::LiveVariables::computeLiveness(), clang::ento::IndirectGotoNodeBuilder::end(), filtered_succ_start_end(), clang::threadSafety::ThreadSafetyAnalyzer::getMutexIDs(), print_block(), and scanFromBlock().
const_succ_iterator clang::CFGBlock::succ_end | ( | ) | const [inline] |
Definition at line 546 of file CFG.h.
References clang::BumpVector< T >::end().
succ_reverse_iterator clang::CFGBlock::succ_rbegin | ( | ) | [inline] |
Definition at line 548 of file CFG.h.
References clang::BumpVector< T >::rbegin().
Referenced by clang::ento::SwitchNodeBuilder::begin(), and clang::ento::SwitchNodeBuilder::generateDefaultCaseNode().
const_succ_reverse_iterator clang::CFGBlock::succ_rbegin | ( | ) | const [inline] |
Definition at line 550 of file CFG.h.
References clang::BumpVector< T >::rbegin().
succ_reverse_iterator clang::CFGBlock::succ_rend | ( | ) | [inline] |
Definition at line 549 of file CFG.h.
References clang::BumpVector< T >::rend().
Referenced by clang::ento::SwitchNodeBuilder::end().
const_succ_reverse_iterator clang::CFGBlock::succ_rend | ( | ) | const [inline] |
Definition at line 551 of file CFG.h.
References clang::BumpVector< T >::rend().
unsigned clang::CFGBlock::succ_size | ( | ) | const [inline] |
Definition at line 553 of file CFG.h.
References clang::BumpVector< T >::size().
Referenced by DiagnoseSwitchLabelsFallthrough(), clang::ento::CoreEngine::ExecuteWorkList(), getLastStmtLoc(), isDeadReturn(), isJumpToFalseBranch(), print_block(), clang::ento::ExprEngine::processCallEnter(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ConditionBRVisitor::VisitTerminator().