]> granicus.if.org Git - clang/commitdiff
Update DataflowSolver to handle the case where a successor/predecessor block
authorTed Kremenek <kremenek@apple.com>
Mon, 20 Jul 2009 18:52:34 +0000 (18:52 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 20 Jul 2009 18:52:34 +0000 (18:52 +0000)
could be NULL. This allows the solver to handle optimized CFGs where branches
can be determined during CFG-construction to be infeasible.

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

include/clang/Analysis/FlowSensitive/DataflowSolver.h

index a9b96a81872f70b1cbafbe7f0afaf4754d034f26..e44bf3262bd38546982c3177c09ab06368f4adfd 100644 (file)
@@ -194,9 +194,9 @@ private:
     
     while (!WorkList.isEmpty()) {
       const CFGBlock* B = WorkList.dequeue();
-      ProcessMerge(cfg,B);
+      ProcessMerge(cfg, B);
       ProcessBlock(B, recordStmtValues, AnalysisDirTag());
-      UpdateEdges(cfg,B,TF.getVal());
+      UpdateEdges(cfg, B, TF.getVal());
     }
   }  
   
@@ -211,16 +211,22 @@ private:
     bool firstMerge = true;
     
     for (PrevBItr I=ItrTraits::PrevBegin(B),E=ItrTraits::PrevEnd(B); I!=E; ++I){
+      
+      CFGBlock *PrevBlk = *I;
+
+      if (!PrevBlk)
+        continue;
 
       typename EdgeDataMapTy::iterator EI =
-        M.find(ItrTraits::PrevEdge(B, *I));
+        M.find(ItrTraits::PrevEdge(B, PrevBlk));
 
       if (EI != M.end()) {
         if (firstMerge) {
           firstMerge = false;
           V.copyValues(EI->second);
         }
-        else Merge(V,EI->second);
+        else
+          Merge(V, EI->second);
       }
     }
     
@@ -263,7 +269,8 @@ private:
   //    forward/backward analysis respectively)
   void UpdateEdges(CFG& cfg, const CFGBlock* B, ValTy& V) {
     for (NextBItr I=ItrTraits::NextBegin(B), E=ItrTraits::NextEnd(B); I!=E; ++I)
-      UpdateEdgeValue(ItrTraits::NextEdge(B, *I),V,*I);
+      if (CFGBlock *NextBlk = *I)
+        UpdateEdgeValue(ItrTraits::NextEdge(B, NextBlk),V, NextBlk);
   }
     
   /// UpdateEdgeValue - Update the value associated with a given edge.