[cfe-commits] r47146 - in /cfe/trunk: Analysis/GRSimpleVals.cpp Driver/ASTConsumers.cpp Driver/ASTConsumers.h Driver/clang.cpp include/clang/Analysis/Analyses/GRSimpleVals.h

Ted Kremenek kremenek at apple.com
Thu Feb 14 16:35:40 PST 2008


Author: kremenek
Date: Thu Feb 14 18:35:38 2008
New Revision: 47146

URL: http://llvm.org/viewvc/llvm-project?rev=47146&view=rev
Log:
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.

Modified:
    cfe/trunk/Analysis/GRSimpleVals.cpp
    cfe/trunk/Driver/ASTConsumers.cpp
    cfe/trunk/Driver/ASTConsumers.h
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/include/clang/Analysis/Analyses/GRSimpleVals.h

Modified: cfe/trunk/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.cpp?rev=47146&r1=47145&r2=47146&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/Analysis/GRSimpleVals.cpp Thu Feb 14 18:35:38 2008
@@ -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

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=47146&r1=47145&r2=47146&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Thu Feb 14 18:35:38 2008
@@ -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);
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=47146&r1=47145&r2=47146&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Thu Feb 14 18:35:38 2008
@@ -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);

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=47146&r1=47145&r2=47146&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Feb 14 18:35:38 2008
@@ -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);
       

Modified: cfe/trunk/include/clang/Analysis/Analyses/GRSimpleVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/GRSimpleVals.h?rev=47146&r1=47145&r2=47146&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/GRSimpleVals.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/GRSimpleVals.h Thu Feb 14 18:35:38 2008
@@ -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
 





More information about the cfe-commits mailing list