19 #include "llvm/ADT/SmallPtrSet.h" 20 #include "llvm/ADT/SmallString.h" 21 #include "llvm/ADT/Statistic.h" 22 #include "llvm/Support/raw_ostream.h" 24 using namespace clang;
27 #define DEBUG_TYPE "StatsChecker" 30 "The # of blocks in top level functions");
32 "The # of unreachable blocks in analyzing top level functions");
35 class AnalyzerStatsChecker :
public Checker<check::EndAnalysis> {
44 const CFG *C =
nullptr;
46 llvm::SmallPtrSet<const CFGBlock*, 32> reachable;
72 unsigned total = 0, unreachable = 0;
79 if (!reachable.count(CB)) {
92 llvm::raw_svector_ostream output(buf);
97 if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) {
101 else if (isa<BlockDecl>(D)) {
105 NumBlocksUnreachable += unreachable;
107 std::string NameOfRootFunction = output.str();
109 output <<
" -> Total CFGBlocks: " << total <<
" | Unreachable CFGBlocks: " 110 << unreachable <<
" | Exhausted Block: " 112 <<
" | Empty WorkList: " 115 B.
EmitBasicReport(D,
this,
"Analyzer Statistics",
"Internal Statistics",
119 typedef CoreEngine::BlocksExhausted::const_iterator ExhaustedIterator;
130 llvm::raw_svector_ostream outputI(bufI);
131 outputI <<
"(" << NameOfRootFunction <<
")" <<
132 ": The analyzer generated a sink at this point";
134 D,
this,
"Sink Point",
"Internal Statistics", outputI.str(),
Defines the SourceManager interface.
Decl - This represents one declaration (or definition), e.g.
roots_iterator roots_begin()
BlocksExhausted::const_iterator blocks_exhausted_end() const
bool hasEmptyWorkList() const
BlocksExhausted::const_iterator blocks_exhausted_begin() const
bool wasBlocksExhausted() const
const CoreEngine & getCoreEngine() const
STATISTIC(NumBlocks, "The # of blocks in top level functions")
CFGBlockListTy::const_iterator const_iterator
Represents a single basic block in a source-level CFG.
AllNodesTy::iterator node_iterator
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
unsigned getLine() const
Return the presumed line number of this location.
const CFGBlock * getDst() const
Represents an unpacked "presumed" location which can be presented to the user.
CHECKER * registerChecker(AT... Args)
Used to register checkers.
BugReporter is a utility class for generating PathDiagnostics for analysis.
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
node_iterator nodes_begin()
unsigned getColumn() const
Return the presumed column number of this location.
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
node_iterator nodes_end()
Optional< T > getAs() const
Convert to the specified CFGElement type, returning None if this CFGElement is not of the desired typ...
CoreEngine - Implements the core logic of the graph-reachability analysis.
Dataflow Directional Tag Classes.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
const Decl * getDecl() const
const LocationContext * getLocationContext() const
SourceManager & getSourceManager()
Represents a top-level expression in a basic block.
This represents a decl that may have a name.
Optional< T > getAs() const
Convert to the specified ProgramPoint type, returning None if this ProgramPoint is not of the desired...
void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker, StringRef BugName, StringRef BugCategory, StringRef BugStr, PathDiagnosticLocation Loc, ArrayRef< SourceRange > Ranges=None)
This class handles loading and caching of source files into memory.
SourceLocation getLocation() const