]> granicus.if.org Git - clang/commitdiff
[analyzer; alternate edges] remove redundant adjacent "events" with the same text.
authorTed Kremenek <kremenek@apple.com>
Wed, 22 May 2013 19:10:41 +0000 (19:10 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 22 May 2013 19:10:41 +0000 (19:10 +0000)
Fixes <rdar://problem/13949982>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182505 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/BugReporter.cpp

index 9663492a14cdfd88064b0ce4fe50ccefbbff9a27..f08e048bb80ee8a6a86fae5371f9ea35d96aecd6 100644 (file)
@@ -2026,6 +2026,31 @@ static void removePunyEdges(PathPieces &path,
   }
 }
 
+static void removeIdenticalEvents(PathPieces &path) {
+  for (PathPieces::iterator I = path.begin(), E = path.end(); I != E; ++I) {
+    PathDiagnosticEventPiece *PieceI =
+      dyn_cast<PathDiagnosticEventPiece>(*I);
+
+    if (!PieceI)
+      continue;
+
+    PathPieces::iterator NextI = I; ++NextI;
+    if (NextI == E)
+      return;
+
+    PathDiagnosticEventPiece *PieceNextI =
+      dyn_cast<PathDiagnosticEventPiece>(*I);
+
+    if (!PieceNextI)
+      continue;
+
+    // Erase the second piece if it has the same exact message text.
+    if (PieceI->getString() == PieceNextI->getString()) {
+      path.erase(NextI);
+    }
+  }
+}
+
 static bool optimizeEdges(PathPieces &path, SourceManager &SM,
                           OptimizedCallsSet &OCS,
                           LocationContextMap &LCM) {
@@ -2199,6 +2224,8 @@ static bool optimizeEdges(PathPieces &path, SourceManager &SM,
   if (!hasChanges) {
     // Remove any puny edges left over after primary optimization pass.
     removePunyEdges(path, SM, PM);
+    // Remove identical events.
+    removeIdenticalEvents(path);
   }
 
   return hasChanges;