Renamed GRConstants => GRSimpleVals.
Moved driver logic for --grsimple to GRSimpleVals.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47137 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index d9f1826..4418afd 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -14,7 +14,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Analysis/PathSensitive/GRExprEngine.h"
-#include "GRSimpleVals.h"
+#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+
+#include "llvm/Support/Streams.h"
 
 using namespace clang;
 using llvm::dyn_cast;
@@ -1004,7 +1006,7 @@
 }
 
 //===----------------------------------------------------------------------===//
-// Driver.
+// Visualization.
 //===----------------------------------------------------------------------===//
 
 #ifndef NDEBUG
@@ -1210,36 +1212,10 @@
 } // end llvm namespace    
 #endif
 
-namespace clang {
-void RunGRConstants(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx,
-                    Diagnostic& Diag) {
-  
-  GRCoreEngine<GRExprEngine> Engine(cfg, FD, Ctx);
-  GRExprEngine* CheckerState = &Engine.getCheckerState();
-  GRSimpleVals GRSV;
-  CheckerState->setTransferFunctions(GRSV);
-  
-  // Execute the worklist algorithm.
-  Engine.ExecuteWorkList();
-  
-  // Look for explicit-Null dereferences and warn about them.
-
-  
-  for (GRExprEngine::null_iterator I=CheckerState->null_begin(),
-                                  E=CheckerState->null_end(); I!=E; ++I) {
-    
-    const PostStmt& L = cast<PostStmt>((*I)->getLocation());
-    Expr* E = cast<Expr>(L.getStmt());
-    
-    Diag.Report(FullSourceLoc(E->getExprLoc(), Ctx.getSourceManager()),
-                diag::chkr_null_deref_after_check);
-  }
-  
-  
+void GRExprEngine::ViewGraph() {
 #ifndef NDEBUG
-  GraphPrintCheckerState = CheckerState;
-  llvm::ViewGraph(*Engine.getGraph().roots_begin(),"GRExprEngine");
+  GraphPrintCheckerState = this;
+  llvm::ViewGraph(*G.roots_begin(), "GRExprEngine");
   GraphPrintCheckerState = NULL;
-#endif  
+#endif
 }
-} // end clang namespace
diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp
index 200c9a3..490ed7f 100644
--- a/Analysis/GRSimpleVals.cpp
+++ b/Analysis/GRSimpleVals.cpp
@@ -14,9 +14,39 @@
 //===----------------------------------------------------------------------===//
 
 #include "GRSimpleVals.h"
+#include "clang/Basic/Diagnostic.h"
 
 using namespace clang;
 
+namespace clang {
+  void RunGRSimpleVals(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx,
+                      Diagnostic& Diag) {
+    
+    GRCoreEngine<GRExprEngine> Engine(cfg, FD, Ctx);
+    GRExprEngine* CheckerState = &Engine.getCheckerState();
+    GRSimpleVals GRSV;
+    CheckerState->setTransferFunctions(GRSV);
+    
+    // Execute the worklist algorithm.
+    Engine.ExecuteWorkList();
+    
+    // Look for explicit-Null dereferences and warn about them.
+    for (GRExprEngine::null_iterator I=CheckerState->null_begin(),
+         E=CheckerState->null_end(); I!=E; ++I) {
+      
+      const PostStmt& L = cast<PostStmt>((*I)->getLocation());
+      Expr* E = cast<Expr>(L.getStmt());
+      
+      Diag.Report(FullSourceLoc(E->getExprLoc(), Ctx.getSourceManager()),
+                  diag::chkr_null_deref_after_check);
+    }
+        
+#ifndef NDEBUG
+    CheckerState->ViewGraph();
+#endif  
+  }
+} // end clang namespace
+
 //===----------------------------------------------------------------------===//
 // Transfer function for Casts.
 //===----------------------------------------------------------------------===//
diff --git a/Analysis/GRSimpleVals.h b/Analysis/GRSimpleVals.h
index 1ed6968..0f517fe 100644
--- a/Analysis/GRSimpleVals.h
+++ b/Analysis/GRSimpleVals.h
@@ -17,6 +17,7 @@
 #define LLVM_CLANG_ANALYSIS_GRSIMPLEVALS
 
 #include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+#include "clang/Analysis/PathSensitive/GRExprEngine.h"
 
 namespace clang {