[PATCH] D78189: [analyzer] StdLibraryFunctionsChecker: Add statistics

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 03:14:45 PDT 2020


martong created this revision.
martong added reviewers: NoQ, Szelethus, balazske, steakhal.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.
martong added a parent revision: D77641: [analyzer] StdLibraryFunctionsChecker: Associate summaries to FunctionDecls.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78189

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -56,11 +56,22 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "llvm/ADT/Statistic.h"
 
 using namespace clang;
 using namespace clang::ento;
 
 namespace {
+
+#define DEBUG_TYPE "StdLibraryFunctionsChecker"
+STATISTIC(NumCall, "The # of calls handled by the checker");
+STATISTIC(NumFoundSummary, "The # of calls with associated summary");
+STATISTIC(NumArgConstraintViolated,
+          "The # of calls where an arg constraint is violated");
+STATISTIC(NumArgConstrained,
+          "The # of calls with applied argumentum constraints");
+STATISTIC(NumCaseApplied, "The # of calls with applied cases");
+
 class StdLibraryFunctionsChecker
     : public Checker<check::PreCall, check::PostCall, eval::Call> {
   /// Below is a series of typedefs necessary to define function specs.
@@ -437,9 +448,11 @@
 
 void StdLibraryFunctionsChecker::checkPreCall(const CallEvent &Call,
                                               CheckerContext &C) const {
+  ++NumCall;
   Optional<Summary> FoundSummary = findFunctionSummary(Call, C);
   if (!FoundSummary)
     return;
+  ++NumFoundSummary;
 
   const Summary &Summary = *FoundSummary;
   ProgramStateRef State = C.getState();
@@ -450,6 +463,7 @@
     ProgramStateRef FailureSt = VC->negate()->apply(NewState, Call, Summary);
     // The argument constraint is not satisfied.
     if (FailureSt && !SuccessSt) {
+      ++NumArgConstraintViolated;
       if (ExplodedNode *N = C.generateErrorNode(NewState))
         reportBug(Call, N, C);
       break;
@@ -462,8 +476,10 @@
       NewState = SuccessSt;
     }
   }
-  if (NewState && NewState != State)
+  if (NewState && NewState != State) {
+    ++NumArgConstrained;
     C.addTransition(NewState);
+  }
 }
 
 void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call,
@@ -485,8 +501,10 @@
         break;
     }
 
-    if (NewState && NewState != State)
+    if (NewState && NewState != State) {
+      ++NumCaseApplied;
       C.addTransition(NewState);
+    }
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78189.257647.patch
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200415/3b8afbe8/attachment-0001.bin>


More information about the cfe-commits mailing list