summaryrefslogtreecommitdiffstats
path: root/clang/Analysis/DataflowSolver.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-09-17 21:59:08 +0000
committerTed Kremenek <kremenek@apple.com>2007-09-17 21:59:08 +0000
commit3c996d9a6003721434c4fdf4ac1a8e8d1647b36d (patch)
tree0b2bc14d4a012685d5c7904c0b131dd530a4cdae /clang/Analysis/DataflowSolver.h
parent613ccacb49547fa95cf95ec3219c30aaa9d2ec88 (diff)
downloadbcm5719-llvm-3c996d9a6003721434c4fdf4ac1a8e8d1647b36d.tar.gz
bcm5719-llvm-3c996d9a6003721434c4fdf4ac1a8e8d1647b36d.zip
Bug fix to merging of data flow values (merge incorrectly made values
too "conservative"). Several revisions to UninitializedValues checker after testing. We now appear to be working correctly (probably some bugs still, but main functionality appears to be there). Implemented careful emitting of warnings so that we wouldn't get a cascade of warnings for simply not defining a single variable and using it everywhere. This way the warnings point closer to the root cause rather than "symptoms" from using values derived from uninitialized variables. llvm-svn: 42067
Diffstat (limited to 'clang/Analysis/DataflowSolver.h')
-rw-r--r--clang/Analysis/DataflowSolver.h45
1 files changed, 32 insertions, 13 deletions
diff --git a/clang/Analysis/DataflowSolver.h b/clang/Analysis/DataflowSolver.h
index 4a089dbcdc6..5266af3407c 100644
--- a/clang/Analysis/DataflowSolver.h
+++ b/clang/Analysis/DataflowSolver.h
@@ -85,6 +85,9 @@ public:
/// only be used for querying the dataflow values within a block with
/// and Observer object.
void runOnBlock(const CFGBlock* B) {
+ if (D.getBlockDataMap().find(B) == D.getBlockDataMap().end())
+ return;
+
TransferFuncsTy TF (D.getAnalysisData());
ProcessBlock(B,TF,AnalysisDirTag());
}
@@ -118,14 +121,6 @@ private:
I != E; ++I)
WorkList.enqueue(*I);
}
-
- // For blocks that have no associated dataflow value, instantiate a
- // default value.
- BlockDataMapTy& M = D.getBlockDataMap();
-
- for (CFG::const_iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
- if (M.find(&*I) == M.end())
- M[&*I].resetValues(D.getAnalysisData());
}
/// SolveDataflowEquations (BACKWARD ANALYSIS) - Perform the actual
@@ -155,7 +150,7 @@ private:
/// ProcessBlock (FORWARD ANALYSIS) - Process the transfer functions
/// for a given block based on a forward analysis.
- bool ProcessBlock(const CFGBlock* B, TransferFuncsTy& TF,
+ bool ProcessBlock(const CFGBlock* B, TransferFuncsTy& TF,
dataflow::forward_analysis_tag) {
ValTy& V = TF.getVal();
@@ -164,9 +159,21 @@ private:
V.resetValues(D.getAnalysisData());
MergeOperatorTy Merge;
+ BlockDataMapTy& M = D.getBlockDataMap();
+ bool firstMerge = true;
+
for (CFGBlock::const_pred_iterator I=B->pred_begin(),
- E=B->pred_end(); I!=E; ++I)
- Merge(V,D.getBlockData(*I));
+ E=B->pred_end(); I!=E; ++I) {
+ typename BlockDataMapTy::iterator BI = M.find(*I);
+ if (BI != M.end()) {
+ if (firstMerge) {
+ firstMerge = false;
+ V.copyValues(BI->second);
+ }
+ else
+ Merge(V,BI->second);
+ }
+ }
// Process the statements in the block in the forward direction.
for (CFGBlock::const_iterator I=B->begin(), E=B->end(); I!=E; ++I)
@@ -186,9 +193,21 @@ private:
V.resetValues(D.getAnalysisData());
MergeOperatorTy Merge;
+ BlockDataMapTy& M = D.getBlockDataMap();
+ bool firstMerge = true;
+
for (CFGBlock::const_succ_iterator I=B->succ_begin(),
- E=B->succ_end(); I!=E; ++I)
- Merge(V,D.getBlockData(*I));
+ E=B->succ_end(); I!=E; ++I) {
+ typename BlockDataMapTy::iterator BI = M.find(*I);
+ if (BI != M.end()) {
+ if (firstMerge) {
+ firstMerge = false;
+ V.copyValues(BI->second);
+ }
+ else
+ Merge(V,BI->second);
+ }
+ }
// Process the statements in the block in the forward direction.
for (CFGBlock::const_reverse_iterator I=B->begin(), E=B->end(); I!=E; ++I)
OpenPOWER on IntegriCloud