[cfe-commits] r75548 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h include/clang/Analysis/PathSensitive/SymbolManager.h lib/Analysis/MemRegion.cpp lib/Analysis/RegionStore.cpp lib/Analysis/SymbolManager.cpp

Ted Kremenek kremenek at apple.com
Mon Jul 13 16:31:23 PDT 2009


Author: kremenek
Date: Mon Jul 13 18:31:04 2009
New Revision: 75548

URL: http://llvm.org/viewvc/llvm-project?rev=75548&view=rev
Log:
Change pretty-printing API for SymExprs and MemRegions to use a naming convention and style similar to other elements in Clang.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
    cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
    cfe/trunk/lib/Analysis/MemRegion.cpp
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/lib/Analysis/SymbolManager.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Mon Jul 13 18:31:04 2009
@@ -82,9 +82,9 @@
   
   bool hasHeapOrStackStorage() const;
 
-  virtual void print(llvm::raw_ostream& os) const;
+  virtual void dumpToStream(llvm::raw_ostream& os) const;
 
-  void printStdErr() const;
+  void dump() const;
   
   Kind getKind() const { return kind; }  
   
@@ -163,7 +163,7 @@
   static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex,
                             unsigned Cnt, const MemRegion *superRegion);
   
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
   
   static bool classof(const MemRegion* R) {
     return R->getKind() == AllocaRegionKind;
@@ -259,7 +259,7 @@
   
   bool isBoundable() const { return false; }
   
-  virtual void print(llvm::raw_ostream& os) const;
+  virtual void dumpToStream(llvm::raw_ostream& os) const;
 
   void Profile(llvm::FoldingSetNodeID& ID) const;
 
@@ -296,7 +296,7 @@
                             SymbolRef sym,
                             const MemRegion* superRegion);
   
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
   
   static bool classof(const MemRegion* R) {
     return R->getKind() == SymbolicRegionKind;
@@ -330,7 +330,7 @@
     ProfileRegion(ID, Str, superRegion);
   }
 
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
 
   static bool classof(const MemRegion* R) {
     return R->getKind() == StringRegionKind;
@@ -349,7 +349,7 @@
 
 public:
 
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
   
   QualType getLocationType(ASTContext&) const {
     return LValueType;
@@ -400,7 +400,7 @@
 
   void Profile(llvm::FoldingSetNodeID& ID) const;
   
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
 
   const CompoundLiteralExpr* getLiteralExpr() const { return CL; }
   
@@ -448,7 +448,7 @@
     return C.getCanonicalType(getDecl()->getType());
   }    
     
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
   
   static bool classof(const MemRegion* R) {
     return R->getKind() == VarRegionKind;
@@ -463,7 +463,7 @@
 
 public:
   
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
   
   const FieldDecl* getDecl() const { return cast<FieldDecl>(D); }
     
@@ -559,7 +559,7 @@
     return ElementType;
   }
   
-  void print(llvm::raw_ostream& os) const;
+  void dumpToStream(llvm::raw_ostream& os) const;
 
   void Profile(llvm::FoldingSetNodeID& ID) const;
 
@@ -840,10 +840,10 @@
 //===----------------------------------------------------------------------===//
 
 namespace llvm {
-static inline raw_ostream& operator<<(raw_ostream& O,
+static inline raw_ostream& operator<<(raw_ostream& os,
                                       const clang::MemRegion* R) { 
-  R->print(O);
-  return O;
+  R->dumpToStream(os);
+  return os;
 }
 } // end llvm namespace
 

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Mon Jul 13 18:31:04 2009
@@ -50,6 +50,10 @@
   virtual ~SymExpr() {}
   
   Kind getKind() const { return K; }  
+    
+  void dump() const;
+  
+  virtual void dumpToStream(llvm::raw_ostream &os) const = 0;
   
   virtual QualType getType(ASTContext&) const = 0;  
   virtual void Profile(llvm::FoldingSetNodeID& profile) = 0;
@@ -71,7 +75,7 @@
   virtual ~SymbolData() {}
   
   SymbolID getSymbolID() const { return Sym; }
-    
+
   // Implement isa<T> support.
   static inline bool classof(const SymExpr* SE) { 
     Kind k = SE->getKind();
@@ -104,6 +108,8 @@
     Profile(profile, R, T);
   }
   
+  void dumpToStream(llvm::raw_ostream &os) const;
+  
   QualType getType(ASTContext&) const;
 
   // Implement isa<T> support.
@@ -130,6 +136,8 @@
   
   QualType getType(ASTContext&) const;
   
+  void dumpToStream(llvm::raw_ostream &os) const;
+  
   static void Profile(llvm::FoldingSetNodeID& profile, const Stmt* S,
                       QualType T, unsigned Count, const void* SymbolTag) {    
     profile.AddInteger((unsigned) ConjuredKind);
@@ -166,6 +174,8 @@
   QualType getType(ASTContext& C) const { return T; }  
   
   BinaryOperator::Opcode getOpcode() const { return Op; }
+    
+  void dumpToStream(llvm::raw_ostream &os) const;  
   
   const SymExpr *getLHS() const { return LHS; }
   const llvm::APSInt &getRHS() const { return RHS; }
@@ -208,7 +218,9 @@
   // FIXME: We probably need to make this out-of-line to avoid redundant
   // generation of virtual functions.
   QualType getType(ASTContext& C) const { return T; }
-
+  
+  void dumpToStream(llvm::raw_ostream &os) const;
+  
   static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
                     BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) {
     ID.AddInteger((unsigned) SymSymKind);
@@ -325,7 +337,10 @@
 } // end clang namespace
 
 namespace llvm {
-  llvm::raw_ostream& operator<<(llvm::raw_ostream& Out,
-                                const clang::SymExpr *SE);
+static inline llvm::raw_ostream& operator<<(llvm::raw_ostream& os,
+                                            const clang::SymExpr *SE) {
+  SE->dumpToStream(os);
+  return os;
 }
+} // end llvm namespace
 #endif

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

==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Mon Jul 13 18:31:04 2009
@@ -143,26 +143,26 @@
 // Region pretty-printing.
 //===----------------------------------------------------------------------===//
 
-void MemRegion::printStdErr() const {
-  print(llvm::errs());
+void MemRegion::dump() const {
+  dumpToStream(llvm::errs());
 }
 
 std::string MemRegion::getString() const {
   std::string s;
   llvm::raw_string_ostream os(s);
-  print(os);
+  dumpToStream(os);
   return os.str();
 }
 
-void MemRegion::print(llvm::raw_ostream& os) const {
+void MemRegion::dumpToStream(llvm::raw_ostream& os) const {
   os << "<Unknown Region>";
 }
 
-void AllocaRegion::print(llvm::raw_ostream& os) const {
+void AllocaRegion::dumpToStream(llvm::raw_ostream& os) const {
   os << "alloca{" << (void*) Ex << ',' << Cnt << '}';
 }
 
-void CodeTextRegion::print(llvm::raw_ostream& os) const {
+void CodeTextRegion::dumpToStream(llvm::raw_ostream& os) const {
   os << "code{";
   if (isDeclared())
     os << getDecl()->getDeclName().getAsString();
@@ -172,37 +172,34 @@
   os << '}';
 }
 
-void CompoundLiteralRegion::print(llvm::raw_ostream& os) const {
+void CompoundLiteralRegion::dumpToStream(llvm::raw_ostream& os) const {
   // FIXME: More elaborate pretty-printing.
   os << "{ " << (void*) CL <<  " }";
 }
 
-void ElementRegion::print(llvm::raw_ostream& os) const {
-  superRegion->print(os);
-  os << '['; Index.print(os); os << ']';
+void ElementRegion::dumpToStream(llvm::raw_ostream& os) const {
+  os << superRegion << '['; Index.print(os); os << ']';
 }
 
-void FieldRegion::print(llvm::raw_ostream& os) const {
-  superRegion->print(os);
-  os << "->" << getDecl()->getNameAsString();
+void FieldRegion::dumpToStream(llvm::raw_ostream& os) const {
+  os << superRegion << "->" << getDecl()->getNameAsString();
 }
 
-void StringRegion::print(llvm::raw_ostream& os) const {
+void StringRegion::dumpToStream(llvm::raw_ostream& os) const {
   LangOptions LO; // FIXME.
   Str->printPretty(os, 0, PrintingPolicy(LO));
 }
 
-void SymbolicRegion::print(llvm::raw_ostream& os) const {
+void SymbolicRegion::dumpToStream(llvm::raw_ostream& os) const {
   os << "SymRegion-" << sym;
 }
 
-void TypedViewRegion::print(llvm::raw_ostream& os) const {
-  os << "typed_view{" << LValueType.getAsString() << ',';
-  getSuperRegion()->print(os);
-  os << '}';
+void TypedViewRegion::dumpToStream(llvm::raw_ostream& os) const {
+  os << "typed_view{" << LValueType.getAsString() << ',' 
+     << getSuperRegion() << '}';
 }
 
-void VarRegion::print(llvm::raw_ostream& os) const {
+void VarRegion::dumpToStream(llvm::raw_ostream& os) const {
   os << cast<VarDecl>(D)->getNameAsString();
 }
 

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Mon Jul 13 18:31:04 2009
@@ -1439,7 +1439,7 @@
   OS << "Store:" << nl;
   
   for (RegionBindingsTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
-    OS << ' '; I.getKey()->print(OS); OS << " : ";
+    OS << ' ' << I.getKey() << " : ";
     I.getData().print(OS); OS << nl;
   }
 }

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

==============================================================================
--- cfe/trunk/lib/Analysis/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Analysis/SymbolManager.cpp Mon Jul 13 18:31:04 2009
@@ -18,7 +18,9 @@
 
 using namespace clang;
 
-static void print(llvm::raw_ostream& os, const SymExpr *SE);
+void SymExpr::dump() const {
+  dumpToStream(llvm::errs());
+}
 
 static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) {  
   switch (Op) {
@@ -44,45 +46,30 @@
   }        
 }
 
-static void print(llvm::raw_ostream& os, const SymIntExpr *SE) {
+void SymIntExpr::dumpToStream(llvm::raw_ostream& os) const {
   os << '(';
-  print(os, SE->getLHS());
+  getLHS()->dumpToStream(os);
   os << ") ";
-  print(os, SE->getOpcode());
-  os << ' ' << SE->getRHS().getZExtValue();
-  if (SE->getRHS().isUnsigned()) os << 'U';
+  print(os, getOpcode());
+  os << ' ' << getRHS().getZExtValue();
+  if (getRHS().isUnsigned()) os << 'U';
 }
   
-static void print(llvm::raw_ostream& os, const SymSymExpr *SE) {
+void SymSymExpr::dumpToStream(llvm::raw_ostream& os) const {
   os << '(';
-  print(os, SE->getLHS());
+  getLHS()->dumpToStream(os);
   os << ") ";
   os << '(';
-  print(os, SE->getRHS());
+  getRHS()->dumpToStream(os);
   os << ')';  
 }
 
-static void print(llvm::raw_ostream& os, const SymExpr *SE) {
-  switch (SE->getKind()) {
-    case SymExpr::BEGIN_SYMBOLS:
-    case SymExpr::RegionValueKind:
-    case SymExpr::ConjuredKind:
-    case SymExpr::END_SYMBOLS:
-      os << '$' << cast<SymbolData>(SE)->getSymbolID();
-      return;
-    case SymExpr::SymIntKind:
-      print(os, cast<SymIntExpr>(SE));
-      return;
-    case SymExpr::SymSymKind:
-      print(os, cast<SymSymExpr>(SE));
-      return;
-  }
+void SymbolConjured::dumpToStream(llvm::raw_ostream& os) const {
+  os << "conj_$" << getSymbolID();
 }
 
-
-llvm::raw_ostream& llvm::operator<<(llvm::raw_ostream& os, const SymExpr *SE) {
-  print(os, SE);
-  return os;
+void SymbolRegionValue::dumpToStream(llvm::raw_ostream& os) const {
+  os << "reg_$" << getSymbolID() << "<" << R << ">";
 }
 
 const SymbolRegionValue* 





More information about the cfe-commits mailing list