18#include "llvm/ADT/STLExtras.h"
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"
28#define DEBUG_TYPE "StatsChecker"
31 "The # of blocks in top level functions");
33 "The # of unreachable blocks in analyzing top level functions");
36class AnalyzerStatsChecker :
public Checker<check::EndAnalysis> {
45 const CFG *
C =
nullptr;
60 if (
D !=
P.getLocationContext()->getDecl())
79 if (!reachable.count(CB)) {
92 llvm::raw_svector_ostream output(buf);
97 if (isa<FunctionDecl, ObjCMethodDecl>(
D)) {
100 }
else if (isa<BlockDecl>(
D)) {
101 output <<
"block(line:" <<
Loc.getLine() <<
":col:" <<
Loc.getColumn();
106 std::string NameOfRootFunction = std::string(output.str());
108 output <<
" -> Total CFGBlocks: " << total <<
" | Unreachable CFGBlocks: "
111 <<
" | Empty WorkList: "
126 llvm::raw_svector_ostream outputI(bufI);
127 outputI <<
"(" << NameOfRootFunction <<
")" <<
128 ": The analyzer generated a sink at this point";
130 D,
this,
"Sink Point",
"Internal Statistics", outputI.str(),
140bool ento::shouldRegisterAnalyzerStatsChecker(
const CheckerManager &mgr) {
STATISTIC(NumBlocks, "The # of blocks in top level functions")
Defines the SourceManager interface.
Represents a single basic block in a source-level CFG.
Represents a top-level expression in a basic block.
std::optional< T > getAs() const
Convert to the specified CFGElement type, returning std::nullopt if this CFGElement is not of the des...
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const Decl * getDecl() const
This represents a decl that may have a name.
Represents an unpacked "presumed" location which can be presented to the user.
const LocationContext * getLocationContext() const
This class handles loading and caching of source files into memory.
BugReporter is a utility class for generating PathDiagnostics for analysis.
const SourceManager & getSourceManager()
void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker, StringRef BugName, StringRef BugCategory, StringRef BugStr, PathDiagnosticLocation Loc, ArrayRef< SourceRange > Ranges=std::nullopt, ArrayRef< FixItHint > Fixits=std::nullopt)
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
CoreEngine - Implements the core logic of the graph-reachability analysis.
auto exhausted_blocks() const
bool isValid() const =delete
llvm::iterator_range< node_iterator > nodes()
roots_iterator roots_begin()
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
const CoreEngine & getCoreEngine() const
bool hasEmptyWorkList() const
bool wasBlocksExhausted() const
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
The JSON file list parser is used to communicate input to InstallAPI.