Allow a SourceManager to optionally be passed into Stmt::dump


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41588 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/StmtDumper.cpp b/AST/StmtDumper.cpp
index fc58184..4a07d51 100644
--- a/AST/StmtDumper.cpp
+++ b/AST/StmtDumper.cpp
@@ -26,6 +26,7 @@
 
 namespace  {
   class VISIBILITY_HIDDEN StmtDumper : public StmtVisitor<StmtDumper> {
+    const SourceManager *SM;
     FILE *F;
     unsigned IndentLevel;
     
@@ -34,8 +35,8 @@
     /// are left.
     unsigned MaxDepth;
   public:
-    StmtDumper(FILE *f, unsigned maxDepth)
-      : F(f), IndentLevel(0), MaxDepth(maxDepth) {}
+    StmtDumper(const SourceManager *sm, FILE *f, unsigned maxDepth)
+      : SM(sm), F(f), IndentLevel(0), MaxDepth(maxDepth) {}
     
     void DumpSubTree(Stmt *S) {
       // Prune the recursion if not using dump all.
@@ -537,15 +538,31 @@
 /// dump - This does a local dump of the specified AST fragment.  It dumps the
 /// specified node and a few nodes underneath it, but not the whole subtree.
 /// This is useful in a debugger.
+void Stmt::dump(const SourceManager &SM) const {
+  StmtDumper P(&SM, stderr, 4);
+  P.Visit(const_cast<Stmt*>(this));
+  fprintf(stderr, "\n");
+}
+
+/// dump - This does a local dump of the specified AST fragment.  It dumps the
+/// specified node and a few nodes underneath it, but not the whole subtree.
+/// This is useful in a debugger.
 void Stmt::dump() const {
-  StmtDumper P(stderr, 4);
+  StmtDumper P(0, stderr, 4);
+  P.Visit(const_cast<Stmt*>(this));
+  fprintf(stderr, "\n");
+}
+
+/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
+void Stmt::dumpAll(const SourceManager &SM) const {
+  StmtDumper P(&SM, stderr, ~0U);
   P.Visit(const_cast<Stmt*>(this));
   fprintf(stderr, "\n");
 }
 
 /// dumpAll - This does a dump of the specified AST fragment and all subtrees.
 void Stmt::dumpAll() const {
-  StmtDumper P(stderr, ~0U);
+  StmtDumper P(0, stderr, ~0U);
   P.Visit(const_cast<Stmt*>(this));
   fprintf(stderr, "\n");
 }