[cfe-commits] r153279 - /cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp

Anna Zaks ganna at apple.com
Thu Mar 22 14:05:58 PDT 2012


Author: zaks
Date: Thu Mar 22 16:05:57 2012
New Revision: 153279

URL: http://llvm.org/viewvc/llvm-project?rev=153279&view=rev
Log:
[analyzer] Add inlining awareness to the block coverage computation
(Stats Checker).

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp?rev=153279&r1=153278&r2=153279&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp Thu Mar 22 16:05:57 2012
@@ -36,17 +36,21 @@
                                             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 @@
 
   // 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;





More information about the cfe-commits mailing list