|
clang 24.0.0git
|
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt. More...
#include "clang/Analysis/CFG.h"
Classes | |
| class | BuildOptions |
Public Types | |
| using | CFGBlockListTy = BumpVector<CFGBlock *> |
| using | iterator = CFGBlockListTy::iterator |
| using | const_iterator = CFGBlockListTy::const_iterator |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| using | try_block_iterator = std::vector<const CFGBlock *>::const_iterator |
| using | try_block_range = llvm::iterator_range<try_block_iterator> |
| using | synthetic_stmt_iterator |
| using | synthetic_stmt_range = llvm::iterator_range<synthetic_stmt_iterator> |
Public Member Functions | |
| CFGBlock * | createBlock () |
| Create a new block in the CFG. | |
| void | setEntry (CFGBlock *B) |
| Set the entry block of the CFG. | |
| void | setIndirectGotoBlock (CFGBlock *B) |
| Set the block used for indirect goto jumps. | |
| CFGBlock & | front () |
| CFGBlock & | back () |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| iterator | nodes_begin () |
| iterator | nodes_end () |
| llvm::iterator_range< iterator > | nodes () |
| llvm::iterator_range< const_iterator > | const_nodes () const |
| const_iterator | nodes_begin () const |
| const_iterator | nodes_end () const |
| reverse_iterator | rbegin () |
| reverse_iterator | rend () |
| const_reverse_iterator | rbegin () const |
| const_reverse_iterator | rend () const |
| llvm::iterator_range< reverse_iterator > | reverse_nodes () |
| llvm::iterator_range< const_reverse_iterator > | const_reverse_nodes () const |
| CFGBlock & | getEntry () |
| const CFGBlock & | getEntry () const |
| CFGBlock & | getExit () |
| const CFGBlock & | getExit () const |
| CFGBlock * | getIndirectGotoBlock () |
| const CFGBlock * | getIndirectGotoBlock () const |
| try_block_iterator | try_blocks_begin () const |
| try_block_iterator | try_blocks_end () const |
| try_block_range | try_blocks () const |
| void | addTryDispatchBlock (const CFGBlock *block) |
| void | addSyntheticDeclStmt (const DeclStmt *Synthetic, const DeclStmt *Source) |
| Records a synthetic DeclStmt and the DeclStmt it was constructed from. | |
| synthetic_stmt_iterator | synthetic_stmt_begin () const |
| Iterates over synthetic DeclStmts in the CFG. | |
| synthetic_stmt_iterator | synthetic_stmt_end () const |
| synthetic_stmt_range | synthetic_stmts () const |
| template<typename Callback> | |
| void | VisitBlockStmts (Callback &O) const |
| unsigned | getNumBlockIDs () const |
| Returns the total number of BlockIDs allocated (which start at 0). | |
| unsigned | size () const |
| Return the total number of CFGBlocks within the CFG This is simply a renaming of the getNumBlockIDs(). | |
| bool | isLinear () const |
| Returns true if the CFG has no branches. | |
| void | viewCFG (const LangOptions &LO) const |
| void | print (raw_ostream &OS, const LangOptions &LO, bool ShowColors) const |
| print - A simple pretty printer of a CFG that outputs to an ostream. | |
| void | dump (const LangOptions &LO, bool ShowColors) const |
| dump - A simple pretty printer of a CFG that outputs to stderr. | |
| CFG () | |
| llvm::BumpPtrAllocator & | getAllocator () |
| BumpVectorContext & | getBumpVectorContext () |
Static Public Member Functions | |
| static std::unique_ptr< CFG > | buildCFG (const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO) |
| Builds a CFG from an AST. | |
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
The Stmt can represent an entire function body, or a single expression. A CFG will always contain one empty block that represents the Exit point of the CFG. A CFG will also contain a designated Entry block. The CFG solely represents control-flow; it consists of CFGBlocks which are simply containers of Stmt*'s in the AST the CFG was constructed from.
| using clang::CFG::CFGBlockListTy = BumpVector<CFGBlock *> |
| using clang::CFG::const_reverse_iterator = std::reverse_iterator<const_iterator> |
| using clang::CFG::reverse_iterator = std::reverse_iterator<iterator> |
| using clang::CFG::synthetic_stmt_range = llvm::iterator_range<synthetic_stmt_iterator> |
| using clang::CFG::try_block_iterator = std::vector<const CFGBlock *>::const_iterator |
| using clang::CFG::try_block_range = llvm::iterator_range<try_block_iterator> |
|
inline |
|
inline |
Definition at line 1378 of file CFG.h.
References clang::CFGBlock::back().
Referenced by createBlock().
|
inline |
Definition at line 1380 of file CFG.h.
References clang::CFGBlock::begin().
Referenced by const_nodes(), createBlock(), clang::CFGBlock::getIndexInCFG(), and nodes().
|
inline |
Definition at line 1382 of file CFG.h.
References clang::CFGBlock::begin().
|
static |
Builds a CFG from an AST.
buildCFG - Constructs a CFG from an AST.
Definition at line 5470 of file CFG.cpp.
References clang::C.
Referenced by clang::dataflow::AdornedCFG::build(), clang::AnalysisDeclContext::getCFG(), and clang::AnalysisDeclContext::getUnoptimizedCFG().
|
inline |
|
inline |
| CFGBlock * CFG::createBlock | ( | ) |
Create a new block in the CFG.
createBlock - Constructs and adds a new CFGBlock to the CFG.
The CFG owns the block; the caller should not directly free it.
The block has no successors or predecessors. If this is the first block created in the CFG, it is automatically set to be the Entry and Exit of the CFG.
Definition at line 5454 of file CFG.cpp.
References back(), begin(), end(), and getAllocator().
| void CFG::dump | ( | const LangOptions & | LO, |
| bool | ShowColors ) const |
dump - A simple pretty printer of a CFG that outputs to stderr.
Definition at line 6375 of file CFG.cpp.
References clang::CFGBlock::print().
Referenced by clang::lifetimes::internal::DebugOnlyFunction(), clang::AnalysisDeclContext::dumpCFG(), and clang::lifetimes::internal::LifetimeSafetyAnalysis::run().
|
inline |
Definition at line 1381 of file CFG.h.
References clang::CFGBlock::end().
Referenced by const_nodes(), createBlock(), and nodes().
|
inline |
Definition at line 1383 of file CFG.h.
References clang::CFGBlock::end().
|
inline |
Definition at line 1377 of file CFG.h.
References clang::CFGBlock::front().
|
inline |
Definition at line 1514 of file CFG.h.
Referenced by createBlock().
|
inline |
|
inline |
Definition at line 1408 of file CFG.h.
Referenced by annotateStartParameter(), CheckFallThrough(), checkForRecursiveFunctionCall(), clang::ento::PathDiagnosticLocation::create(), clang::findCFGBackEdges(), clang::dataflow::findReachableBlocks(), clang::reachable_code::FindUnreachableCode(), clang::CallEnter::getEntry(), llvm::GraphTraits<::clang::CFG * >::getEntryNode(), clang::dataflow::NumReachableBlocks(), clang::internal::partitionIntoIntervals(), clang::PostOrderCFGView::PostOrderCFGView(), print(), print_block(), clang::lifetimes::internal::FactsGenerator::run(), clang::dataflow::runTypeErasedDataflowAnalysis(), clang::runUninitializedVariablesAnalysis(), and visitReachableThrows().
|
inline |
Definition at line 1410 of file CFG.h.
Referenced by CheckFallThrough(), checkForRecursiveFunctionCall(), checkRecursiveFunction(), checkThrowInNonThrowingFunc(), findBlockLocations(), clang::FunctionExitPoint::getBlock(), llvm::GraphTraits< Inverse<::clang::CFG * > >::getEntryNode(), clang::ento::PathSensitiveBugReport::getStmt(), clang::CFGBlock::isInevitablySinking(), print(), print_block(), clang::ento::ExprEngine::processCallExit(), clang::consumed::ConsumedAnalyzer::run(), clang::lifetimes::internal::FactsGenerator::run(), and throwEscapes().
|
inline |
Definition at line 1413 of file CFG.h.
Referenced by print_block().
|
inline |
|
inline |
Returns the total number of BlockIDs allocated (which start at 0).
Definition at line 1487 of file CFG.h.
Referenced by clang::internal::buildInterval(), CheckFallThrough(), clang::LiveVariables::computeLiveness(), clang::ento::CoreEngine::ExecuteWorkList(), clang::lifetimes::internal::FactManager::FactManager(), clang::findCFGBackEdges(), clang::dataflow::findReachableBlocks(), clang::reachable_code::FindUnreachableCode(), clang::internal::partitionIntoIntervals(), clang::PostOrderCFGView::PostOrderCFGView(), clang::consumed::ConsumedAnalyzer::run(), clang::lifetimes::internal::LifetimeSafetyAnalysis::run(), clang::runUninitializedVariablesAnalysis(), throwEscapes(), and visitReachableThrows().
| bool CFG::isLinear | ( | ) | const |
Returns true if the CFG has no branches.
Usually it boils down to the CFG having exactly three blocks (entry, the actual code, exit), but sometimes more blocks appear due to having control flow that can be fully resolved in compile time.
Definition at line 5477 of file CFG.cpp.
References size(), and clang::CFGBlock::succs().
Referenced by clang::ento::NoStateChangeFuncVisitor::VisitNode().
|
inline |
Definition at line 1388 of file CFG.h.
References begin(), and end().
Referenced by clang::LiveVariables::computeLiveness().
|
inline |
Definition at line 1385 of file CFG.h.
Referenced by llvm::GraphTraits< Inverse<::clang::CFG * > >::nodes_begin(), and llvm::GraphTraits<::clang::CFG * >::nodes_begin().
|
inline |
|
inline |
Definition at line 1386 of file CFG.h.
Referenced by llvm::GraphTraits< Inverse<::clang::CFG * > >::nodes_end(), and llvm::GraphTraits<::clang::CFG * >::nodes_end().
|
inline |
| void CFG::print | ( | raw_ostream & | OS, |
| const LangOptions & | LO, | ||
| bool | ShowColors ) const |
print - A simple pretty printer of a CFG that outputs to an ostream.
Definition at line 6380 of file CFG.cpp.
References getEntry(), getExit(), and print_block().
|
inline |
Definition at line 1396 of file CFG.h.
Referenced by const_reverse_nodes(), and reverse_nodes().
|
inline |
|
inline |
Definition at line 1397 of file CFG.h.
Referenced by const_reverse_nodes(), and reverse_nodes().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the total number of CFGBlocks within the CFG This is simply a renaming of the getNumBlockIDs().
This is necessary because the dominator implementation needs such an interface.
Definition at line 1492 of file CFG.h.
Referenced by clang::getIntervalWTO(), isLinear(), clang::dataflow::NumReachableBlocks(), clang::dataflow::runTypeErasedDataflowAnalysis(), and llvm::GraphTraits<::clang::CFG * >::size().
|
inline |
Iterates over synthetic DeclStmts in the CFG.
Each element is a (synthetic statement, source statement) pair.
Definition at line 1456 of file CFG.h.
Referenced by addParentsForSyntheticStmts(), and synthetic_stmts().
|
inline |
Definition at line 1461 of file CFG.h.
Referenced by addParentsForSyntheticStmts(), and synthetic_stmts().
|
inline |
Definition at line 1466 of file CFG.h.
References synthetic_stmt_begin(), and synthetic_stmt_end().
|
inline |
Definition at line 1427 of file CFG.h.
References try_blocks_begin(), and try_blocks_end().
Referenced by clang::reachable_code::FindUnreachableCode().
|
inline |
Definition at line 1419 of file CFG.h.
Referenced by try_blocks().
|
inline |
Definition at line 1423 of file CFG.h.
Referenced by try_blocks().
| void CFG::viewCFG | ( | const LangOptions & | LO | ) | const |
Definition at line 6605 of file CFG.cpp.
References GraphHelper.
Definition at line 1474 of file CFG.h.
References clang::Callback, and clang::ast_matchers::stmt.
Referenced by clang::runUninitializedVariablesAnalysis().