[cfe-commits] r153280 - in /cfe/trunk/lib/StaticAnalyzer: Checkers/AnalyzerStatsChecker.cpp Core/ExprEngine.cpp

Anna Zaks ganna at apple.com
Thu Mar 22 14:06:03 PDT 2012


Author: zaks
Date: Thu Mar 22 16:06:03 2012
New Revision: 153280

URL: http://llvm.org/viewvc/llvm-project?rev=153280&view=rev
Log:
[analyzer] Add stats useful for coverage investigations.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp?rev=153280&r1=153279&r2=153280&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp Thu Mar 22 16:06:03 2012
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 // This file reports various statistics about analyzer visitation.
 //===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "StatsChecker"
 
 #include "ClangSACheckers.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -20,10 +21,16 @@
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Statistic.h"
 
 using namespace clang;
 using namespace ento;
 
+STATISTIC(NumBlocks,
+          "The # of blocks in top level functions");
+STATISTIC(NumBlocksUnreachable,
+          "The # of unreachable blocks in analyzing top level functions");
+
 namespace {
 class AnalyzerStatsChecker : public Checker<check::EndAnalysis> {
 public:
@@ -96,6 +103,9 @@
     }
   }
   
+  NumBlocksUnreachable += unreachable;
+  NumBlocks += total;
+
   output << " -> Total CFGBlocks: " << total << " | Unreachable CFGBlocks: "
       << unreachable << " | Exhausted Block: "
       << (Eng.wasBlocksExhausted() ? "yes" : "no")

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=153280&r1=153279&r2=153280&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Mar 22 16:06:03 2012
@@ -44,6 +44,12 @@
             "The # of times RemoveDeadBindings is called");
 STATISTIC(NumRemoveDeadBindingsSkipped,
             "The # of times RemoveDeadBindings is skipped");
+STATISTIC(NumMaxBlockCountReached,
+            "The # of aborted paths due to reaching the maximum block count in "
+            "a top level function");
+STATISTIC(NumMaxBlockCountReachedInInlined,
+            "The # of aborted paths due to reaching the maximum block count in "
+            "an inlined function");
 
 //===----------------------------------------------------------------------===//
 // Utility functions.
@@ -975,6 +981,14 @@
   if (nodeBuilder.getContext().getCurrentBlockCount() >= AMgr.getMaxVisit()) {
     static SimpleProgramPointTag tag("ExprEngine : Block count exceeded");
     nodeBuilder.generateNode(pred->getState(), pred, &tag, true);
+
+    // Check if we stopped at the top level function or not.
+    // Root node should have the location context of the top most function.
+    if ((*G.roots_begin())->getLocation().getLocationContext() !=
+        pred->getLocation().getLocationContext())
+      NumMaxBlockCountReachedInInlined++;
+    else
+      NumMaxBlockCountReached++;
   }
 }
 





More information about the cfe-commits mailing list