<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 11, 2014 at 10:43 AM, victor <span dir="ltr"><<a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div><div dir="ltr"><div class=""><blockquote>Well, as I said, not necessarily - you will definitely find a 
CXXMethodDecl, but from there you have to go to its CXXRecordDecl 
directly, not via getParents(), as it might be an out-of-line 
definition.</blockquote><br></div>Ok, <span lang="en"><span>that's much</span> <span>clearer.</span></span> <span lang="en"><span>I hope I can</span> <span>implement it</span> <span>without</span> <span>problems.</span></span><div class="">
<br><br><blockquote>No, you get the children directly from the AST nodes.</blockquote><br></div>Sorry if my question is too trivial, but I am not so expert using these libraries. I can find children in Stmt:<br><a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html#a489148e5d234a5a7f00d8b02981bcee5" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1Stmt.html#a489148e5d234a5a7f00d8b02981bcee5</a><br>
<br>but I couldn't find it in Decl. What is the way in this case?<br></div></div></blockquote><div><br></div><div>You can go from the DeclContext: <a href="http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html">http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html</a> </div>
<div>But generally, you'll want to use the AST matchers, or the RecursiveASTVisitor if you want to traverse the ast...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><div dir="ltr"><br><br><div><hr>Date: Fri, 11 Apr 2014 10:02:59 +0200<div><div class="h5"><br>Subject: Re: [cfe-dev] How to know in what CXXRecordDecl is a Stmt?<br>From: <a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a><br>
To: <a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a><br>CC: <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><br><div dir="ltr"><div><div>On Fri, Apr 11, 2014 at 9:19 AM, victor <span dir="ltr"><<a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a>></span> wrote:<br>

<blockquote style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div><div dir="ltr">Oh, thanks, I didn't know that method. <br><div><br><blockquote>Note that you'll not always end up in a CXXRecordDecl - sometimes you'll
 also end up in a method decl that is defined out-of-line.<br><br></blockquote></div>Ok, so I will go through the ParentVector and, if finding a method decl, I will get the CXXRecordDecl of that method with getParent() in CXXMethodDecl, is this right?<br>

</div></div></blockquote><div> </div><div>Well, as I said, not necessarily - you will definitely find a CXXMethodDecl, but from there you have to go to its CXXRecordDecl directly, not via getParents(), as it might be an out-of-line definition.</div>

<blockquote style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div dir="ltr"><br>BTW, Isn't there a getChildren in ASTContext for the contrary purpose? I was wondering the reason.<br>

</div></div></blockquote><div><br></div><div>No, you get the children directly from the AST nodes.</div><div> </div><blockquote style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
<div dir="ltr"><br>Thanks.<br><div><br><br></div><div><div><hr>Date: Thu, 10 Apr 2014 10:48:50 +0200<br>Subject: Re: [cfe-dev] How to know in what CXXRecordDecl is a Stmt?<br>From: <a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a><br>

To: <a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a><br>CC: <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a></div><div><div><br><br><div dir="ltr">
ASTContext (<a href="http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html</a>) has a getParents() method. Note that you'll not always end up in a CXXRecordDecl - sometimes you'll also end up in a method decl that is defined out-of-line.</div>


<div><br><br><div>On Thu, Apr 10, 2014 at 9:40 AM, victor <span dir="ltr"><<a href="mailto:pedretti_86@hotmail.com" target="_blank">pedretti_86@hotmail.com</a>></span> wrote:<br>
<blockquote style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div><div dir="ltr">Hello,<br><br>
<div dir="ltr">When I retrieve a Stmt in the AST, how can I know the CXXRecordDel to which that Stmt belongs to? I have been looking over the methods in the Stmt class, but I couldn't find an appropriate method to this end. <br>


<br>Thanks in advance.<br></div>
                                          </div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div></div></div>                                       </div></div>
</blockquote></div><br></div></div></div></div></div>                                     </div></div>
</blockquote></div><br></div></div>