[cfe-commits] r41588 - in /cfe/trunk: AST/StmtDumper.cpp Driver/ASTStreamers.cpp include/clang/AST/Stmt.h

Chris Lattner sabre at nondot.org
Wed Aug 29 17:40:08 PDT 2007


Author: lattner
Date: Wed Aug 29 19:40:08 2007
New Revision: 41588

URL: http://llvm.org/viewvc/llvm-project?rev=41588&view=rev
Log:
Allow a SourceManager to optionally be passed into Stmt::dump

Modified:
    cfe/trunk/AST/StmtDumper.cpp
    cfe/trunk/Driver/ASTStreamers.cpp
    cfe/trunk/include/clang/AST/Stmt.h

Modified: cfe/trunk/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtDumper.cpp?rev=41588&r1=41587&r2=41588&view=diff

==============================================================================
--- cfe/trunk/AST/StmtDumper.cpp (original)
+++ cfe/trunk/AST/StmtDumper.cpp Wed Aug 29 19:40:08 2007
@@ -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");
 }

Modified: cfe/trunk/Driver/ASTStreamers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTStreamers.cpp?rev=41588&r1=41587&r2=41588&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTStreamers.cpp (original)
+++ cfe/trunk/Driver/ASTStreamers.cpp Wed Aug 29 19:40:08 2007
@@ -136,7 +136,7 @@
       
       if (FD->getBody()) {
         fprintf(stderr, "\n");
-        FD->getBody()->dumpAll();
+        FD->getBody()->dumpAll(PP.getSourceManager());
         fprintf(stderr, "\n");
       }
     } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=41588&r1=41587&r2=41588&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed Aug 29 19:40:08 2007
@@ -23,6 +23,7 @@
   class Expr;
   class Decl;
   class IdentifierInfo;
+  class SourceManager;
   class SwitchStmt;
   
 /// Stmt - This represents one statement.
@@ -57,9 +58,11 @@
   /// specified node and a few nodes underneath it, but not the whole subtree.
   /// This is useful in a debugger.
   void dump() const;
+  void dump(const SourceManager &SM) const;
 
   /// dumpAll - This does a dump of the specified AST fragment and all subtrees.
   void dumpAll() const;
+  void dumpAll(const SourceManager &SM) const;
 
   /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
   /// back to its original source language syntax.





More information about the cfe-commits mailing list