From: Ted Kremenek Date: Tue, 23 Sep 2008 18:02:10 +0000 (+0000) Subject: Fix PR 2819: Compute dataflow values for all CFG blocks by not relying on having... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa708259cb518e87a2e7f636671b94a49f823608;p=clang Fix PR 2819: Compute dataflow values for all CFG blocks by not relying on having the "Exit" block being reachable by all (or any) of the blocks in the CFG. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56492 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/FlowSensitive/DataflowSolver.h b/include/clang/Analysis/FlowSensitive/DataflowSolver.h index 169417c3d2..0ed4c8667f 100644 --- a/include/clang/Analysis/FlowSensitive/DataflowSolver.h +++ b/include/clang/Analysis/FlowSensitive/DataflowSolver.h @@ -187,7 +187,10 @@ private: /// SolveDataflowEquations - Perform the actual worklist algorithm /// to compute dataflow values. void SolveDataflowEquations(CFG& cfg, bool recordStmtValues) { - EnqueueFirstBlock(cfg,AnalysisDirTag()); + // Enqueue all blocks to ensure the dataflow values are computed + // for every block. Not all blocks are guaranteed to reach the exit block. + for (CFG::iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I) + WorkList.enqueue(&*I); while (!WorkList.isEmpty()) { const CFGBlock* B = WorkList.dequeue(); @@ -195,14 +198,6 @@ private: ProcessBlock(B, recordStmtValues, AnalysisDirTag()); UpdateEdges(cfg,B,TF.getVal()); } - } - - void EnqueueFirstBlock(const CFG& cfg, dataflow::forward_analysis_tag) { - WorkList.enqueue(&cfg.getEntry()); - } - - void EnqueueFirstBlock(const CFG& cfg, dataflow::backward_analysis_tag) { - WorkList.enqueue(&cfg.getExit()); } void ResetValues(CFG& cfg, ValTy& V, const CFGBlock* B,