[cfe-commits] r71920 - /cfe/trunk/lib/Analysis/BugReporter.cpp

Ted Kremenek kremenek at apple.com
Fri May 15 18:11:58 PDT 2009


Author: kremenek
Date: Fri May 15 20:11:58 2009
New Revision: 71920

URL: http://llvm.org/viewvc/llvm-project?rev=71920&view=rev
Log:
Fix another bug in BugReporter where we wouldn't always select the bug report in a bug equivalence class with the shortest path.

Modified:
    cfe/trunk/lib/Analysis/BugReporter.cpp

Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=71920&r1=71919&r2=71920&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Fri May 15 20:11:58 2009
@@ -1347,16 +1347,19 @@
   // Find the (first) error node in the trimmed graph.  We just need to consult
   // the node map (NMap) which maps from nodes in the original graph to nodes
   // in the new graph.
-  const ExplodedNode<GRState>* N = 0;
-  unsigned NodeIndex = 0;
+
+  std::queue<const ExplodedNode<GRState>*> WS;
+  typedef llvm::DenseMap<const ExplodedNode<GRState>*,unsigned> IndexMapTy;
+  IndexMapTy IndexMap;
 
   for (const ExplodedNode<GRState>** I = NStart; I != NEnd; ++I)
-    if ((N = NMap->getMappedNode(*I))) {
-      NodeIndex = (I - NStart) / sizeof(*I);
-      break;
+    if (const ExplodedNode<GRState> *N = NMap->getMappedNode(*I)) {
+      unsigned NodeIndex = (I - NStart) / sizeof(*I);
+      WS.push(N);
+      IndexMap[*I] = NodeIndex;
     }
   
-  assert(N && "No error node found in the trimmed graph.");
+  assert(!WS.empty() && "No error node found in the trimmed graph.");
 
   // Create a new (third!) graph with a single path.  This is the graph
   // that will be returned to the caller.
@@ -1368,8 +1371,6 @@
   // to the root node, and then construct a new graph that contains only
   // a single path.
   llvm::DenseMap<const void*,unsigned> Visited;
-  std::queue<const ExplodedNode<GRState>*> WS;
-  WS.push(N);
   
   unsigned cnt = 0;
   const ExplodedNode<GRState>* Root = 0;
@@ -1393,17 +1394,18 @@
       WS.push(*I);
   }
   
-  assert (Root);
+  assert(Root);
   
   // Now walk from the root down the BFS path, always taking the successor
   // with the lowest number.
   ExplodedNode<GRState> *Last = 0, *First = 0;  
   NodeBackMap *BM = new NodeBackMap();
+  unsigned NodeIndex = 0;
   
-  for ( N = Root ;;) {
+  for ( const ExplodedNode<GRState> *N = Root ;;) {
     // Lookup the number associated with the current node.
     llvm::DenseMap<const void*,unsigned>::iterator I = Visited.find(N);
-    assert (I != Visited.end());
+    assert(I != Visited.end());
     
     // Create the equivalent node in the new graph with the same state
     // and location.
@@ -1422,8 +1424,11 @@
     Last = NewN;
     
     // Are we at the final node?
-    if (I->second == 0) {
+    IndexMapTy::iterator IMI =
+      IndexMap.find((const ExplodedNode<GRState>*)(IMitr->second));
+    if (IMI != IndexMap.end()) {
       First = NewN;
+      NodeIndex = IMI->second;
       break;
     }
     
@@ -1446,10 +1451,11 @@
       }
     }
     
-    assert (N);
+    assert(N);
   }
   
-  assert (First);
+  assert(First);
+
   return std::make_pair(std::make_pair(GNew, BM),
                         std::make_pair(First, NodeIndex));
 }





More information about the cfe-commits mailing list