]> granicus.if.org Git - clang/commitdiff
[analyzer] Add stats useful for coverage investigations.
authorAnna Zaks <ganna@apple.com>
Thu, 22 Mar 2012 21:06:03 +0000 (21:06 +0000)
committerAnna Zaks <ganna@apple.com>
Thu, 22 Mar 2012 21:06:03 +0000 (21:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153280 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp

index 6269acddb08a2afec7691aaad987640d751eea2b..b22f7ee87f740d4efbd40e75b00d6934f64d7500 100644 (file)
@@ -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"
 #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 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
     }
   }
   
+  NumBlocksUnreachable += unreachable;
+  NumBlocks += total;
+
   output << " -> Total CFGBlocks: " << total << " | Unreachable CFGBlocks: "
       << unreachable << " | Exhausted Block: "
       << (Eng.wasBlocksExhausted() ? "yes" : "no")
index a1be56426e62a1ecc22d1b1324749b2d9f357bae..051c31a55482fb549274da54688cde145986beae 100644 (file)
@@ -44,6 +44,12 @@ STATISTIC(NumRemoveDeadBindings,
             "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 @@ void ExprEngine::processCFGBlockEntrance(NodeBuilderWithSinks &nodeBuilder) {
   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++;
   }
 }