Change pretty-printing API for SymExprs and MemRegions to use a naming convention and style similar to other elements in Clang.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75548 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index 0dac76b..ec0608b 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -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();
 }
 
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 00a086d..2999225 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -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;
   }
 }
diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp
index 275f30a..e59d0bd 100644
--- a/lib/Analysis/SymbolManager.cpp
+++ b/lib/Analysis/SymbolManager.cpp
@@ -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*