r177188 - [analyzer] Collect stats on the max # of bug reports in an equivalence class.

Jordan Rose jordan_rose at apple.com
Fri Mar 15 14:41:53 PDT 2013

Author: jrose
Date: Fri Mar 15 16:41:53 2013
New Revision: 177188

URL: http://llvm.org/viewvc/llvm-project?rev=177188&view=rev
[analyzer] Collect stats on the max # of bug reports in an equivalence class.

We discovered that sqlite3.c currently has 2600 reports in a single
equivalence class; it would be good to know if this is a recent
development or what.

(For the curious, the different reports in an equivalence class represent
the same bug found along different paths. When we're suppressing false
positives, we need to go through /every/ path to make sure there isn't a
valid path to a bug. This is a flaw in our after-the-fact suppression,
made worse by the fact that that function isn't particularly optimized.)


Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=177188&r1=177187&r2=177188&view=diff
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Mar 15 16:41:53 2013
@@ -12,6 +12,8 @@
+#define DEBUG_TYPE "BugReporter"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
@@ -29,12 +31,19 @@
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <queue>
 using namespace clang;
 using namespace ento;
+          "The maximum number of bug reports in the same equivalence class");
+          "The maximum number of bug reports in the same equivalence class "
+          "where at least one report is valid (not suppressed)");
 BugReporterVisitor::~BugReporterVisitor() {}
 void BugReporterContext::anchor() {}
@@ -2402,6 +2411,9 @@ void BugReporter::FlushReport(BugReport
+  MaxBugClassSize = std::max(bugReports.size(),
+                             static_cast<size_t>(MaxBugClassSize));
   // Generate the full path diagnostic, using the generation scheme
   // specified by the PathDiagnosticConsumer. Note that we have to generate
   // path diagnostics even for consumers which do not support paths, because
@@ -2410,6 +2422,9 @@ void BugReporter::FlushReport(BugReport
     if (!generatePathDiagnostic(*D.get(), PD, bugReports))
+  MaxValidBugClassSize = std::max(bugReports.size(),
+                                  static_cast<size_t>(MaxValidBugClassSize));
   // If the path is empty, generate a single step path with the location
   // of the issue.
   if (D->path.empty()) {

More information about the cfe-commits mailing list