[cfe-commits] [PATCH] Utilize the indents in -ast-dump to draw structural information

Richard Smith richard at metafoo.co.uk
Thu Jan 24 21:08:28 PST 2013


  Bikeshedding!


================
Comment at: lib/AST/ASTDumper.cpp:249-254
@@ +248,8 @@
+// Example of tree and the Indents vector at each level.
+// (A        { }
+// |-(B      { IT_Child }
+// | `-(C))  { IT_Child,     IT_LastChild }
+// `-(D      { IT_LastChild }
+//   |-(E)   { IT_LastChild, IT_Child }
+//   `-(F))) { IT_LastChild, IT_LastChild }
+// Type            non-last element, last element
----------------
Example needs updating to reflect the removal of the parens.

================
Comment at: lib/AST/ASTDumper.cpp:284
@@ +283,3 @@
+  }
+  OS << " ";
+  Indents.push_back(IT_Child);
----------------
Instead of adding a space here, how about adding one to each of the indent strings? So we'd get:
##
TranslationUnitDecl 0x4bd5660 <<invalid sloc>>
`- FunctionDecl 0x4bd61c0 <simple2.cc:1:1, line:5:1> main 'int (int, char **)'
   |- ParmVarDecl 0x4bd6020 <line:1:10, col:14> argc 'int'
   |- ParmVarDecl 0x4bd60f0 <col:20, col:27> argv 'char **'
   `- CompoundStmt 0x4c028c0 <col:33, line:5:1>
##
rather than
##
 TranslationUnitDecl 0x4bd5660 <<invalid sloc>>
`- FunctionDecl 0x4bd61c0 <simple2.cc:1:1, line:5:1> main 'int (int, char **)'
  |- ParmVarDecl 0x4bd6020 <line:1:10, col:14> argc 'int'
  |- ParmVarDecl 0x4bd60f0 <col:20, col:27> argv 'char **'
  `- CompoundStmt 0x4c028c0 <col:33, line:5:1>
##
(note, no leading space on first line, and | lines up with first character of AST node name)


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



More information about the cfe-commits mailing list