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

Chandler Carruth chandlerc at google.com
Thu Jan 10 18:51:52 PST 2013


On Thu, Jan 10, 2013 at 6:42 PM, Richard Trieu <rtrieu at google.com> wrote:

> On Thu, Jan 10, 2013 at 6:35 PM, Sean Silva <silvas at purdue.edu> wrote:
>
>> Could you please attach an example of the output? It's hard to comment
>> on the format just by looking through the narrow lens of the FileCheck
>> assertions.
>>
>> -- Sean Silva
>
>
> I can certainly provide an example.
>
> Code:
> int main(int argc, char** argv) {
>   int x = 5;
>   int y = 2;
>   return (x * y);
> }
>
> Old -ast-dump:
> (TranslationUnitDecl 0x5341640 <<invalid sloc>>
>   (TypedefDecl 0x5341b80 <<invalid sloc>> __int128_t '__int128')
>   (TypedefDecl 0x5341be0 <<invalid sloc>> __uint128_t 'unsigned __int128')
>   (TypedefDecl 0x5341fa0 <<invalid sloc>> __builtin_va_list '__va_list_tag
> [1]')
>   (FunctionDecl 0x53421a0 <simple.cc:1:1, line:5:1> main 'int (int, char
> **)'
>     (ParmVarDecl 0x5342000 <line:1:10, col:14> argc 'int')
>     (ParmVarDecl 0x53420d0 <col:20, col:27> argv 'char **')
>     (CompoundStmt 0x536e8a0 <col:33, line:5:1>
>       (DeclStmt 0x53422d8 <line:2:3, col:12>
>         (VarDecl 0x5342260 <col:3, col:11> x 'int'
>           (IntegerLiteral 0x53422b8 <col:11> 'int' 5)))
>       (DeclStmt 0x536e7a0 <line:3:3, col:12>
>         (VarDecl 0x5342300 <col:3, col:11> y 'int'
>           (IntegerLiteral 0x536e780 <col:11> 'int' 2)))
>       (ReturnStmt 0x536e880 <line:4:3, col:16>
>         (ParenExpr 0x536e860 <col:10, col:16> 'int'
>           (BinaryOperator 0x536e838 <col:11, col:15> 'int' '*'
>             (ImplicitCastExpr 0x536e808 <col:11> 'int' <LValueToRValue>
>               (DeclRefExpr 0x536e7b8 <col:11> 'int' lvalue Var 0x5342260
> 'x' 'int'))
>             (ImplicitCastExpr 0x536e820 <col:15> 'int' <LValueToRValue>
>               (DeclRefExpr 0x536e7e0 <col:15> 'int' lvalue Var 0x5342300
> 'y' 'int'))))))))
>
> New -ast-dump:
> (TranslationUnitDecl 0x6784640 <<invalid sloc>>
> |-(TypedefDecl 0x6784b80 <<invalid sloc>> __int128_t '__int128')
> |-(TypedefDecl 0x6784be0 <<invalid sloc>> __uint128_t 'unsigned __int128')
> |-(TypedefDecl 0x6784fa0 <<invalid sloc>> __builtin_va_list '__va_list_tag
> [1]')
> \-(FunctionDecl 0x67851a0 <simple.cc:1:1, line:5:1> main 'int (int, char
> **)'
>

So, hopefully no one actually immolates me for asking to repaint this
bikeshed, but I'd mildly prefer a ` (back-tick) to \ for the last one....

<dons asbestos>


>   |-(ParmVarDecl 0x6785000 <line:1:10, col:14> argc 'int')
>   |-(ParmVarDecl 0x67850d0 <col:20, col:27> argv 'char **')
>   \-(CompoundStmt 0x67b18a0 <col:33, line:5:1>
>     |-(DeclStmt 0x67852d8 <line:2:3, col:12>
>     | \-(VarDecl 0x6785260 <col:3, col:11> x 'int'
>     |   \-(IntegerLiteral 0x67852b8 <col:11> 'int' 5)))
>     |-(DeclStmt 0x67b17a0 <line:3:3, col:12>
>     | \-(VarDecl 0x6785300 <col:3, col:11> y 'int'
>     |   \-(IntegerLiteral 0x67b1780 <col:11> 'int' 2)))
>     \-(ReturnStmt 0x67b1880 <line:4:3, col:16>
>       \-(ParenExpr 0x67b1860 <col:10, col:16> 'int'
>         \-(BinaryOperator 0x67b1838 <col:11, col:15> 'int' '*'
>           |-(ImplicitCastExpr 0x67b1808 <col:11> 'int' <LValueToRValue>
>           | \-(DeclRefExpr 0x67b17b8 <col:11> 'int' lvalue Var 0x6785260
> 'x' 'int'))
>           \-(ImplicitCastExpr 0x67b1820 <col:15> 'int' <LValueToRValue>
>             \-(DeclRefExpr 0x67b17e0 <col:15> 'int' lvalue Var 0x6785300
> 'y' 'int'))))))))
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130110/9a71b836/attachment.html>


More information about the cfe-commits mailing list