diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/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 { /// 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 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); + } } }