<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>I'm having a problem and the information is not very enlightening:<br><br>/usr/local/include/llvm/ADT/SmallPtrSet.h:190: const PtrTy llvm::SmallPtrSetIterator<const clang::CXXRecordDecl *>::operator*() const [PtrTy = const clang::CXXRecordDecl *]: Assertion `Bucket < End' failed.<br>Stack dump:<br>...<br><br>Have you ever bumped into this error? The code of the method that gives the error is:<br><pre class="fragment"><a class="code" href="http://llvm.org/docs/doxygen/html/classllvm_1_1SmallPtrSetIterator.html#a1730fbaa5cd997f7f94cfab313efc001">00192</a> <span class="keyword">const</span> PtrTy <a class="code" href="http://llvm.org/docs/doxygen/html/classllvm_1_1SmallPtrSetIterator.html#a1730fbaa5cd997f7f94cfab313efc001">operator*</a>()<span class="keyword"> const </span>{
<a name="l00193"></a>00193     assert(<a class="code" href="http://llvm.org/docs/doxygen/html/classllvm_1_1SmallPtrSetIteratorImpl.html#ab01497ce0bb39908edbb877194c45b78">Bucket</a> < <a class="code" href="http://llvm.org/docs/doxygen/html/classllvm_1_1SmallPtrSetIteratorImpl.html#a8cdc03b6ca7233dddb05aa44af1f4c1e">End</a>);
<a name="l00194"></a>00194     <span class="keywordflow">return</span> PtrTraits::getFromVoidPointer(const_cast<void*>(*<a class="code" href="http://llvm.org/docs/doxygen/html/classllvm_1_1SmallPtrSetIteratorImpl.html#ab01497ce0bb39908edbb877194c45b78">Bucket</a>));
<a name="l00195"></a>00195   }</pre>http://llvm.org/docs/doxygen/html/SmallPtrSet_8h_source.html#l00183<br><br>I'm not sure where in the code this error occurs, but anyway, is this the correct way to use the method getParents? This gets all kind of nodes, not only Stmt, right?<br><br>clang::ASTContext::ParentVector pv = Context->getParents<Stmt>(*m);<br><br>Thanks.<br><br><br><br><div>Date: Fri, 11 Apr 2014 10:45:55 +0200<br>Subject: Re: [cfe-dev] How to know in what CXXRecordDecl is a Stmt?<br>From: klimek@google.com<br>To: pedretti_86@hotmail.com<br>CC: cfe-dev@cs.uiuc.edu<br><br><div dir="ltr"><div class="ecxgmail_extra"><div class="ecxgmail_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="ecxgmail_quote" style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex;">


<div><div dir="ltr"><div><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>
<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" target="_blank">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="ecxgmail_quote" style="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></div>                                     </div></body>
</html>