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

Richard Trieu rtrieu at google.com
Thu Jan 24 21:45:34 PST 2013



================
Comment at: lib/AST/ASTDumper.cpp:284
@@ +283,3 @@
+  }
+  OS << " ";
+  Indents.push_back(IT_Child);
----------------
Richard Smith wrote:
> 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)
That will also increase the space used by indenting by 50% (2 vs 3 characters per indent level).  If you want the | to line up, the space could be removed.


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



More information about the cfe-commits mailing list