[cfe-commits] [PATCH] Add -ast-dump-depth option

Philip Craig philipjcraig at gmail.com
Tue Nov 13 01:37:48 PST 2012


  Delete some incomplete support for limiting the maximum dump depth in StmtDumper. There are better ways of limiting the amount of information if there is a need for that.

Hi doug.gregor,

http://llvm-reviews.chandlerc.com/D98

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D98?vs=251&id=306#toc

Files:
  include/clang/AST/Stmt.h
  lib/AST/StmtDumper.cpp

Index: include/clang/AST/Stmt.h
===================================================================
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -360,17 +360,11 @@
   static void EnableStatistics();
   static void PrintStats();
 
-  /// 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.
+  /// \brief This does a dump of the specified AST fragment and all subtrees.
   LLVM_ATTRIBUTE_USED void dump() const;
   LLVM_ATTRIBUTE_USED void dump(SourceManager &SM) const;
   void dump(raw_ostream &OS, SourceManager &SM) const;
 
-  /// dumpAll - This does a dump of the specified AST fragment and all subtrees.
-  void dumpAll() const;
-  void dumpAll(SourceManager &SM) const;
-
   /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
   /// back to its original source language syntax.
   void dumpPretty(ASTContext &Context) const;
Index: lib/AST/StmtDumper.cpp
===================================================================
--- lib/AST/StmtDumper.cpp
+++ lib/AST/StmtDumper.cpp
@@ -32,11 +32,6 @@
     unsigned IndentLevel;
     bool IsFirstLine;
 
-    /// MaxDepth - When doing a normal dump (not dumpAll) we only want to dump
-    /// the first few levels of an AST.  This keeps track of how many ast levels
-    /// are left.
-    unsigned MaxDepth;
-
     /// LastLocFilename/LastLocLine - Keep track of the last location we print
     /// out so that we can print out deltas from then on out.
     const char *LastLocFilename;
@@ -54,8 +49,8 @@
     };
 
   public:
-    StmtDumper(SourceManager *sm, raw_ostream &os, unsigned maxDepth)
-      : SM(sm), OS(os), IndentLevel(0), IsFirstLine(true), MaxDepth(maxDepth) {
+    StmtDumper(SourceManager *sm, raw_ostream &os)
+      : SM(sm), OS(os), IndentLevel(0), IsFirstLine(true) {
       LastLocFilename = "";
       LastLocLine = ~0U;
     }
@@ -65,9 +60,6 @@
     }
 
     void DumpSubTree(Stmt *S) {
-      // Prune the recursion if not using dump all.
-      if (MaxDepth == 0) return;
-
       IndentScope Indent(*this);
 
       if (!S) {
@@ -727,34 +719,16 @@
 // Stmt method implementations
 //===----------------------------------------------------------------------===//
 
-/// 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(SourceManager &SM) const {
   dump(llvm::errs(), SM);
 }
 
 void Stmt::dump(raw_ostream &OS, SourceManager &SM) const {
-  StmtDumper P(&SM, OS, 4);
+  StmtDumper P(&SM, OS);
   P.DumpSubTree(const_cast<Stmt*>(this));
 }
 
-/// 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(0, llvm::errs(), 4);
-  P.DumpSubTree(const_cast<Stmt*>(this));
-}
-
-/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
-void Stmt::dumpAll(SourceManager &SM) const {
-  StmtDumper P(&SM, llvm::errs(), ~0U);
-  P.DumpSubTree(const_cast<Stmt*>(this));
-}
-
-/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
-void Stmt::dumpAll() const {
-  StmtDumper P(0, llvm::errs(), ~0U);
+  StmtDumper P(0, llvm::errs());
   P.DumpSubTree(const_cast<Stmt*>(this));
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98.2.patch
Type: text/x-patch
Size: 3510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121113/1262858c/attachment.bin>


More information about the cfe-commits mailing list