summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-03-27 20:02:44 +0000
committerAnna Zaks <ganna@apple.com>2012-03-27 20:02:44 +0000
commitdc36e616a427fb1f70d80f9f28676d68dcb84766 (patch)
tree64e5fefb5845e7e6d72f72f7f60737eff9115294 /clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
parent23df6bb18f081c26ede55f8ba3041444459ee894 (diff)
downloadbcm5719-llvm-dc36e616a427fb1f70d80f9f28676d68dcb84766.tar.gz
bcm5719-llvm-dc36e616a427fb1f70d80f9f28676d68dcb84766.zip
[analyzer] Stats checker: minor interprocedural tweaks.
Report root function name with exhausted block diagnostic. Also, use stack frames, not just any location context when checking if the basic block is in the same context. llvm-svn: 153532
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
index b22f7ee87f7..219fc28595e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
@@ -48,7 +48,8 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
// Root node should have the location context of the top most function.
const ExplodedNode *GraphRoot = *G.roots_begin();
- const LocationContext *LC = GraphRoot->getLocation().getLocationContext();
+ const LocationContext *LC =
+ GraphRoot->getLocation().getLocationContext()->getCurrentStackFrame();
// Iterate over the exploded graph.
for (ExplodedGraph::node_iterator I = G.nodes_begin();
@@ -56,7 +57,7 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
const ProgramPoint &P = I->getLocation();
// Only check the coverage in the top level function.
- if (LC != P.getLocationContext())
+ if (LC != P.getLocationContext()->getCurrentStackFrame())
continue;
if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) {
@@ -91,20 +92,20 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
SmallString<128> buf;
llvm::raw_svector_ostream output(buf);
PresumedLoc Loc = SM.getPresumedLoc(D->getLocation());
- if (Loc.isValid()) {
- output << Loc.getFilename() << " : ";
+ if (!Loc.isValid())
+ return;
- if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) {
- const NamedDecl *ND = cast<NamedDecl>(D);
- output << *ND;
- }
- else if (isa<BlockDecl>(D)) {
- output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn();
- }
+ if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) {
+ const NamedDecl *ND = cast<NamedDecl>(D);
+ output << *ND;
+ }
+ else if (isa<BlockDecl>(D)) {
+ output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn();
}
NumBlocksUnreachable += unreachable;
NumBlocks += total;
+ std::string NameOfRootFunction = output.str();
output << " -> Total CFGBlocks: " << total << " | Unreachable CFGBlocks: "
<< unreachable << " | Exhausted Block: "
@@ -115,7 +116,7 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
B.EmitBasicReport("Analyzer Statistics", "Internal Statistics", output.str(),
PathDiagnosticLocation(D, SM));
- // Emit warning for each block we bailed out on
+ // Emit warning for each block we bailed out on.
typedef CoreEngine::BlocksExhausted::const_iterator ExhaustedIterator;
const CoreEngine &CE = Eng.getCoreEngine();
for (ExhaustedIterator I = CE.blocks_exhausted_begin(),
@@ -123,10 +124,14 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
const BlockEdge &BE = I->first;
const CFGBlock *Exit = BE.getDst();
const CFGElement &CE = Exit->front();
- if (const CFGStmt *CS = dyn_cast<CFGStmt>(&CE))
- B.EmitBasicReport("Bailout Point", "Internal Statistics", "The analyzer "
- "stopped analyzing at this point",
+ if (const CFGStmt *CS = dyn_cast<CFGStmt>(&CE)) {
+ SmallString<128> bufI;
+ llvm::raw_svector_ostream outputI(bufI);
+ outputI << "(" << NameOfRootFunction << ")" <<
+ ": The analyzer generated a sink at this point";
+ B.EmitBasicReport("Sink Point", "Internal Statistics", outputI.str(),
PathDiagnosticLocation::createBegin(CS->getStmt(), SM, LC));
+ }
}
}
OpenPOWER on IntegriCloud