<div dir="ltr">Hi Ray,<div><br></div><div>First off, understand that the AST dumper provides a human readable view of the AST that may be missing information and can change over time.  It's good for a quick look into Clang's AST, but there are better options for tooling to work on the AST.  (<a href="https://clang.llvm.org/docs/Tooling.html" target="_blank">https://clang.llvm.org/docs/T<wbr>ooling.html</a>)</div><div><br></div><div>(<a href="https://clang.llvm.org/docs/IntroductionToTheClangAST.html" target="_blank">https://clang.llvm.org/docs/I<wbr>ntroductionToTheClangAST.html</a>) This is an introduction to the AST, which has links to the Doxygen generated documentation for the AST nodes.  Stmt, Decl, and Type are good places to start.<br></div><div><br></div><div>For your specific question, you have a DeclRefExpr and a FunctionDecl.</div><div><br></div><div>DeclRefExpr (<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html" target="_blank">https://clang.llvm.org/doxyge<wbr>n/classclang_1_1DeclRefExpr.<wbr>html</a>)</div><div>DeclRefExpr is a sub class of Expr which is a sub class of Stmt</div><div><br></div><div>FunctionDecl (<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html" target="_blank">http://clang.llvm.org/doxygen<wbr>/classclang_1_1FunctionDecl.<wbr>html</a>)<br></div><div>FunctionDecl->DeclaratorDecl-><wbr>ValueDecl->NamedDecl->Decl</div><div><br></div><div>The AST dumper code is in lib/AST/ASTDumper.cpp.  To dump a DeclRefExpr node, it first dumps the Stmt portion, followed by the Expr portion, then DeclRefExpr portion.  Stmt prints "DeclRefExpr 0x862c118 <col:11>" which is the specific Stmt kind, the pointer address, and the code location.  Expr prints "'float (int, char)' lvalue" which is the Type and value type.  DeclRefExpr is pretty much just a holder for a Decl, so it dumps the Decl.  For all Decl's, it prints the Decl kind and the pointer address.  Since FunctionDecl is a NamedDecl, it prints the name next.  And finally, since it is a ValueDecl, it also prints the type.</div><div><br></div><div>So, the first 'float (int, char)' is the type of the DeclRefExpr while the second 'float (int, char)' is the type of the FunctionDecl.  There can be some conversions between the Decl type and the Expr type, so they may not always be the same.</div><div><br></div><div>Hope that helps.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 20, 2018 at 9:50 PM, Ray Mitchell via cfe-users <span dir="ltr"><<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>
<span style="font-family:'Consolas';font-size:12pt;color:#000000">I am attempting to do some basic parsing of the AST using C#.  So far I've had success extracting a few things simply by writing some test C++ code, generating an AST for it, making some changes, regenerating an AST, and observing what changes in the AST entries.  However, this empirical approach is pretty brutal and requires a lot of questionable assumptions.  Is there any documentation that explicitly explains the possible permutations and field meanings of each AST entry type?  If so I'd greatly appreciate a link to it.  I've done pretty well figuring out the FunctionDecl item and a few others but a document describing them would really be helpful.  For example, in the following I know that 'ABCDE' represents the name of the function and 'float (int, char)' represents its data type, but there are two copies of 'float (int, char)' and I'd like to know why and if they both represent the same thing:<br>
<br>
|| `-DeclRefExpr 0x862c118 <col:11> 'float (int, char)' lvalue Function 0x85deae0 'ABCDE' 'float (int, char)'<br>
<br>
I have similar questions about most of the entry types.<br>
Thanks,<br>
Ray<br><br></span></div><br>______________________________<wbr>_________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org">cfe-users@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-users</a><br>
<br></blockquote></div><br></div>