]> granicus.if.org Git - clang/commitdiff
When creating PathDiagnostics, created a trimmed graph first and report the
authorTed Kremenek <kremenek@apple.com>
Thu, 3 Apr 2008 04:59:14 +0000 (04:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 3 Apr 2008 04:59:14 +0000 (04:59 +0000)
BFS path to the root.  This also avoids problems with loops in the ExplodedGraph.

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

lib/Analysis/BugReporter.cpp

index 2ae096020602959bbe290372ae8827281d743c3f..db979fafdbfdddb7b7b36982a05f28f2c7fa6867 100644 (file)
@@ -69,8 +69,26 @@ void BugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, ASTContext& Ctx,
   
   SourceManager& SMgr = Ctx.getSourceManager();
   
-  
   llvm::OwningPtr<ExplodedGraph<GRExprEngine> > GTrim(G.Trim(&N, &N+1));
+  
+  // Find the sink in the trimmed graph.
+  // FIXME: Should we eventually have a sink iterator?
+  
+  ExplodedNode<ValueState>* NewN = 0;
+  
+  for (ExplodedGraph<GRExprEngine>::node_iterator
+        I = GTrim->nodes_begin(), E = GTrim->nodes_end(); I != E; ++I) {
+    
+    if (I->isSink()) {
+      NewN = &*I;
+      break;
+    }    
+  }
+  
+  assert (NewN);
+  assert (NewN->getLocation() == N->getLocation());
+  
+  N = NewN;
 
   while (!N->pred_empty()) {