]> granicus.if.org Git - clang/commitdiff
Renamed GRConstants => GRSimpleVals.
authorTed Kremenek <kremenek@apple.com>
Thu, 14 Feb 2008 22:36:46 +0000 (22:36 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 14 Feb 2008 22:36:46 +0000 (22:36 +0000)
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

Analysis/GRExprEngine.cpp
Analysis/GRSimpleVals.cpp
Analysis/GRSimpleVals.h
Driver/ASTConsumers.cpp
Driver/ASTConsumers.h
Driver/clang.cpp
include/clang/Analysis/Analyses/GRSimpleVals.h [moved from include/clang/Analysis/Analyses/GRConstants.h with 72% similarity]
include/clang/Analysis/PathSensitive/GRExprEngine.h

index d9f1826bd7d1276464870688e6c73a1ccc7285b3..4418afddb6cb4bae321e3b8e942cca29985c92e1 100644 (file)
@@ -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 @@ GRExprEngine::AssumeSymInt(StateTy St, bool Assumption,
 }
 
 //===----------------------------------------------------------------------===//
-// Driver.
+// Visualization.
 //===----------------------------------------------------------------------===//
 
 #ifndef NDEBUG
@@ -1210,36 +1212,10 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
 } // 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
index 200c9a39c6dd8fa62bb59bb2e6f5af11bc270e79..490ed7f31eed6abe39ae9545a86c57920059a1ad 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #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.
 //===----------------------------------------------------------------------===//
index 1ed69688b8dee275026b58c4f9efd8285b398485..0f517fe5eb157520b4df2e7ea81f570185a9d0ae 100644 (file)
@@ -17,6 +17,7 @@
 #define LLVM_CLANG_ANALYSIS_GRSIMPLEVALS
 
 #include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+#include "clang/Analysis/PathSensitive/GRExprEngine.h"
 
 namespace clang {
   
index 688619438b9de28e9afbeedefff0133c761d8f38..08e2238a66aec28e7a5b9d30a349ad68ad191cd7 100644 (file)
@@ -20,7 +20,7 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/CFG.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
-#include "clang/Analysis/Analyses/GRConstants.h"
+#include "clang/Analysis/Analyses/GRSimpleVals.h"
 #include "clang/Analysis/LocalCheckers.h"
 #include "llvm/Support/Streams.h"
 using namespace clang;
@@ -574,26 +574,26 @@ ASTConsumer *clang::CreateUnitValsChecker(Diagnostic &Diags) {
 }
 
 //===----------------------------------------------------------------------===//
-// GRConstants - Perform intra-procedural, path-sensitive constant propagation.
+// GRSimpleVals - Perform intra-procedural, path-sensitive constant propagation.
 
 namespace {
-  class GRConstantsVisitor : public CFGVisitor {
+  class GRSimpleValsVisitor : public CFGVisitor {
     Diagnostic &Diags;
     ASTContext* Ctx;
   public:
-    GRConstantsVisitor(Diagnostic &diags) : Diags(diags) {}
+    GRSimpleValsVisitor(Diagnostic &diags) : Diags(diags) {}
     
     virtual void Initialize(ASTContext &Context) { Ctx = &Context; }    
     virtual void VisitCFG(CFG& C, FunctionDecl&);
   };
 } // end anonymous namespace
 
-ASTConsumer* clang::CreateGRConstants(Diagnostic &Diags) {
-  return new GRConstantsVisitor(Diags);
+ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags) {
+  return new GRSimpleValsVisitor(Diags);
 }
 
-void GRConstantsVisitor::VisitCFG(CFG& C, FunctionDecl& FD) {
-  RunGRConstants(C, FD, *Ctx, Diags);
+void GRSimpleValsVisitor::VisitCFG(CFG& C, FunctionDecl& FD) {
+  RunGRSimpleVals(C, FD, *Ctx, Diags);
 }
 
 //===----------------------------------------------------------------------===//
index 28decda9b30bba019744344467b5955e08d70f36..8a14ff2b9e0004185d645572189c3133d85a7aa2 100644 (file)
@@ -41,7 +41,7 @@ ASTConsumer *CreateDeadStoreChecker(Diagnostic &Diags);
 
 ASTConsumer *CreateUnitValsChecker(Diagnostic &Diags);
   
-ASTConsumer *CreateGRConstants(Diagnostic &Diags);
+ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags);
 
 ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
                                     Diagnostic &Diags);
index 2f47e5199ca21f5cf0a426892331974c932ebbf9..c29730397f0b7caa6f1f9229fcbcb21b8bdd0836 100644 (file)
@@ -68,7 +68,7 @@ enum ProgActions {
   ParseCFGDump,                 // Parse ASTS. Build CFGs. Print CFGs.
   ParseCFGView,                 // Parse ASTS. Build CFGs. View CFGs.
   AnalysisLiveVariables,        // Print results of live-variable analysis.
-  AnalysisGRConstants,          // Perform graph-reachability constant prop.
+  AnalysisGRSimpleVals,          // Perform graph-reachability constant prop.
   WarnDeadStores,               // Run DeadStores checker on parsed ASTs.
   WarnDeadStoresCheck,          // Check diagnostics for "DeadStores".
   WarnUninitVals,               // Run UnitializedVariables checker.
@@ -113,7 +113,7 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
                         "Flag warnings of stores to dead variables."),
              clEnumValN(WarnUninitVals, "warn-uninit-values",
                         "Flag warnings of uses of unitialized variables."),
-             clEnumValN(AnalysisGRConstants, "grconstants",
+             clEnumValN(AnalysisGRSimpleVals, "grsimple",
                         "Perform path-sensitive constant propagation."),
              clEnumValN(TestSerialization, "test-pickling",
                         "Run prototype serializtion code."),
@@ -971,8 +971,8 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
     case WarnUninitVals:
       return CreateUnitValsChecker(Diag);
       
-    case AnalysisGRConstants:
-      return CreateGRConstants(Diag);
+    case AnalysisGRSimpleVals:
+      return CreateGRSimpleVals(Diag);
       
     case TestSerialization:
       return CreateSerializationTest(Diag, FileMgr, LangOpts);
similarity index 72%
rename from include/clang/Analysis/Analyses/GRConstants.h
rename to include/clang/Analysis/Analyses/GRSimpleVals.h
index afd0535a9aefa58f6aa3b1b3223b16a2a35e4bb2..4da6d258db3851d062c5f1356456244c43c98c3c 100644 (file)
@@ -1,4 +1,4 @@
-//===-- GRConstants.h- Simple, Path-Sens. Constant Prop. ---------*- C++ -*-==//
+//===-- GRSimpleVals.h- Simple, Path-Sens. Constant Prop. ---------*- C++ -*-==//
 //   
 //                     The LLVM Compiler Infrastructure
 //
@@ -9,7 +9,7 @@
 //
 //               Constant Propagation via Graph Reachability
 //
-//  This files defines the interface to use the 'GRConstants' path-sensitive
+//  This files defines the interface to use the 'GRSimpleVals' path-sensitive
 //  constant-propagation analysis.
 //
 //===----------------------------------------------------------------------===//
 namespace clang {
   class Diagnostic;
   
-  /// RunGRConstants - This is a simple driver to run the GRConstants analysis
+  /// RunGRSimpleVals - This is a simple driver to run the GRSimpleVals analysis
   ///  on a provided CFG.  This interface will eventually be replaced with
   ///  something more elaborate as the requirements on the interface become
   ///  clearer.
-  void RunGRConstants(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx,
+  void RunGRSimpleVals(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx,
                       Diagnostic& Diag);
   
 } // end clang namespace
index fd0399ae5359f659ad62fbf846c7088c3e083aa2..1c88b30b8842b8284d88cb2a6b0d3d62d731b52a 100644 (file)
@@ -17,7 +17,6 @@
 
 #include "clang/Analysis/PathSensitive/GRCoreEngine.h"
 #include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
-#include "GRSimpleVals.h"
 
 #include "clang/AST/Expr.h"
 #include "clang/AST/ASTContext.h"
@@ -33,7 +32,6 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/Streams.h"
 
 #include <functional>
 
@@ -150,6 +148,10 @@ public:
   void setTransferFunctions(GRTransferFuncs* tf) { TF = tf; }
   void setTransferFunctions(GRTransferFuncs& tf) { TF = &tf; }
   
+  /// ViewGraph - Visualize the ExplodedGraph created by executing the
+  ///  simulation.
+  void ViewGraph();
+  
   /// getInitialState - Return the initial state used for the root vertex
   ///  in the ExplodedGraph.
   StateTy getInitialState() {