Added "Dead Stores", a flow-sensitive checker that checks for stores
to variables that are no longer live.  This analysis is built on top
of CFGs and the LiveVariables analysis.

changes to driver:
 added driver option "-check-dead-stores" to run the analysis


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41754 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTStreamers.cpp b/Driver/ASTStreamers.cpp
index b5ea293..95d39fa 100644
--- a/Driver/ASTStreamers.cpp
+++ b/Driver/ASTStreamers.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/AST.h"
 #include "clang/AST/CFG.h"
 #include "clang/Analysis/LiveVariables.h"
+#include "clang/Analysis/LocalCheckers.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/ASTStreamer.h"
 using namespace clang;
@@ -209,4 +210,30 @@
   ASTStreamer_Terminate(Streamer);
 }
 
+void clang::RunDeadStoresCheck(Preprocessor &PP, unsigned MainFileID,bool Stats)
+{
+  ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable());
+  ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
+  
+  while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
+    if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {      
+      if (FD->getBody()) {
+        if (CFG* C = CFG::buildCFG(FD->getBody())) {
+          clang::CheckDeadStores(*C,PP);
+        }
+        else
+          fprintf(stderr," Error processing CFG.\n");
+      }
+    }
+  }
+  
+  if (Stats) {
+    fprintf(stderr, "\nSTATISTICS:\n");
+    ASTStreamer_PrintStats(Streamer);
+    Context.PrintStats();
+  }
+  
+  ASTStreamer_Terminate(Streamer);
+}
+