[cfe-commits] r55013 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp lib/Analysis/GRState.cpp

Ted Kremenek kremenek at apple.com
Tue Aug 19 15:24:03 PDT 2008


Author: kremenek
Date: Tue Aug 19 17:24:03 2008
New Revision: 55013

URL: http://llvm.org/viewvc/llvm-project?rev=55013&view=rev
Log:
Move store pretty-printing logic inside of StoreManager (previously in GRState).

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
    cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
    cfe/trunk/lib/Analysis/BasicStore.cpp
    cfe/trunk/lib/Analysis/GRState.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=55013&r1=55012&r2=55013&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Tue Aug 19 17:24:03 2008
@@ -171,7 +171,8 @@
                        const char* nl, const char* sep) = 0;
   };
 
-  void print(std::ostream& Out, Printer **Beg = 0, Printer **End = 0,
+  void print(std::ostream& Out, StoreManager& StoreMgr,
+             Printer **Beg = 0, Printer **End = 0,
              const char* nl = "\n", const char *sep = "") const;  
 };
   

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=55013&r1=55012&r2=55013&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Tue Aug 19 17:24:03 2008
@@ -19,6 +19,7 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/DenseSet.h"
 #include <vector>
+#include <iosfwd>
 
 namespace clang {
   
@@ -41,8 +42,11 @@
   
   virtual Store RemoveDeadBindings(Store store, Stmt* Loc,
                                    const LiveVariables& Live,
-                                   DeclRootsTy& DRoots, LiveSymbolsTy& LSymbols,
+                                   DeclRootsTy& DRoots, LiveSymbolsTy& LSymbols,                                  
                                    DeadSymbolsTy& DSymbols) = 0;
+  
+  virtual void print(Store store, std::ostream& Out,
+                     const char* nl, const char *sep) = 0;
 };
   
 } // end clang namespace

Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=55013&r1=55012&r2=55013&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Tue Aug 19 17:24:03 2008
@@ -16,6 +16,7 @@
 #include "clang/Analysis/PathSensitive/GRState.h"
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Streams.h"
 
 using namespace clang;
 
@@ -42,7 +43,10 @@
   
   static inline VarBindingsTy GetVarBindings(Store store) {
     return VarBindingsTy(static_cast<const VarBindingsTy::TreeTy*>(store));
-  }  
+  }
+
+  virtual void print(Store store, std::ostream& Out,
+                     const char* nl, const char *sep);
 };  
   
 } // end anonymous namespace
@@ -234,3 +238,20 @@
   }
   return St;
 }
+
+void BasicStoreManager::print(Store store, std::ostream& Out,
+                              const char* nl, const char *sep) {
+      
+  VarBindingsTy B = GetVarBindings(store);
+  Out << "Variables:" << nl;
+  
+  bool isFirst = true;
+  
+  for (VarBindingsTy::iterator I=B.begin(), E=B.end(); I != E; ++I) {
+    if (isFirst) isFirst = false;
+    else Out << nl;
+    
+    Out << ' ' << I.getKey()->getName() << " : ";
+    I.getData().print(Out);
+  }
+}

Modified: cfe/trunk/lib/Analysis/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRState.cpp?rev=55013&r1=55012&r2=55013&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRState.cpp (original)
+++ cfe/trunk/lib/Analysis/GRState.cpp Tue Aug 19 17:24:03 2008
@@ -238,26 +238,15 @@
 //  State pretty-printing.
 //===----------------------------------------------------------------------===//
 
-void GRState::print(std::ostream& Out, Printer** Beg, Printer** End,
+void GRState::print(std::ostream& Out, StoreManager& StoreMgr,
+                    Printer** Beg, Printer** End,
                     const char* nl, const char* sep) const {
-
-  // Print Variable Bindings
-  Out << "Variables:" << nl;
   
-  bool isFirst = true;
-  
-  for (vb_iterator I = vb_begin(), E = vb_end(); I != E; ++I) {        
-    
-    if (isFirst) isFirst = false;
-    else Out << nl;
-    
-    Out << ' ' << I.getKey()->getName() << " : ";
-    I.getData().print(Out);
-  }
+  // Print the store.
+  StoreMgr.print(getStore(), Out, nl, sep);
   
   // Print Subexpression bindings.
-  
-  isFirst = true;
+  bool isFirst = true;
   
   for (seb_iterator I = seb_begin(), E = seb_end(); I != E; ++I) {        
     
@@ -274,7 +263,6 @@
   }
   
   // Print block-expression bindings.
-  
   isFirst = true;
   
   for (beb_iterator I = beb_begin(), E = beb_end(); I != E; ++I) {      
@@ -341,7 +329,7 @@
 void GRStateRef::print(std::ostream& Out, const char* nl, const char* sep)const{
   GRState::Printer **beg = Mgr->Printers.empty() ? 0 : &Mgr->Printers[0];
   GRState::Printer **end = !beg ? 0 : beg + Mgr->Printers.size();  
-  St->print(Out, beg, end, nl, sep);
+  St->print(Out, *Mgr->StMgr, beg, end, nl, sep);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list