diff options
author | Anna Zaks <ganna@apple.com> | 2012-03-22 21:05:57 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-03-22 21:05:57 +0000 |
commit | 395c0dd70e889ef3e91c0dd9c2c784b5b82c9d2b (patch) | |
tree | e17a7e8d09090f18555a28c1bb76ef070ce12285 /clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp | |
parent | 44022b2ae8d8a1fc76eaacdbe19f59339086c934 (diff) | |
download | bcm5719-llvm-395c0dd70e889ef3e91c0dd9c2c784b5b82c9d2b.tar.gz bcm5719-llvm-395c0dd70e889ef3e91c0dd9c2c784b5b82c9d2b.zip |
[analyzer] Add inlining awareness to the block coverage computation
(Stats Checker).
llvm-svn: 153279
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp index abc76b1ed7b..6269acddb08 100644 --- a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp @@ -36,17 +36,21 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G, ExprEngine &Eng) const { const CFG *C = 0; const Decl *D = 0; - const LocationContext *LC = 0; const SourceManager &SM = B.getSourceManager(); llvm::SmallPtrSet<const CFGBlock*, 256> reachable; - // Iterate over explodedgraph + // Root node should have the location context of the top most function. + const ExplodedNode *GraphRoot = *G.roots_begin(); + const LocationContext *LC = GraphRoot->getLocation().getLocationContext(); + + // Iterate over the exploded graph. for (ExplodedGraph::node_iterator I = G.nodes_begin(); I != G.nodes_end(); ++I) { const ProgramPoint &P = I->getLocation(); - // Save the LocationContext if we don't have it already - if (!LC) - LC = P.getLocationContext(); + + // Only check the coverage in the top level function. + if (LC != P.getLocationContext()) + continue; if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) { const CFGBlock *CB = BE->getBlock(); @@ -72,6 +76,9 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G, // We never 'reach' the entry block, so correct the unreachable count unreachable--; + // There is no BlockEntrance corresponding to the exit block as well, so + // assume it is reached as well. + unreachable--; // Generate the warning string SmallString<128> buf; |