[cfe-commits] r65407 - /cfe/trunk/lib/Analysis/CFRefCount.cpp

Ted Kremenek kremenek at apple.com
Tue Feb 24 15:30:57 PST 2009


Author: kremenek
Date: Tue Feb 24 17:30:57 2009
New Revision: 65407

URL: http://llvm.org/viewvc/llvm-project?rev=65407&view=rev
Log:
Fix diagnostic regression where the leak diagnostic could appear earlier in the path than the branches taken.

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Tue Feb 24 17:30:57 2009
@@ -2698,12 +2698,18 @@
   Stmt *S = 0;
   
   while (LeakN) {
+    bool atBranch = false;
     ProgramPoint P = LeakN->getLocation();
     
     if (const PostStmt *PS = dyn_cast<PostStmt>(&P))
       S = PS->getStmt();
-    else if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P))
+    else if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
+      // FIXME: What we really want is to set LeakN to be the node
+      // for the BlockEntrance for the branch we took and have BugReporter
+      // do the right thing.
+      atBranch = true;
       S = BE->getSrc()->getTerminator();
+    }
     
     if (S) {
       // Scan 'S' for uses of Sym.
@@ -2734,6 +2740,10 @@
         break;
     }
     
+    // Don't traverse any higher than the branch.
+    if (atBranch)
+      break;
+    
     LeakN = LeakN->pred_empty() ? 0 : *(LeakN->pred_begin());
   }
   





More information about the cfe-commits mailing list