]> granicus.if.org Git - clang/commitdiff
Add overloaded versions of DataflowSolver::runOnBlock to simplify
authorTed Kremenek <kremenek@apple.com>
Tue, 18 Sep 2007 21:08:21 +0000 (21:08 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 18 Sep 2007 21:08:21 +0000 (21:08 +0000)
invocation of the solver.

UninitializedValues checker now uses CFG::runOnAllBlocks to query the
computed dataflow values (tighter code).

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

Analysis/DataflowSolver.h
Analysis/UninitializedValues.cpp

index 724b4a4fbb91383cb60c81bf31f91b18f90feb65..d3d4d9f917a0c4d966feef8646b83d98b081b88a 100644 (file)
@@ -90,6 +90,15 @@ public:
       ProcessBlock(B,AnalysisDirTag());
   }
   
+  void runOnBlock(const CFGBlock& B) { runOnBlock(&B); }
+  void runOnBlock(CFG::iterator &I) { runOnBlock(*I); }
+  void runOnBlock(CFG::const_iterator &I) { runOnBlock(*I); }
+
+  void runOnAllBlocks(const CFG& cfg) {
+    for (CFG::const_iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
+      runOnBlock(I);
+  }
+  
   //===--------------------------------------------------------------------===//
   // Internal solver logic.
   //===--------------------------------------------------------------------===//
index 56897e67d4f080bf9f89e09840ff5633e65a631a..09f195e382656ac80f341504caabb9f07caa8e84 100644 (file)
@@ -238,7 +238,6 @@ struct Merge {
     
     Dst.DeclBV |= Src.DeclBV;
     Dst.ExprBV |= Src.ExprBV;
-
   }
 };
 } // end anonymous namespace
@@ -250,7 +249,6 @@ struct Merge {
 UninitializedValues_ValueTypes::ObserverTy::~ObserverTy() {}
 
 namespace {
-
 class UninitializedValuesChecker : public UninitializedValues::ObserverTy {
   ASTContext &Ctx;
   Diagnostic &Diags;
@@ -270,11 +268,9 @@ public:
         Diags.Report(DR->getSourceRange().Begin(), diag::warn_uninit_val);
   }
 };
-
 } // end anonymous namespace
 
 namespace clang {
-
 void CheckUninitializedValues(CFG& cfg, ASTContext &Ctx, Diagnostic &Diags) {
 
   typedef DataflowSolver<UninitializedValues,TransferFuncs,Merge> Solver;
@@ -287,9 +283,6 @@ void CheckUninitializedValues(CFG& cfg, ASTContext &Ctx, Diagnostic &Diags) {
   // Scan for DeclRefExprs that use uninitialized values.
   UninitializedValuesChecker Observer(Ctx,Diags);
   U.getAnalysisData().Observer = &Observer;
-
-  for (CFG::iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
-    S.runOnBlock(&*I);
-}
-
+  S.runOnAllBlocks(cfg);
 }
+} // end namespace clang