Added --grsimple-view option to clang driver; this is the same as
--grsimple except that it visualizes the ExplodedGraph using dot and
outputs the current function being analyzed. --grsimple is now silent
except when it emits diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47146 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp
index 1e438ee..e856c3e 100644
--- a/Analysis/GRSimpleVals.cpp
+++ b/Analysis/GRSimpleVals.cpp
@@ -20,7 +20,7 @@
namespace clang {
void RunGRSimpleVals(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx,
- Diagnostic& Diag) {
+ Diagnostic& Diag, bool Visualize) {
if (Diag.hasErrorOccurred())
return;
@@ -45,7 +45,7 @@
}
#ifndef NDEBUG
- CheckerState->ViewGraph();
+ if (Visualize) CheckerState->ViewGraph();
#endif
}
} // end clang namespace
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 08e2238..73f843f 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -580,20 +580,23 @@
class GRSimpleValsVisitor : public CFGVisitor {
Diagnostic &Diags;
ASTContext* Ctx;
+ bool Visualize;
public:
- GRSimpleValsVisitor(Diagnostic &diags) : Diags(diags) {}
+ GRSimpleValsVisitor(Diagnostic &diags, bool visualize)
+ : Diags(diags), Visualize(visualize) {}
virtual void Initialize(ASTContext &Context) { Ctx = &Context; }
virtual void VisitCFG(CFG& C, FunctionDecl&);
+ virtual bool printFuncDeclStart() { return Visualize; }
};
} // end anonymous namespace
-ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags) {
- return new GRSimpleValsVisitor(Diags);
+ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags, bool Visualize) {
+ return new GRSimpleValsVisitor(Diags, Visualize);
}
void GRSimpleValsVisitor::VisitCFG(CFG& C, FunctionDecl& FD) {
- RunGRSimpleVals(C, FD, *Ctx, Diags);
+ RunGRSimpleVals(C, FD, *Ctx, Diags, Visualize);
}
//===----------------------------------------------------------------------===//
diff --git a/Driver/ASTConsumers.h b/Driver/ASTConsumers.h
index 8a14ff2..08d2268 100644
--- a/Driver/ASTConsumers.h
+++ b/Driver/ASTConsumers.h
@@ -41,7 +41,7 @@
ASTConsumer *CreateUnitValsChecker(Diagnostic &Diags);
-ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags);
+ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags, bool Visualize = false);
ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
Diagnostic &Diags);
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index c297303..71291ae 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -68,7 +68,8 @@
ParseCFGDump, // Parse ASTS. Build CFGs. Print CFGs.
ParseCFGView, // Parse ASTS. Build CFGs. View CFGs.
AnalysisLiveVariables, // Print results of live-variable analysis.
- AnalysisGRSimpleVals, // Perform graph-reachability constant prop.
+ AnalysisGRSimpleVals, // Perform graph-reachability constant prop.
+ AnalysisGRSimpleValsView, // Visualize results of path-sens. analysis.
WarnDeadStores, // Run DeadStores checker on parsed ASTs.
WarnDeadStoresCheck, // Check diagnostics for "DeadStores".
WarnUninitVals, // Run UnitializedVariables checker.
@@ -115,6 +116,8 @@
"Flag warnings of uses of unitialized variables."),
clEnumValN(AnalysisGRSimpleVals, "grsimple",
"Perform path-sensitive constant propagation."),
+ clEnumValN(AnalysisGRSimpleValsView, "grsimple-view",
+ "View results of path-sensitive constant propagation."),
clEnumValN(TestSerialization, "test-pickling",
"Run prototype serializtion code."),
clEnumValN(EmitLLVM, "emit-llvm",
@@ -974,6 +977,9 @@
case AnalysisGRSimpleVals:
return CreateGRSimpleVals(Diag);
+ case AnalysisGRSimpleValsView:
+ return CreateGRSimpleVals(Diag, true);
+
case TestSerialization:
return CreateSerializationTest(Diag, FileMgr, LangOpts);
diff --git a/include/clang/Analysis/Analyses/GRSimpleVals.h b/include/clang/Analysis/Analyses/GRSimpleVals.h
index 4da6d25..83b6473 100644
--- a/include/clang/Analysis/Analyses/GRSimpleVals.h
+++ b/include/clang/Analysis/Analyses/GRSimpleVals.h
@@ -25,7 +25,7 @@
/// something more elaborate as the requirements on the interface become
/// clearer.
void RunGRSimpleVals(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx,
- Diagnostic& Diag);
+ Diagnostic& Diag, bool Visualize);
} // end clang namespace