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/clang.cpp b/Driver/clang.cpp
index ed540ae..79a09f1 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -53,8 +53,9 @@
ParseASTCheck, // Parse ASTs and check diagnostics.
ParseAST, // Parse ASTs.
ParseCFGDump, // Parse ASTS. Build CFGs. Print CFGs.
- ParseCFGView, // Parse ASTS. Build CFGs. View CFGs (Graphviz).
+ ParseCFGView, // Parse ASTS. Build CFGs. View CFGs.
AnalysisLiveVariables, // Print results of live-variable analysis.
+ WarnDeadStores, // Run DeadStores checker on parsed ASTs.
ParsePrintCallbacks, // Parse and print each callback.
ParseSyntaxOnly, // Parse and perform semantic analysis.
ParseNoop, // Parse with noop callbacks.
@@ -93,6 +94,8 @@
"Run parser, then build and view CFGs with Graphviz."),
clEnumValN(AnalysisLiveVariables, "dump-live-variables",
"Print results of live variable analysis."),
+ clEnumValN(WarnDeadStores, "check-dead-stores",
+ "Flag warnings of stores to dead variables."),
clEnumValN(EmitLLVM, "emit-llvm",
"Build ASTs then convert to LLVM, emit .ll file"),
clEnumValEnd));
@@ -851,7 +854,10 @@
break;
case AnalysisLiveVariables:
AnalyzeLiveVariables(PP, MainFileID);
- break;
+ break;
+ case WarnDeadStores:
+ RunDeadStoresCheck(PP, MainFileID, Stats);
+ break;
case EmitLLVM:
EmitLLVMFromASTs(PP, MainFileID, Stats);
break;