[cfe-commits] r109243 - /cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h
Ted Kremenek
kremenek at apple.com
Fri Jul 23 11:15:17 PDT 2010
Author: kremenek
Date: Fri Jul 23 13:15:17 2010
New Revision: 109243
URL: http://llvm.org/viewvc/llvm-project?rev=109243&view=rev
Log:
Dataflow solver: Don't overrwite the initial value of a block with top unless new values are available. Patch by Simone Pellegrini!
Modified:
cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h
Modified: cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h?rev=109243&r1=109242&r2=109243&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h (original)
+++ cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h Fri Jul 23 13:15:17 2010
@@ -231,7 +231,7 @@
EdgeDataMapTy& M = D.getEdgeDataMap();
bool firstMerge = true;
-
+ bool noEdges = true;
for (PrevBItr I=ItrTraits::PrevBegin(B),E=ItrTraits::PrevEnd(B); I!=E; ++I){
CFGBlock *PrevBlk = *I;
@@ -243,6 +243,7 @@
M.find(ItrTraits::PrevEdge(B, PrevBlk));
if (EI != M.end()) {
+ noEdges = false;
if (firstMerge) {
firstMerge = false;
V.copyValues(EI->second);
@@ -252,8 +253,20 @@
}
}
+ bool isInitialized = true;
+ typename BlockDataMapTy::iterator BI = D.getBlockDataMap().find(B);
+ if(BI == D.getBlockDataMap().end()) {
+ isInitialized = false;
+ BI = D.getBlockDataMap().insert( std::make_pair(B,ValTy()) ).first;
+ }
+ // If no edges have been found, it means this is the first time the solver
+ // has been called on block B, we copy the initialization values (if any)
+ // as current value for V (which will be used as edge data)
+ if(noEdges && isInitialized)
+ Merge(V, BI->second);
+
// Set the data for the block.
- D.getBlockDataMap()[B].copyValues(V);
+ BI->second.copyValues(V);
}
/// ProcessBlock - Process the transfer functions for a given block.
More information about the cfe-commits
mailing list