Hi all:<br /><br />I am writing a source to source tool and adding new keywords in the clang source file(i just care about the AST), <br />is there a way to just compile the clang frontend source file but not including llvm source file?<br /><br />Sincerely<br />xiaohui  <br /><br /><span>On 11/03/14, <b class="name">Nikola Smiljanic </b> <popizdeh@gmail.com> wrote:</span><blockquote cite="mid:CAGq7tnNo9JK3a8UA6pnZ0v23kxQqcbGohOG_rZ2GCmo_5BVmgg@mail.gmail.com" class="iwcQuote" style="border-left: 1px solid #00F; padding-left: 13px; margin-left: 0;" type="cite"><div class="mimepart text html"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 4, 2014 at 7:14 AM, Xiaohui Chen <span dir="ltr"><<a href="mailto:xchen422@uwo.ca">xchen422@uwo.ca</a>></span> wrote:<br /><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for your reply.<br /><br />I am confusing here:<span class=""><br /><br />1. Traverse method visits AST nodes that form a tree. CXXRecordDecl is the parent of each of its CXXMethodDecls and FieldDecls.<br /><br /></span> CXXMethodDecls ( FieldDecls )  is not  a member of CXXRecordDecl and also does not inherit from CXXRecordDecl, so how could<br />you define them as parent-child relationship?</blockquote><div><br /></div><div>CXXRecordDecl contains CXXMethodDecls and RecordDecl contains FieldDecls. They're just stored in the DeclContext class but are exposed with method_begin/method_end and field_begin/field_end.</div><div ><br/></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">2. WalkUpFrom method visits the class hierarchy of a single AST node. CXXRecordDecl inherits RecordDecl which inherits TagDecl etc.<br /><br /></span>here TagDecl has three direct parents, so will WalkUpFrom be applied to these three classes?<br /><br /></blockquote><div><br /></div><div>TagDecl does have three super classes but only one of them is also an AST node. AST is built from declarations, statements and types. DeclContext represents a declaration context and structs/classes introduce one. They are also redeclarable (forward declaration) which is what Redeclarable class keeps track of.</div><div><br /></div><div ><br/></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sincerely<span class="HOEnZb"><font color="#888888"><br />xiaohui</font></span><div class="HOEnZb"><div class="h5"><br /><br /><span>On 11/03/14, <b>Nikola Smiljanic </b> <<a href="mailto:popizdeh@gmail.com">popizdeh@gmail.com</a>> wrote:</span><blockquote style="border-left:1px solid #00f;padding-left:13px;margin-left:0" type="cite"><div><div dir="ltr">There are two parent-child relationships at play.<div><br /></div><div>1. Traverse method visits AST nodes that form a tree. CXXRecordDecl is the parent of each of its CXXMethodDecls and FieldDecls. This is what you'll see with clang -cc1 -ast-dump</div><div>2. WalkUpFrom method visits the class hierarchy of a single AST node. CXXRecordDecl inherits RecordDecl which inherits TagDecl etc. Think of serialization, to serialize CXXRecordDecl you'd first want to serialize everything from the base class and so on recursively.</div></div><div class="gmail_extra"><br /><div class="gmail_quote">On Mon, Nov 3, 2014 at 12:32 PM, Xiaohui Chen <span dir="ltr"><<a href="mailto:xchen422@uwo.ca">xchen422@uwo.ca</a>></span> wrote:<br /><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Dear all:<br /><span><div><br />I am using Clang as the frontend of my project, but i am confusing of the following statements.<br />PS: i am a newbie. <br /><br /><pre><span>These tasks are done by three groups of methods, respectively:</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00089" target="1"></a>00089 <span>///   1. TraverseDecl(Decl *x) does task #1.  It is the entry point</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00090" target="1"></a>00090 <span>///      for traversing an AST rooted at x.  This method simply</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00091" target="1"></a>00091 <span>///      dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00092" target="1"></a>00092 <span>///      is the dynamic type of *x, which calls WalkUpFromFoo(x) and</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00093" target="1"></a>00093 <span>///      then recursively visits the child nodes of x.</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00094" target="1"></a>00094 <span>///      TraverseStmt(Stmt *x) and TraverseType(QualType x) work</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00095" target="1"></a>00095 <span>///      similarly.</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00096" target="1"></a>00096 <span>///   2. WalkUpFromFoo(Foo *x) does task #2.  It does not try to visit</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00097" target="1"></a>00097 <span>///      any child node of x.  Instead, it first calls WalkUpFromBar(x)</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00098" target="1"></a>00098 <span>///      where Bar is the direct parent class of Foo (unless Foo has</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00099" target="1"></a>00099 <span>///      no parent), and then calls VisitFoo(x) (see the next list item).</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00100" target="1"></a>00100 <span>///   3. VisitFoo(Foo *x) does task #3.</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00101" target="1"></a>00101 <span>///</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00102" target="1"></a>00102 <span>/// These three method groups are tiered (Traverse* > WalkUpFrom* ></span>
<a name="149774a86dc8444d_1497396fe06534f4_l00103" target="1"></a>00103 <span>/// Visit*).  A method (e.g. Traverse*) may call methods from the same</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00104" target="1"></a>00104 <span>/// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*).</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00105" target="1"></a>00105 <span>/// It may not call methods from a higher tier.</span></pre>According to the above statement, the calling relationship between these<br />functions are organized in this way in general:<br /><br />Traversal*()<br />{<br />        .......<br />        WalkUpFrom*();<br />        .......<br />}<br /><br />WalkUpFrom*()<br />{<br />         .......<br />         Visit*();<br />         .......<br /><br />}<br /><br />am i right?<br /><br />For this statement:<br /><pre>00096 <span>///   2. WalkUpFromFoo(Foo *x) does task #2.  It does not try to visit</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00097" target="1"></a>00097 <span>///      any child node of x.  Instead, it first calls WalkUpFromBar(x)</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00098" target="1"></a>00098 <span>///      where Bar is the direct parent class of Foo (unless Foo has</span>
<a name="149774a86dc8444d_1497396fe06534f4_l00099" target="1"></a>00099 <span>///      no parent), and then calls VisitFoo(x) (see the next list item).</span></pre>what do you mean by saying "the direct parent class of Foo"?<br />why i need to visit the parent class before i visit the current class? <br />what is the purpose? Could you please give me a short example?<br /><br />Thank you in advance!<br /><br />Sincerely<span><font color="#888888"><br />xiaohui<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</font></span></div><br /><br /></span>
<br />_______________________________________________<br />
cfe-dev mailing list<br />
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br />
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="1">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br />
<br /></blockquote></div><br /></div>
</div></blockquote>
</div></div></blockquote></div><br /></div></div>
</div></blockquote>