diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-20 18:52:34 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-20 18:52:34 +0000 |
commit | 0b5a07d3a08e84f5c73aedacdda176c5cdb77c4e (patch) | |
tree | 73f31ccc7a93752b8824a9f73907cfcd175f3993 /include/clang/Analysis/FlowSensitive/DataflowSolver.h | |
parent | ec8b59ffc30c65051070e6d6cbb8e4b419210d18 (diff) |
Update DataflowSolver to handle the case where a successor/predecessor block
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
Diffstat (limited to 'include/clang/Analysis/FlowSensitive/DataflowSolver.h')
-rw-r--r-- | include/clang/Analysis/FlowSensitive/DataflowSolver.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/include/clang/Analysis/FlowSensitive/DataflowSolver.h b/include/clang/Analysis/FlowSensitive/DataflowSolver.h index a9b96a8187..e44bf3262b 100644 --- a/include/clang/Analysis/FlowSensitive/DataflowSolver.h +++ b/include/clang/Analysis/FlowSensitive/DataflowSolver.h @@ -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. |